Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:28417 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 46482 invoked by uid 1010); 19 Mar 2007 09:20:40 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 46467 invoked from network); 19 Mar 2007 09:20:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Mar 2007 09:20:40 -0000 Authentication-Results: pb1.pair.com smtp.mail=cschneid@cschneid.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=cschneid@cschneid.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain cschneid.com from 195.226.6.51 cause and error) X-PHP-List-Original-Sender: cschneid@cschneid.com X-Host-Fingerprint: 195.226.6.51 darkcity.gna.ch Linux 2.6 Received: from [195.226.6.51] ([195.226.6.51:46052] helo=mail.gna.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5E/51-33476-5E55EF54 for ; Mon, 19 Mar 2007 04:20:39 -0500 Received: from localhost (localhost [127.0.0.1]) by darkcity.gna.ch (Postfix) with ESMTP id A778293CB5; Mon, 19 Mar 2007 10:20:34 +0100 (CET) Received: from unknown by localhost (amavisd-new, unix socket) id client-XXc8F3hp; Mon, 19 Mar 2007 10:20:33 +0100 (CET) Received: from [192.168.1.42] (217-162-171-242.dclient.hispeed.ch [217.162.171.242]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by darkcity.gna.ch (Postfix) with ESMTP id A987E93C73; Mon, 19 Mar 2007 10:20:33 +0100 (CET) Message-ID: <45FE55DF.9010006@cschneid.com> Date: Mon, 19 Mar 2007 10:20:31 +0100 User-Agent: Thunderbird 1.5.0.10 (Macintosh/20070221) MIME-Version: 1.0 To: Stanislav Malyshev CC: internals@lists.php.net References: <86478A67-DCA2-4000-9EF0-DA4338E8389B@omniti.com> <45FDF031.4010508@zend.com> <45FE2312.1050506@zend.com> In-Reply-To: <45FE2312.1050506@zend.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: amavisd-new at gna.ch Subject: Re: [PHP-DEV] PATCH: anonymous functions in PHP From: cschneid@cschneid.com (Christian Schneider) Stanislav Malyshev wrote: > Well, making it work makes this thing closure. Otherwise it's just a > nice way to save a couple of keystrokes :) Not to diminish your work, > but there's a danger people would think it is closure because it looks > like one (i.e., in other languages closures look exactly this way, e.g. > Javascript). Wez' proposal sounds very intriguing. At the same time I wouldn't try to add closures to PHP as while they might be a mighty concept they are also complicated and have a high WTF factor IMHO. When I first started doing more complex things in Javascript I was bitten more than once by closures: Sometimes they did what I expected and sometimes they didn't (e.g. when using 'this'). But I agree that it would be great to being able to pass context to the generated function, preferably not via a global variable. One possible solution would be to generate the function as a method of the current object and expose this so something like usort($data, function($a, $b) { return $this->cmp($a, $b); }); could be used. - Chris