4 ms·
I don't see how that would work. I'd say that the two snippets describe different intentions and using one when you want the other is a case of not saying what
by likeclockwork 13y ago
I don't see how that would work. I'd say that the two snippets describe different intentions and using one when you want the other is a case of not saying what you mean.
A function call in a loop condition might have side effects or do something very unorthodox.
- humanrebar 13y agoI guess this is a problem with trivial examples. Pulling redundant work out of loops is a category of optimization that is widely used. In many cases, the optimizer can detect a lack of side effects on $list inside the loop body and perform the above optimization.
- esailija 13y agoThe canonical PHP implementation is a simple interpreter that cannot even dream of such optimizations. Hell, it uses unions to handle dynamic typing and hash tables to represent objects. The implementation by facebook (HipHop) might have such an optimization though.