Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:28490 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24290 invoked by uid 1010); 20 Mar 2007 18:40:59 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 24274 invoked from network); 20 Mar 2007 18:40:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Mar 2007 18:40:59 -0000 Authentication-Results: pb1.pair.com header.from=wez@omniti.com; sender-id=pass; domainkeys=good Authentication-Results: pb1.pair.com smtp.mail=wez@omniti.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain omniti.com designates 66.225.209.50 as permitted sender) DomainKey-Status: good X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: wez@omniti.com X-Host-Fingerprint: 66.225.209.50 mail.omniti.com Linux 2.5 (sometimes 2.4) (4) Received: from [66.225.209.50] ([66.225.209.50:58930] helo=mail.omniti.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CC/00-21779-8BA20064 for ; Tue, 20 Mar 2007 13:40:58 -0500 X-DKIM: Ecelerity dkim_sign implementing draft-ietf-dkim-base-00 DKIM-Signature: a=rsa-sha1; d=omniti.com; s=test; t=1174416052; c=simple/simple; q=dns; i=@omniti.com; h=From; b=GLcJ6vAShuB3RDIJtf2R3K6/U5bWA2hjfkfzRazEWDDQifZSw7l4oS87gDKhQdS5 hzrT7RB1S3z8SIq/9lGm3SOHI4IC/djW1redp1zeQT3PRAWu5BuBVu496HcufS2p X-DomainKeys: Ecelerity dk_sign implementing draft-delany-domainkeys-base-01 DomainKey-Signature: q=dns; a=rsa-sha1; c=nofws; s=test; d=omniti.com; h=Authentication-Results:Received:In-Reply-To:References:Mime-Version:Content-Type:Message-Id:Cc:Content-Transfer-Encoding:From:Subject:Date:To:X-Mailer; b=g3s+e5URORjMruahYx/lWUGvVSoWlLFlSoGJaFtmWnFV/wKp8cUwIGQR7FyUKuNI qrXw+AQRm3nk0N9O5LLXCzhtYD4wd1DxitqAgiuUwHIiaJ3iF3cqfzrWC56glBhc Authentication-Results: mail.omniti.com smtp.user=wez; auth=pass (LOGIN) Received: from [66.80.117.2] ([66.80.117.2:51368] helo=[10.80.116.165]) by mail.omniti.com (ecelerity 2.1.1.12 r(14453)) with ESMTPSA (cipher=AES128-SHA) id A0/A6-26454-EAA20064 for ; Tue, 20 Mar 2007 14:40:52 -0400 In-Reply-To: <460025EA.5050303@zend.com> References: <86478A67-DCA2-4000-9EF0-DA4338E8389B@omniti.com> <45FDF031.4010508@zend.com> <45FE2312.1050506@zend.com> <45FED6D9.8030307@caedmon.net> <45FEDAE5.2010309@zend.com> <45FEE396.7040905@caedmon.net> <0757BDEA-65F5-4123-B647-060DCA84B4B0@omniti.com> <45FEEF52.1060002@zend.com> <1174336464.24632.110.camel@blobule> <45FEF9A5.4050409@zend.com> <1174338801.24632.124.camel@blobule> <45FEFDCE.7050100@zend.com> <1174339527.24632.129.camel@blobule> <45FF01FE.6070504@zend.com> <698DE66518E7CA45812BD18E807866CE185525@us-ex1.zend.net> <2b2f60dc7b3112ac164aba20fbddd29d@gravitonic.com> <460025EA.5050303@zend.com> Mime-Version: 1.0 (Apple Message framework v752.3) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-ID: Cc: Andi Gutmans , internals@lists.php.net, Sean Coates Content-Transfer-Encoding: 7bit Date: Tue, 20 Mar 2007 14:40:46 -0400 To: Stanislav Malyshev X-Mailer: Apple Mail (2.752.3) Subject: Re: [PHP-DEV] PATCH: anonymous functions in PHP From: wez@omniti.com (Wez Furlong) You need the callable type to store the closure information. Either that, or you need to store it in the op_array, which is "bad" because you don't know when you can free that closure state, so you have to carry it around for the rest of the request. I agree about $_SCOPES['foo']. I'm actually starting to lean towards just copying the entire local scope hash table and storing it in the callable/closure, and using that to initialize the symtable when you call into the function. --Wez. On Mar 20, 2007, at 2:20 PM, Stanislav Malyshev wrote: >>> of the function. Again, this would be created based on the >>> $_SCOPES fixup information, and again, $_SCOPES['i'] would be >>> rewritten as simply $i in the op_array. >>> >>> So the funcs array might look like this is var_dump()'d: >>> >>> 0 => callable('__anon_0', array('i' => 0)), >>> 1 => callable('__anon_0', array('i' => 1)), >>> 2 => callable('__anon_0', array('i' => 2)) > > How do you know it's 'i'? Does it mean compiler should record any > reference to _SCOPES? What if I do $_SCOPES[$foo] - is it that > unthinkable? What if I doo $a = "_SCOPES", $$a[$foo]? > > Only way I see you can really do it is to explicitly declare the > imported variables, otherwise you'll lose them - PHP is too dynamic > for compiler to be able to statically resolve it. > > On a side note: why one needs callable type? What can be done with > it which can't be done with string and $string()? > -- > Stanislav Malyshev, Zend Products Engineer > stas@zend.com http://www.zend.com/ >