Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38350 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23742 invoked from network); 18 Jun 2008 15:05:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jun 2008 15:05:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.162 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 212.25.124.162 mail.zend.com Windows 2000 SP4, XP SP1 Received: from [212.25.124.162] ([212.25.124.162:34432] helo=mx1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A6/34-03518-93429584 for ; Wed, 18 Jun 2008 11:05:30 -0400 Received: from us-ex1.zend.com ([192.168.16.5]) by mx1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 18 Jun 2008 18:05:36 +0300 Received: from [192.168.17.96] ([192.168.17.96]) by us-ex1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 18 Jun 2008 08:01:43 -0700 Message-ID: <4859234C.5010003@zend.com> Date: Wed, 18 Jun 2008 08:01:32 -0700 Organization: Zend Technologies User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 To: Gwynne Raskind CC: PHP Developers Mailing List References: <4856A547.3080801@gmx.net> <698DE66518E7CA45812BD18E807866CE01B11811@us-ex1.zend.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 18 Jun 2008 15:01:43.0797 (UTC) FILETIME=[38A6C250:01C8D154] Subject: Re: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP From: stas@zend.com (Stanislav Malyshev) Hi! > The Lua interpreter handles this by resolving variable references as > they're made; "someVariable1" is looked up in the closure's scope and > not found, so the interpreter steps out one scope and looks for it You may get into a problem here - creator's scope may not exist when you execute the closure, and using caller's scope would be very unexpected - usually closures are intended to capture part of creating environment, not calling environment. It would also impose serious penalty if you just use undefined variable - you'd have to go through whole stack up to the top. > there, repeat as necessary. Once found outside the closure's scope, > something similar to the proposed "lexical" keyword happens. Closures lexical in the proposal binds to creator's scope, not caller's scope, as I understood. Anyway, binding to caller's immediate scope doesn't seem that useful since you could just pass it as a parameter when calling. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com