Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:59863 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38726 invoked from network); 13 Apr 2012 08:36:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Apr 2012 08:36:43 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 67.192.241.203 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 67.192.241.203 smtp203.dfw.emailsrvr.com Linux 2.6 Received: from [67.192.241.203] ([67.192.241.203:35708] helo=smtp203.dfw.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 25/A0-35770-A95E78F4 for ; Fri, 13 Apr 2012 04:36:42 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp10.relay.dfw1a.emailsrvr.com (SMTP Server) with ESMTP id 69F8D1B820E; Fri, 13 Apr 2012 04:36:39 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp10.relay.dfw1a.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id DDB6C1B81FE; Fri, 13 Apr 2012 04:36:38 -0400 (EDT) Message-ID: <4F87E595.2090704@sugarcrm.com> Date: Fri, 13 Apr 2012 01:36:37 -0700 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 MIME-Version: 1.0 To: Charlie Somerville CC: Yasuo Ohgaki , "internals@lists.php.net" , Verbitsky Alexander References: <4F87DF77.7040608@mail.by> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Allow "use( $longname as $alias)" syntax for closures declaration From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > I'm at a bit of a loss as to why Laruence is claiming that allowing > closures to implicitly access variables in the outer scope requires > duplicating the symbol table. Because variables need to be stored somewhere after the parent function exits. > Is there any technical reason why it's not possible for scopes to retain a > pointer to their parent scopes so variables can be looked up that way? Because the parent scope will be gone by the time closure is called. Unless we retain a copy of it - which in most cases is very expensive and impractical - you usually don't need all variables from parent scope - you need 1-2 of them, keeping all of them linked to the closure - and thus not freed until closure ceases to exist - would be very expensive. Declaring shared variables explicitly is a trade-off allowing you to not keep all the variables in case you do not need them. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227