Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38322 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5270 invoked from network); 17 Jun 2008 11:48:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jun 2008 11:48:22 -0000 X-Host-Fingerprint: 24.228.80.153 ool-18e45099.dyn.optonline.net Received: from [24.228.80.153] ([24.228.80.153:9690] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 18/A7-61252-684A7584 for ; Tue, 17 Jun 2008 07:48:22 -0400 Message-ID: <18.A7.61252.684A7584@pb1.pair.com> To: internals@lists.php.net Date: Tue, 17 Jun 2008 07:48:27 -0400 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041206 Thunderbird/1.0 Mnenhy/0.6.0.104 MIME-Version: 1.0 References: <4856A547.3080801@gmx.net> <4856B752.1040500@gmx.net> <200806162257.24141.larry@garfieldtech.com> In-Reply-To: <200806162257.24141.larry@garfieldtech.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Posted-By: 24.228.80.153 Subject: Re: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP From: edwardzyang@thewritingpot.com ("Edward Z. Yang") Larry Garfield wrote: > $e = new Example(); > $lambda = $e->myMethod(); > $e->$lambda(5); > > That doesn't seem right at all, but that's how I interpret "Essentially, > closures inside methods are added as public methods to the class that > contains the original method." Can you give an example of what that actually > means? At first blush, this sets off warning bells in my head, I suppose because my notion of a lambda says that the lambda should not carry any baggage about the context it was created in. However, with further thought, I believe that binding the lambda's lexical scope to the place it was defined is: * Conducive to good coding (you will always be able to look outside the lambda to find out where the lexical variables are coming form) * Adds functionality, since anything you want to pass to the function via the callee's context can be passed via a parameter What would be neat, however, is the ability to rebind the lambda to another context. Also, I don't know how other languages do it (Python? Lisp?). -- Edward Z. Yang GnuPG: 0x869C48DA HTML Purifier Anti-XSS Filter [[ 3FA8 E9A9 7385 B691 A6FC B3CB A933 BE7D 869C 48DA ]]