Re:What PHP 5.5 might look like
by MarceloRamos on Thursday July 12, 2012 @12:11PM
(#4235259)
Yes what the code does is very clear, but the function call is even a level up clearer, maybe you don't want to know how it does it's job, you just want an array of values in a column (array_column(array, column)).
Personally I like comprehensions, but I tend to disguise them behind a function, it's much more clear to me. (but if I need the code to be super fast, I avoid using an extra function.)
Re:What PHP 5.5 might look like
by TazeTSchnitzel on Thursday July 12, 2012 @02:26PM
(#4235898)
>PHP only added namespaces in 5.3.0 and can't modularize their globals into namespaces without causing massive backwards compatibility problems. PHP is stuck with a polluted global namespace
They could do what Python did for 3.0, and make a tool similar to Python's 2to3 that replaces global namespace references.
Re:What PHP 5.5 might look like
by sirclueless on Thursday July 12, 2012 @03:33PM
(#4236281)
That sounds like a disaster. I don't think anyone wants to follow Python's lead on breaking backwards compatibility without a very good reason. A much better reason than a cluttered namespace.
As far as list comprehensions, I tend to find list comprehensions the readable and self documenting, at least in Python where I most commonly see them. If nothing else, what is the ordering of the arguments for the equivalent non list comprehension? With list comprehensions you don't have that impedance.
I can also convert the majority of list comprehensions into English quite easily -- "output x for each x in range(10) if x is divisible by 2" (though it may be cleaner if it was "for each x in range(10) [output x] if x is divisible by 2").[1]: http://php.net/quickref.php
[2]: http://docs.python.org/library/functions.html + http://docs.python.org/library/exceptions.html