Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34123 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1478 invoked by uid 1010); 20 Dec 2007 09:43:40 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 1463 invoked from network); 20 Dec 2007 09:43:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Dec 2007 09:43:40 -0000 Authentication-Results: pb1.pair.com smtp.mail=rquadling@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rquadling@googlemail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.146.181 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@googlemail.com X-Host-Fingerprint: 209.85.146.181 wa-out-1112.google.com Received: from [209.85.146.181] ([209.85.146.181:32393] helo=wa-out-1112.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4F/2B-15872-B493A674 for ; Thu, 20 Dec 2007 04:43:39 -0500 Received: by wa-out-1112.google.com with SMTP id l24so5639051waf.17 for ; Thu, 20 Dec 2007 01:43:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=slgR+SsMHraOcLJM22CrPwqzSS34GB4xGEhW/gD/4xw=; b=OtnZnG650xgqUxEN9W3B0i6lQFe2GkhcxWLRWFeLrBX9bPTTqoweMt2SH62SKeKswCxpXlrcHA2b9stIvqWBdnpTquFNe6ScniLC7k9ydgnj+80mDtRtjEHnmAxEnqogGA6Lw5+4J78mM91sIzn+IDntnVXJMn90RK2cH6jJ8lQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=CN3rmiX0WiMMSVGdhfx7TEyfHFkmNBuEKiRvsLonvBMlrl0Cvk/WMiWKyk2LVkb6OsYAvsZeHC3rxWxiQIQP5mGAzOWp5aRDNKGClCB0wOnxGS0Bie4Kjm2WLdckrfdCUFN+CLYYxkzzWT5XO+Y+UPpcAvmHRk/OnZ971ukY8fg= Received: by 10.114.169.2 with SMTP id r2mr6725312wae.76.1198143816034; Thu, 20 Dec 2007 01:43:36 -0800 (PST) Received: by 10.114.210.8 with HTTP; Thu, 20 Dec 2007 01:43:35 -0800 (PST) Message-ID: <10845a340712200143k1b83db1bufbb1462aceb439c9@mail.gmail.com> Date: Thu, 20 Dec 2007 09:43:35 +0000 Reply-To: RQuadling@GoogleMail.com To: "Alexey Zakhlestin" Cc: "Stanislav Malyshev" , "troels knak-nielsen" , internals@lists.php.net In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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> Subject: Re: [PHP-DEV] Re: PATCH: anonymous functions in PHP From: rquadling@googlemail.com ("Richard Quadling") On 20/12/2007, Alexey Zakhlestin wrote: > On 12/20/07, Stanislav Malyshev wrote: > > > I think we need it. In the current incarnation, anonymous functions > > > are so impractical to use, that it's a barrier. I think that is > > > unfortunate, because it could be an interesting and useful direction > > > to take for PHP. The users, who don't know what a closure is, could > > > > Direction like what? > > 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) }); That makes perfect sense to me as I see/use this sort of code in JavaScript. The argument about making the filter a global function is not sensible to apply in all circumstances. In many cases the filter is only going to be of use in an array_filter() call, so now we would have 2 functions to do the work of 1. If you think about for() and foreach(), these are functional-ish ideas. Iterators in general should quite happily support this idea. Maybe a syntax like this would be more appealing ... array_filter($my_data as $test) { return 4 === ($test % 4); } This sort of looks like a foreach, which is extremely readable. Richard. -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!"