Re: Generators in PHP
| From: | Nikita Popov | Date: | Wed, 06 Jun 2012 19:23:27 +0000 |
| Subject: | Re: Generators in PHP | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-60764@lists.php.net to get a copy of this message | ||
On Wed, Jun 6, 2012 at 4:15 AM, Laruence <laruence@php.net> wrote:
> Hi Nikita:
>
> the most important part to me is how did you implemented
>
yield
> keyword, is there a whole patch file I can look into?
>
> what will happen if you use a yield in a normal function?
>
> actually, I tried to implemented coroutine, but since I could not
> find a way to make zend_execute interruptable, then I didn't make it.
Yes I also faced that problem. The current execute() function accepts
an op_array and initializes the execution context from that
(execute_data + CVs + Ts).
So I added a new function execute_ex() which takes that execution
context directly. The execute() function now works by initializing the
execute_data using a new zend_create_execute_data_from_op_array()
function and then calls execute_ex() with it.
The most relevant commit for this change is
https://github.com/nikic/php-src/commit/f627be52540738e124da7cb1566d7f60a2b6a48b.
Nikita