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

Re: Continuations?



In article <bruce-FA3F8B.11010607112000@news.nzl.ihugultra.co.nz>, 
Bruce Hoult <bruce@hoult.org> wrote:

> In article <3A06FEB9.68B7D2D@jenkon.com>, Bryn Keller <brk@jenkon.com> 
> wrote:
> 
> > Hi folks,
> >     After poking around Dylan for a while, I can't seem to find any
> > mention of continuations, despite Dylan's Scheme-like feel. Have I just
> > missed them somewhere? If not, is there something similar? For instance,
> > can the condition handler system be bent into a continuation-like shape?
> > If the answer to all the above is no, has any thought been given to
> > including them in the future?
> 
> Dylan doesn't have general call/cc but it does have built-in facilities 
> that do several of the things that Scheme people use call/cc to build:
> 
> block (xyzzy)
>    ...
> end
> 
> binds xyzzy to an exit procedure in the same sort of way that call/cc 
> does.  You can use it anywhere inside the block to immediately exit and 
> return a value for the block as a whole.  You can store the exit 
> procedure in variables, and pass it to other functions.  The only thing 
> you *can't* do is use xyzzy() after exiting from the block.  Thus you 
> can't call the same continuation multiple times, and you can't use it to 
> build threads.
> 
> If you want threads, then Dylan is intended to be used with operating 
> system- or library-provided threads.
> 
> -- Bruce

It is too bad that you can't do coroutines at least.
coroutines should be very easy to support since it only requires
switching stacks. You could even add coroutines to C.
Coroutines are immensely useful since they allow multiple algorithms
to be easily intertwined in complex ways with simple code. They allow
easy creation of lazy/incremental algorithms.
Most thread libraries are not very efficient for synchronous algorithms
like coroutines.

My own sound synthesis and music composition language uses coroutines
quite a bit. It has a Smalltalk like object model with scheme like 
additions. <http://www.audiosynth.com>

 --- james mccartney



Follow-Ups: References: