logoalt Hacker News

crotetoday at 1:09 PM3 repliesview on HN

The horrifying side effect of this is that "arr[idx]" is equal to "idx[arr]", so "5[arr]" is just as valid as "arr[5]".

Your colleagues would probably prefer if you forget this.


Replies

miningapetoday at 1:39 PM

Mom, please come pick me up. These kids are scaring me.

Joker_vDtoday at 1:26 PM

> so "5[arr]" is just as valid as "arr[5]"

This is, I am sure, one of the stupid legacy reasons we still write "lr a0, 4(a1)" instead of more sensible "lr a0, a1[4]". The other one is that FORTRAN used round parentheses for both array access and function calls, so it stuck somehow.

rocquatoday at 1:24 PM

That depends on sizeof(*arr) no?

show 2 replies