Re: Re: Generators in PHP
| From: | Derick Rethans | Date: | Sun, 19 Aug 2012 16:03:49 +0000 |
| Subject: | Re: Re: Generators in PHP | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-62262@lists.php.net to get a copy of this message | ||
On Sun, 19 Aug 2012, Nikita Popov wrote:
> On Sun, Aug 19, 2012 at 6:28 AM, Stas Malyshev <smalyshev@sugarcrm.com> wrote:
> >
> >> For PHP we would need to have some similar behavior. PHP's current
> >> exception model is incompatible with GeneratorExitException
> >> (because PHP does not have BaseExceptions). So what I'd probably do
> >> instead is monkeypatch a ZEND_RETURN opcode at the current
> >> execution position and
> >
> > Patching opcodes is not a good idea, since opcodes could be cached,
> > and the cache can be shared between different processes.
>
> Patching a single opcode should be okay, because it does not require
> modification of the op_array. Only execute_data->opline has to be
> changed (and the execute data is not shared). The exception handling
> mechanism currently uses the same technique. It patches an
> ZEND_HANDLE_EXCEPTION opcode into the current position.
Please do not modify opcodes for running code. That is a ginormous hack
and it *will* cause problems with some code.
Derick
--
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug