Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:28542 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94630 invoked by uid 1010); 21 Mar 2007 18:48:09 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 94614 invoked from network); 21 Mar 2007 18:48:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Mar 2007 18:48:09 -0000 Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 63.205.162.114 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 63.205.162.114 unknown Windows 2000 SP4, XP SP1 Received: from [63.205.162.114] ([63.205.162.114:42124] helo=us-ex1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 32/90-09395-6ED71064 for ; Wed, 21 Mar 2007 13:48:09 -0500 Received: from [127.0.0.1] ([192.168.16.109]) by us-ex1.zend.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 21 Mar 2007 11:48:04 -0700 Message-ID: <46017D67.6090800@zend.com> Date: Wed, 21 Mar 2007 11:45:59 -0700 Organization: Zend Technologies User-Agent: Thunderbird 2.0b2 (Windows/20070116) MIME-Version: 1.0 To: Jacob Santos CC: internals@lists.php.net 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> <698DE66518E7CA45812BD18E807866CE18559A@us-ex1.zend.net> <40259.216.230.84.67.1174435351.squirrel@www.l-i-e.com> <72.02.09395.9CD51064@pb1.pair.com> In-Reply-To: <72.02.09395.9CD51064@pb1.pair.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 21 Mar 2007 18:48:04.0203 (UTC) FILETIME=[754003B0:01C76BE9] Subject: Re: [PHP-DEV] PATCH: anonymous functions in PHP From: stas@zend.com (Stanislav Malyshev) > Err, Pseudo-oplines, but since I don't exactly know anything about PHP > opcodes, I'm just pulling this stuff out of my ass. > > CREATE_FUNCTION test > > CREATE_FUNCTION zend_anon_0 > > RET_VAL 0 > > END_FUNCTION > > END_FUNCTION > > CALL 'test' > > ASSIGN $0, $valuefunction It looks like you misunderstand how the engine compiles functions. Each function has its own op array. Also, the code you brought is less interesting. More interesting is code such as: function prefixer($p) { $f = function ($name) { return "$p. $name"; } return $f; } $mr = prefixer("Mr"); $mrs = prefixer("Mrs"); echo $mr("Jones"); echo $mrs("Jones"); As you could have guessed, that should result in "Mr. Jones" and "Mrs. Jones" printed. Figuring out where the "Mr." comes from when $mr("Jones") is called would help understand how closure works. -- Stanislav Malyshev, Zend Products Engineer stas@zend.com http://www.zend.com/