sp00fD <sp00fD / yahoo.com> writes:

> So, continuations are kind of a pipe between methods?  I've never used
> continuations before, so go easy ;).  It almost seems like a mini
> client/server relationship is happening between the two "processes",
> but am I completely off or what...

Basically, continuations are like C's setjmp/longjmp on steroids.

The line:

     callcc { |cc|  ...stuff... }

creates a continuation object, and puts a reference to it in the block 
parameter, cc. It then executes the block.

The continuation object has just one method, 'call'. When invoked, it
jumps to the end of the original continuation block.

The wild thing is, it can be called from absolutely anywhere in the
program. The original block could be long gone, and the routine that
created it could have been popped off the stack months ago, but invoke
cc.call, and you'll find yourself transported back to the end of the
block, with all the state intact.

So in the example posted, continuations were used to jump between the
producer and consumer routines, basically implementing coroutining.

Regards


Dave