[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: So, what the heck is a continuation anyway?



At 07:40 PM 12/10/2001 +0000, Seth Gordon wrote:
>    From: Dan Sugalski <dan@sidhe.org>
>
>    Oh, I see. A continuation is a function call where, not only do you 
> get to
>    decide what you return, you get to decide where you return it to.
>
>    That's evil. I really like it. :)
>
>    Are there general rules as to where you're allowed to return to? I 
> presume
>    picking PC addresses out of the air's considered bad form.
>
>In Scheme, the "call-with-current-continuation" form basically allows
>you to say, "I want other functions to be able to return their values
>*here* instead of to their callers", and then you can refer to
>"*here*" with the variable name of your choice, and then pass that
>variable to other functions.

Does *here* always have to be above the routine actually returning to the 
continuation? For example, if I have code flow that looks like:


              top
               ^
              / \
             A   B

where my code runs from top to A back to top and then to B, can I get a 
continuation object/marker from within A and pass it to B, which then 
triggers it and returns to A even though I've unwound the stack frames for A?

>The bad form comes when you start doing things like using the same
>continuation more than once.

Yeah, but the bad forms tend to be the most interesting. :)

					Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
dan@sidhe.org                         have teddy bears and even
                                      teddy bears get drunk