On Tue, Jun 12, 2012 at 11:07 PM, Ángel González <keis...@gmail.com> wrote: > On 11/06/12 23:12, Tom Boutell wrote: >> Can you really use setjmp and longjmp in that way safely? I thought it >> was only safe to longjmp "back," not "forward" - you can use them to >> fake exception support but that's it because you'll smash the stack >> otherwise. Something like that... > My first reaction was also "How do you return to the mid-running function?" > > However, given that the running function is in PHP-land, I think you could > (in non-zts, it's direct in zts), save EG() contents and replace with > new values, and then continue the execution. That's how it is currently implemented. The generator backs up the current execution context (execute_data, CVs, Ts), pushed stack arguments and several executor globals. When the generator is resumed everything is restored and it continues to run as if nothing happened :)
Doing context switching using setjmp family functions seems to me like a really scary thing to do. I don't think that one can do that in a sane way. Nikita -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php