4 ms·
`char *p` is identical to `char* p`??
by skribanto 4y ago
`char *p` is identical to `char* p`??
- peterfirefly 4y agoYes, but "char* p,q;" is "char *p,q;" -- q is a char, only p is a pointer.
- jacquesm 4y agoYes, so don't do that. Do: char * p; char q;
- WalterBright 4y agoIn D we write it "char* p, q;" because both p and q are pointers.
- quietbritishjim 4y agoIf you've gone to the trouble of changing the meaning, why not go the whole way and make a more decent syntax? Ideally I'd argue type second, but at least include a separator in there: // Completely clear that both are pointers var p, q: char* I actually think that using the existing syntax for something different, even if it's "fixing" the meaning, is worse than just using the old behaviour.
- WalterBright 4y ago> Completely clear that both are pointers Yes, it is, and "char* p, q;" is also completely clear! (And much more concise, too.) > I actually think that D's use of an existing syntax for something different, even if it's "fixing" the meaning, is worse than just using the old behaviour. At first blush it does seem like a problem. But my experience in translating many, many tens of thousands of lines of code from C to D is making a mistake with that always results in an obvious semantic error that is trivial to fix.