Re: Continuations for fun and profit

2002-07-09 Thread Peter Haworth
On Tue, 9 Jul 2002 16:42:03 +0100, Peter Haworth wrote: > > When you invoke a continuation you put the call scratchpads and lexical > > scratchpads back to the state they were when you took the continuation. > > If you restore the lexicals, how does this ever finish? Never mind. It's the *acces

Re: Continuations for fun and profit

2002-07-09 Thread Peter Haworth
On Mon, 8 Jul 2002 16:54:16 -0400, Dan Sugalski wrote: > while ($foo) { > $foo--; > } > > Pretty simple. (For illustrative purposes) To do that with > continuations, it'd look like: > > $cont = take_continuation(); > if ($foo) { > $foo--; > invoke($cont); >

Re: Continuations for fun and profit

2002-07-09 Thread Ted Zlatanov
On Mon, 8 Jul 2002, [EMAIL PROTECTED] wrote: > Yep. But serializing continuations is either tough, or not > completely doable, since programs tend to have handles on things > outside their direct control like filehandles, sockets, database > connections, and suchlike things. Resuming a continuatio

Re: Continuations for fun and profit

2002-07-08 Thread Ted Ashton
Thus it was written in the epistle of Peter Scott, > > So if you could serialize a continuation, you could freeze your program > state to disk and restore it later? Cool, makes for easy checkpoint/restarts. I think that that would be true only if *all* data was maintained in those scratchpads

Re: Continuations for fun and profit

2002-07-08 Thread Dan Sugalski
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--; >> invok

Re: Continuations for fun and profit

2002-07-08 Thread Dan Sugalski
At 3:01 PM -0700 7/8/02, Peter Scott wrote: >At 04:54 PM 7/8/02 -0400, Dan Sugalski wrote: >>A continuation is a sort of super-closure. Like a closure it >>captures its lexical variables, so every time you use it, you're >>referring to the same set of variables, which live on until the >>contin

Re: Continuations for fun and profit

2002-07-08 Thread Peter Scott
At 04:54 PM 7/8/02 -0400, Dan Sugalski wrote: >A continuation is a sort of super-closure. Like a closure it captures >its lexical variables, so every time you use it, you're referring to >the same set of variables, which live on until the continuation's >destroyed. This works because the variab

Re: Continuations for fun and profit

2002-07-08 Thread Nicholas Clark
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 continua

Re: Continuations for fun and profit

2002-07-08 Thread David M. Lloyd
On Mon, 8 Jul 2002, 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 curren

Continuations for fun and profit

2002-07-08 Thread Dan Sugalski
Okay, for those of you following along at home, here's a quick rundown of what a continuation is, and how it works. (This is made phenomenally easier by the fact that perl has continations--try explaining this to someone used to allocating local variables on the system stack and get ready for