News for hackers. Stuff that matters.
Re:What PHP 5.5 might look like by Smerity on Thursday July 12, 2012 @11:52AM (#4235175)
One major disadvantage with so many functions is the cluttered global namespace[1]. 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, I'd be wary of adding more. Mind you, I'm well aware that this feeling could just be as I'm primarily a Python coder -- in PHP, you perform array_keys($xyz) whilst in Python it's xyz.keys(). Whilst you might consider Python as cheating by pushing all the functions onto the objects, it results in a far happier global namespace[2].

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.

  // Python example with filter vs list comprehension
  // Filter requires you to remember the ordering --
  // and does it filter on True or False?
  filter(lambda x: x % 2 == 0, range(10)) --> 0 2 4 6 8
  // The list comprehension is self documenting
  [x for x in range(10) if x % 2 == 0] --> 0 2 4 6 8
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

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.