Re: [RFC] Closures: updated proposal and patch
| From: | Stanislav Malyshev | Date: | Wed, 02 Jul 2008 17:30:05 +0000 |
| Subject: | Re: [RFC] Closures: updated proposal and patch | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-38703@lists.php.net to get a copy of this message | ||
Hi!
Re-reading the proposal, I encountered something unexpected:
$replacer = $example->getReplacer ('goodbye');
echo $replacer ('hello world'); // goodbye world
$replacer->setSearch ('world');
echo $replacer ('hello world'); // hello goodbye
Does it mean closure would forward all method calls to it to the enclosed object? Not sure if it's a good idea - seems too magical. Maybe we need to be more explicit, something like $replacer->getThis()->setSearch('world')? I.e., if you have object of type Closure, you can't actually know what methods it has - it'd depend on $this inside, which we don't have access to right now. That seems kind of strange.
Or did you just mean $example->setSearch() and I'm worried about nothing? :) In this case, I'd just propose to have getThis() anyway.
Except for that - excellent work!
--
Stanislav Malyshev, Zend Software Architect
stas@zend.com http://www.zend.com/
(408)253-8829 MSN: stas@zend.com