Re: PATCH: anonymous functions in PHP

From: Date: Wed, 21 Mar 2007 18:45:59 +0000
Subject: Re: PATCH: anonymous functions in PHP
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  Groups: php.internals 
Request: Send a blank email to internals+get-28542@lists.php.net to get a copy of this message
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/

« previous php.internals (#28542) next »