C's index[arr] notation
I had always assumed that it was merely some strange artifact of the language, until I finally thought about it, and then finally understood:
arr[index] is equivalent to (arr + index), which by the commutative property of addition is equivalent to (index + arr) = index[arr].
Mind = blown It's not the same as (index + arr). arr is a pointer to the beginning address of a series of particular "types". These types have a specific size in memory. Index increments the pointer by (n * size_of(type)). arr[index] == arr + (n * size_of(type)) == (n * size_of(type)) + *arr He said it's the same as C pointer arithmetic already accounts for object sizes. And it's sizeof, not size_of. And I don't know what I was on. Proof positive that sleep depravation does not give me more time to be "productive". Thanks for the correction and apologies for my mistake. Always time for a refresher :) http://augustcouncil.com/~tgibson/tutorial/arr.html
which is correct. *(index + arr)
is completely different from arr + x
And it's a series of "values". x + *arr