Re:A convenient untruth: Array notation in C is a lie
by mnarayan01 on Thursday December 22, 2016 @08:31AM
(#13237127)
I don't know if "declarations mirror use" gets you all the way there. You can use:
(though obviously not saying you should), but you can't declare:
Obviously there's good reasons for that, but then you have "declarations mirror use, except when there's good reason not to", which basically brings you back to the original question.
[ Parent
| on HN ]
Re:A convenient untruth: Array notation in C is a lie
by wildmusings on Thursday December 22, 2016 @11:56AM
(#13238510)
Finding an exception doesn't invalidate the explanation. Being able to switch the index and array is more an accident of how C implements arrays than an actual use case.
Re:A convenient untruth: Array notation in C is a lie
by chc on Thursday December 22, 2016 @01:01PM
(#13239026)
> char *5[arr]
Isn't that exploiting a quirk of the operator's definition, rather than how the operator is intended to be used?
Re:A convenient untruth: Array notation in C is a lie
by mnarayan01 on Thursday December 22, 2016 @10:17PM
(#13242548)
I assume you're right, though I would love to see some of the original discussion around it. That said, while I don't think it's a catastrophic point against "declarations mirror use", I do think it's a strike against it.
Edit: I guess I'll also note here just for fun that while
char [5]arr;
seems reasonable enough, char [4][5]arr1;
char[5][4] arr2;
seems less so.