Hacker News new | past | comments | ask | show | jobs | submit login

Ok, but who actually uses that?



The point is to demonstrate that std::array isn't an array.


What makes you so sure that if C got better arrays, those would be arrays, supporting a[i] i[a] commutativity and all?

That is predicated on equivalence to *(a + i) where a is a dumb pointer whose displacement commutes.


That is a quirk of C's arrays, no other language besides Assembly allows for that.

And even in Assembly, it depends on the CPU flavor which kind of memory accesses are available.


It depends entirely on the whims of the assembly language design. Assembly lanuages for the Motorola 68000 could allow operand syntax like like [A0 + offset], which could commute with [offset + A0], but the predominant syntax for that CPU family has it as offset(A0) which cannot be written A0(offset).

None of that changes what instruction is generated, just like C's quirk is one of pure syntax that doesn't affect the run-time.


Ok, fair. But for almost all practical purposes, std::array is an appropriate array replacement.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: