Re: [PHP-DEV] Re: 回复: [PHP-DEV] resume after exception

2012-04-06 Thread Rasmus Schultz
2012/4/5 Anthony Ferrara ircmax...@gmail.com: Why not just do: function foo(callable $callback) {    $a = 0;    $callback();    $a = 1;    $callback(); } function bar() {    foo(function() { echo 1; }); } It's functionally the same, but doesn't have the stack magic. Now, it won't

Re: [PHP-DEV] Re: 回复: [PHP-DEV] resume after exception

2012-04-06 Thread Anthony Ferrara
Rasmus, I think you're missing the difference here. Let's look at an exception. try { doFoo(); throwsException(); doBar(); } catch (Exception $e) { doBaz(); } This is NOT the same as: doFoo(); throwsException('doBaz'); doBar(); To emulate the exception using continuation

[PHP-DEV] Re: 回复: [PHP-DEV] resume after exception

2012-04-05 Thread Rasmus Schultz
interesting, but this doesn't have anything in particular to do with what I was talking about. to the best of my understanding, an exception transfers control back to the nearest calling code that has declared it is ready/willing/able to resume control in the event that, somewhere up the

Re: [PHP-DEV] Re: 回复: [PHP-DEV] resume after exception

2012-04-05 Thread Anthony Ferrara
Rasmus, What would that give you that a continuation passing paradigm wouldn't? Why not tell the code what to call before you call it, rather than bubbling up the stack (which then forces a fork of the stack, as you need to partially unwind it, but keep track of what you unwound for the resume).