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

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

Dan Sugalski wrote:

> At 07:08 PM 12/10/2001 +0000, Seth Gordon wrote:
>> Generally speaking, when you call a function, your program explicitly
>> says "evaluate this function with such-and-such arguments".  The
>> interpreter translates this to "evaluate this function with
>> such-and-such arguments, and return the value and the control of
>> further execution to *here*."
>> That "*here*" is the continuation.  If the programmer can get explicit
>> control of the continuation, then he or she can do 
>> perv^H^H^H^Hinteresting
>> things, since a function can return values to somewhere other than its
>> immediate caller.
> 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.
>                     Dan
> --------------------------------------"it's like this"-------------------
> Dan Sugalski                          even samurai
> dan@sidhe.org                         have teddy bears and even
>                                      teddy bears get drunk

A continuation isn't a function call, when you resume a continuation 
control goes to the point the continuation was captured.

Jeffrey Palm --> http://www.cs.colorado.edu/~jdp