3 ms·
You have obviously never worked on a million-line codebase. When you have crap like this in your language: > E.g., $i = 0; $a[$i] = $i++; makes a different ar
by ScottBurson 14y ago
You have obviously never worked on a million-line codebase.
When you have crap like this in your language:
> E.g., $i = 0; $a[$i] = $i++; makes a different array than $i = 0; $a[$i + 0] = $i++;
you have no hope of making a truly large program work. There are just too many sources of itsy bitsy bugs; you'll never find them all.
(I'm not a PHP user; I have no idea why those are different arrays. Don't bother explaining; I don't want to know.)
- harshreality 14y agoI don't use PHP much, but I was curious, so here's the answer you don't want: You get $a[1] = 0 the first way, and $a[0] = 0 the second way. PHP seems to evaluate the array index before the right hand side if there is something more than a $variable to evaluate; otherwise PHP evaluates the array index after the right hand side, after $i has been incremented. I haven't used hiphop, but I'm curious if it preserves that disparity between arrays when translating to C++, or if it breaks PHP compatibility by making those two arrays equivalent.
- kmavm 14y agoThe entire point of my post was that we preserve the semantics of this (and many other) PHP-isms. We have to, because you never can tell which glitches useful code has come to depend on.