Git Product home page Git Product logo

Comments (5)

flatcap avatar flatcap commented on June 21, 2024

The idea of b5640bb was to ensure that the subject and real_subj are kept in sync.
The const is a hint to call mutt_env_set_subject() rather than altering them directly.

from neomutt.

nabijaczleweli avatar nabijaczleweli commented on June 21, 2024

FTR the fields are const, not the pointers; don't cast the const away, use the setter

from neomutt.

alejandro-colomar avatar alejandro-colomar commented on June 21, 2024

FTR the fields are const, not the pointers;

I'm not sure what you mean by this. char *const p means "p is a constant pointer to char", so the pointer is const.

Maybe you meant the the pointees aren't const, which I agree.

https://cdecl.org/

don't cast the const away, use the setter

Except that I count 10 casts outside of the setter. I'm not sure if something that requires adding 10 casts (+ the ones in the setter) is an improvement. Casts are the thing that hides most bugs by far, since they disable almost all compiler warnings.

from neomutt.

nabijaczleweli avatar nabijaczleweli commented on June 21, 2024

as far as i can tell, there's const-casts on both in the setter, merger, and deserialiser, all three of which are Envelope's member functions (or, as close as they can be), and entirely within the scope of the functions that should bypass the const.

there's an outlier in rfc2047_{de,de}code_envelope(struct Envelope *env), which juggles subject to conform to unfortunate memory management requirements and then calls the setter. also a member (or, sure, friend), also fine.

not sure where you're getting "cast away all the time" here, this reads to me as being perfectly as-designed (only Envelope members (and friends) are allowed to edit these directly) and as-desired (the shit works so everyone else is forced to use the setters so IMAP works)

from neomutt.

alejandro-colomar avatar alejandro-colomar commented on June 21, 2024

as far as i can tell, there's const-casts on both in the setter, merger, and deserialiser, all three of which are Envelope's member functions (or, as close as they can be), and entirely within the scope of the functions that should bypass the const.

there's an outlier in rfc2047_{de,de}code_envelope(struct Envelope *env), which juggles subject to conform to unfortunate memory management requirements and then calls the setter. also a member (or, sure, friend), also fine.

Hmmm, okay.

not sure where you're getting "cast away all the time" here,

Just a way of speaking.

It's not all the time, but a non-trivial amount: 7/52

$ grep -rn 'real_subj\>' | pee 'wc -l > /dev/tty' 'cat' | grep '(char' | wc -l
52
7

this reads to me as being perfectly as-designed (only Envelope members (and friends) are allowed to edit these directly) and as-desired

Yup; just that the design implies some slightly dangerous stuff, IMHO. But I guess since it's your design, it's your prerogative.

(the shit works so everyone else is forced to use the setters so IMAP works)

I would have probably just not forced anything, and just document that the setters should be used. But I know that you prefer C++, so I guess, it's all right. At least now I understand why it's *const + casts.

And FTR, I would just remove IMAP from neomutt(1), but that' not going to happen. It would certainly simplify it a lot. :)

Thanks for explaining!

from neomutt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.