-
-
Notifications
You must be signed in to change notification settings - Fork 380
Issue 9970: Document difference between type constructors & storage classes. #692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
IMO this is informative and well-written. I also couldn't find any DDoc syntax errors. |
Hmm... playing the devil's advocate: So what is the difference between |
This is where I need some help from the core dmd devs to clarify things... the only difference I know of between
But as for the difference in variable declarations, I honestly have no idea:
|
IIRC, in a discussion in the newsgroup not too long ago, Walter and Dicebot were discusssing it, and Dicebot was arguing that there really isn't any difference, but I don't remember what thread that was. And even if there is a difference for member functions, if we could just get it to become illegal to put |
If it were up to me, I'd say all const-qualified types should be written with parentheses |
That would be annoying in other ways, but it wouldn't really solve the |
OK, so let's have both: storage class |
LOL. Honestly, I would find it very annoying if I always had to use parens with |
The reason I advocate parentheses is because of the subtle but important distinction between |
Wasn't Andrei recently saying we should talk about type qualifiers not type constructors, because type constructors also include things as |
Well, I don't see how forcing everyone to use parens would help with that. If anything, it makes it worse, because then there are more cases where you have to figure out exactly what the parens are around.
TDPL certainly seems to favor the term type qualifier, so that wouldn't surprise me. I'm afraid that I'm not as educated as I should be on the differences. |
Forcing people to use parens will also force them to think more carefully about whether they really want |
Maybe. The type system would generally just result in compilation errors if they got it wrong, and personally, I've never had a problem with it, but I don't know about the average D programmer. |
@jmdavis It often leads to frustration, even if the compiler catches it:
Worse yet, if somebody accidentally gives the wrong type to a library API, you're screwed:
Basically, it's an all-round annoyance, even if it's nothing drastically nasty. I vote for mandatory parens. Bring on the lispism. :-P |
Well, I think that we're just going to have to agree to disagree on that one. |
Issue 13671 - http://dlang.org/const3.html incorrectly calls type qualifiers "type constructors" |
Can you please replace the term |
Done. Any other suggestions? The current PR still looks a bit incomplete, as things like the difference between |
Maybe I missed important parts of the discussion (and I don't actually want to be dragged deep into it ;-)), but even with the description in this PR, I don't get what makes "const" a storage type.
The type qualifier has an influence on where a variable is stored, but that is not influenced by the way the modifier is written. In addition, storage is determined by the scope of the declaration and whether an initializer is given. |
OK, so looks like the real source of the confusion is the visual confusion between:
and
The former is equivalent to |
Yes.
That would be my prefered style.
that produces |
Looking at the grammar again, StorageClass is a misnomer and should be replaced with Attribute. If you follow the grammar starting at AttributeSpecifier, you are supposed to parse something like "Attributes_opt StorageClassses_opt BasicType ..." with Attribute and StorageClass being identical. |
Issue 9970: Document difference between type constructors & storage classes.
Thanks |
It would have been nice if from the get-go we had the syntax |
Oh?? Do we actually support this syntax right now, or is it just a wishlist? |
A wish for a time-travel machine. :) |
Haha, OK. Hmm... what are the chances that this syntax can be added as an alternative syntax, and eventually become the recommended syntax, and the current syntax deprecated? |
It all depends on whether Walter thinks it's worth it. Personally I like syntax that makes things clear. I'd even love some form of |
Override would already be nice for for this. |
Fixes: https://issues.dlang.org/show_bug.cgi?id=9970
This is an initial stab at documenting the difference between type constructors and storage classes. Please chime in with any additions, omissions, inaccuracies, etc., that I've probably missed. :-)