This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Coroutines with call/cc


"Peder Chr. Norgaard" <pcn@tbit.dk> writes:

> > Are you sure that call/cc is less ``heavyweight'' than threads in
> > Guile?  I think Guile needs to copy the entire stack each time a
> > continuation is captured.
> 
> Yes, correct, but if the stack is not deep (mine isn't) I judge this is no
> big deal.  The cost of the guile thread is in terms of memory:  each
> thread needs a large piece of RAM that to allow for any possible stack,
> both C and Scheme.  That is fine for heavier things like multiplexing
> network traffic, for instance, but too expensive for an arbitrary data
> access tool.
> 
> Whereas the "stack" copy of a call/cc (I think it is not truly a "copy" of
> the stack, just a datastructure that holds references to the bindings) is
> stored in the heap.

Guile's call/cc is the ordinary heavyweight thing: Since Scheme level
calls are implemented as ordinary C calls, Guile's call/cc indeed
needs to copy the entire C stack.  It also contains various
information about the dynamic state.

/mdj