On 14-03-19 04:21, Larry Garfield wrote: > To the question of having both a generator and array version, I would have to > say no. As noted in the RFC, most cases where you'd want to use a > comprehension are not places where you'd be feeding the result into an array > function. On the off chance that you are converting the iterable into an > array is trivial enough that supporting, documenting, and learning two > slightly different syntaxes seems a net negative.
I fully agree that comprehensions can replace the usual array_*() functions in many cases. However, when you just happen to use a library that has an array oriented API, then you still need to pass it arrays. It would be disappointing when comprehensions turn out to be tedious to use in these situations, because they are no good fit. A dual generator / array syntax will make comprehensions fit in anywhere. Then there are the cases where you want to access the output of the comprehension multiple times. This may be expensive when a comprehension is a generator. So I still think that using a comprehension to create an array isn't an off chance but a common use case. Regards, Dik Takken -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php