At 10:24 PM +0100 7/8/02, Nicholas Clark wrote:
>On Mon, Jul 08, 2002 at 04:54:16PM -0400, Dan Sugalski wrote:
>> Pretty simple. (For illustrative purposes) To do that with
>> continuations, it'd look like:
>>
>> $cont = take_continuation();
>> if ($foo) {
>> $foo--;
>> invoke($cont);
>> }
>>
>> take_continuation() returns a continuation for the current point (or
>> it could return one for the start of the next statement--either
>> works), and invoke takes a continuation and invokes it. When you
>> invoke a continuation you put the call scratchpads and lexical
>> scratchpads back to the state they were when you took the
>> continuation.
>
>So take_continuation is called once and returns 1 or more times?
>(1st return is just after you called it, second and later are for each time
>you invoke $cont from somewhere else)
Yes, Though we could certainly set it up so that $cont represented
the state of the program immediately *after* the statement that
created the continuation.
>and invoke is goto-on-steroids, and never returns? (except if $cont is duff,
>somewhat like the exec system call in Unix only returns on failure)
More or less, yes.
>And everything else is serene and swan-like?
>
>(ie the language gives the appearance of moving smoothly on the surface,
>but under water its feet are paddling furiously to implement motion)
I see you've peeked behind the curtain. :)
--
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk