Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38356 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57865 invoked from network); 18 Jun 2008 16:32:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jun 2008 16:32:51 -0000 Authentication-Results: pb1.pair.com smtp.mail=gwynne@wanderingknights.org; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=gwynne@wanderingknights.org; sender-id=unknown Received-SPF: error (pb1.pair.com: domain wanderingknights.org from 208.97.132.202 cause and error) X-PHP-List-Original-Sender: gwynne@wanderingknights.org X-Host-Fingerprint: 208.97.132.202 sd-green-bigip-202.dreamhost.com Linux 2.4/2.6 Received: from [208.97.132.202] ([208.97.132.202:40472] helo=postalmail-a5.g.dreamhost.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FF/0B-03518-2B839584 for ; Wed, 18 Jun 2008 12:32:51 -0400 Received: from [192.168.2.192] (c-24-128-82-179.hsd1.ma.comcast.net [24.128.82.179]) by postalmail-a5.g.dreamhost.com (Postfix) with ESMTP id 722E6BF2E9; Wed, 18 Jun 2008 09:32:45 -0700 (PDT) Cc: PHP Developers Mailing List Message-ID: To: Stanislav Malyshev In-Reply-To: <4859234C.5010003@zend.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v924) Date: Wed, 18 Jun 2008 12:32:38 -0400 References: <4856A547.3080801@gmx.net> <698DE66518E7CA45812BD18E807866CE01B11811@us-ex1.zend.net> <4859234C.5010003@zend.com> X-Mailer: Apple Mail (2.924) Subject: Re: [PHP-DEV] [PATCH] [RFC] Closures and lambda functions in PHP From: gwynne@wanderingknights.org (Gwynne Raskind) On Jun 18, 2008, at 11:01 AM, Stanislav Malyshev wrote: >> 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. This lookup happens at the time the closure is first declared, and the value is stored for later use by the closure; the calling scope doesn't need to exist anymore. The problem with going to the top of the stack is an issue, though; the Lua interpreter's idea of "scope" is rather different from PHPs, and it's not nearly the same penalty there. > -- Gwynne, Daughter of the Code "This whole world is an asylum for the incurable."