Am 20.12.2007 um 10:19 schrieb Antony Dovgal:
On 20.12.2007 11:18, Alexey Zakhlestin wrote:
On 12/20/07, Antony Dovgal <[EMAIL PROTECTED]> wrote:
On 20.12.2007 09:57, Alexey Zakhlestin wrote:
being able to do the following (and not to worry about runtime
compilation) is a good reason on it's own:

array_filter($my_data, function($test){ return 3 === ($test % 4) });

Oh, my..
This code clearly demonstrates why a syntax like this should not be allowed. Ever.

you prefer cluttering namespace with a lot of oneliners?

Oh, come on.. Since when do we call it "cluttering"?
Is there some kind of limit on number of functions in a namespace?

Why limit yourself and "inline" the function instead of putting it
into a nice library of utility functions?

currently, people prefer to use explicit cycles instead of
array_map/array_filter and that looks ugly (hides actual logic behind
syntax), but at least it is not as slow as create_function.

Whatever people currently use - it's their choice.
If you think that people would magically switch to the new syntax (if we decide to add it after all) in a moment, I'm afraid I have to upset you - this will not happen in the next 10 years because of many reasons, so people would still use the good
old syntax they're used to.

I think you're wrong. There are, especially recently, many examples of libraries, frameworks and products that require a very recent version of PHP. Not to mention "internal" projects, hosted services etc etc etc where supporting legacy versions does not matter.

array_map($array, function($item) { return $item['foo'] == 'bar'; });
etc would be a brilliant way of making code more maintainable and readable. most people don't create a special function for this, and also don't use create_function, but instead write difficult to understand loops or other constructs to process the data.

The point is that creating a function or method just for one array_map call indeed _does_ clutter the namespace with unnecessary stuff. Inline functions are elegant and make code more readable and maintanable, and that should be reason enough to have them.

Best regards,

David

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to