4 ms·
I don't know if "declarations mirror use" gets you all the way there. You can use: *some_index[arr] (though obviously not saying you should), but you can't
by mnarayan01 10y ago
I don't know if "declarations mirror use" gets you all the way there. You can use:
*some_index[arr]
(though obviously not saying you should), but you can't declare:
char *5[arr];
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.
- marcoperaza 10y agoFinding 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.
- chc 10y ago> char *5[arr] Isn't that exploiting a quirk of the operator's definition, rather than how the operator is intended to be used?
- mnarayan01 10y agoI 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.