Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34130 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29359 invoked by uid 1010); 20 Dec 2007 10:56:17 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 29343 invoked from network); 20 Dec 2007 10:56:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Dec 2007 10:56:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=dz@bitxtender.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=dz@bitxtender.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain bitxtender.com from 80.237.132.12 cause and error) X-PHP-List-Original-Sender: dz@bitxtender.com X-Host-Fingerprint: 80.237.132.12 wp005.webpack.hosteurope.de Received: from [80.237.132.12] ([80.237.132.12:51207] helo=wp005.webpack.hosteurope.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 59/BF-15872-05A4A674 for ; Thu, 20 Dec 2007 05:56:16 -0500 Received: from [85.183.90.3] (helo=[10.1.1.120]); authenticated by wp005.webpack.hosteurope.de running ExIM using esmtpsa (TLSv1:RC4-SHA:128) id 1J5J4X-0003g4-8x; Thu, 20 Dec 2007 11:56:13 +0100 Cc: Alexey Zakhlestin , internals@lists.php.net Message-ID: <3B55D45A-9FAD-4869-B8CA-E684CC46B752@bitxtender.com> To: Antony Dovgal In-Reply-To: <476A33BD.1050508@daylessday.org> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v915) Date: Thu, 20 Dec 2007 11:56:12 +0100 References: <98b8086f0712150818n40056cedyf0aae7a5a08a27b7@mail.gmail.com> <200712172130.08216.larry@garfieldtech.com> <4FADC266-873E-4FD2-BEC8-28EA9D833297@procata.com> <200712172341.54372.larry@garfieldtech.com> <98b8086f0712191345h7fe11a7kc5d34b0369754c8f@mail.gmail.com> <47699960.1090101@zend.com> <98b8086f0712191528n2fd348d0oe3da9eed20d87194@mail.gmail.com> <4769ACF5.7000701@zend.com> <476A208D.9020201@daylessday.org> <476A33BD.1050508@daylessday.org> X-Mailer: Apple Mail (2.915) X-bounce-key: webpack.hosteurope.de;dz@bitxtender.com;1198148176;618304aa; Subject: Re: [PHP-DEV] Re: PATCH: anonymous functions in PHP From: dz@bitxtender.com (=?ISO-8859-1?Q?David_Z=FClke?=) 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 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