Hi! > Here it is very obvious that we want to import a variable. Especially, I > wonder how > $array = array_map(function ($x) use ($y) { return $x + $y; }, $array); > is making such simple applications more readable? And especially, what value > does it add here?
It is making it more readable by explicitly specifying that we're using function, that this function imports $y from parent scope and returns $x + $y. Of course, a seasoned programmer that has years of experience in functional languages would recognize this pattern, but that's not exactly the main target audience of PHP. And I do not think the argument "you don't have to use it" is a good one for adding language syntax constructs. If it's in the language, you'd have to deal with it, and you'd have to teach other people to deal with it. It's not some function sitting in the extension that may not even be loaded - it's part of language syntax. So if it would encourage write-only code, you'd have to deal with it even if you don't personally create write-only code. -- Stas Malyshev smalys...@gmail.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php