Re:A convenient untruth: Array notation in C is a lie
by bluetomcat on Thursday December 22, 2016 @12:27PM
(#13238751)
> Surely it would still mirror use if the operators were applied to the type, rather than the identifier?
The "type" is actually a list of storage class specifiers (static, extern, auto, register, typedef, _Thread_local), type qualifiers (const, volatile, restrict) and type specifiers (int, char, float, double, signed, unsigned, long, short, void). Imagine the soup of keywords that would have to be at the deepest level of the expression:
static const volatile unsigned char *arr[X];
// vs
*static const volatile unsigned char[X] arr;
Re:A convenient untruth: Array notation in C is a lie
by Nullabillity on Thursday December 22, 2016 @07:37PM
(#13241825)
static, const, and volatile modify the variable itself, not what values it's legal for it to contain. So the outcome should be:
static const volatile *unsigned char[X] arr;
Or, because signedness should be a property of the type, not an arbitrary modifier: static const volatile *char[X] arr;
Re:A convenient untruth: Array notation in C is a lie
by fredmorcos on Thursday December 22, 2016 @12:32PM
(#13238796)
'char ٭arr[X]' over '٭char[X] arr'
What is this dirt after char and before char? This wouldn't even compile.
Re:A convenient untruth: Array notation in C is a lie
by bluetomcat on Thursday December 22, 2016 @12:35PM
(#13238830)
HN converts asterisks to italics and I too couldn't find a way to escape them, except when surrounded by backticks `*`. Not a C-friendly discussion forum :-)
Preferring 'char ٭arr[X]' over '٭char[X] arr' seems arbitrary to me. I see no reason the 'declaration mirror use' principle can differentiate between the two.
Personally I prefer the latter since it makes it easy to separate the type from the identifier.