This is the mail archive of the guile@sources.redhat.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: continuation and multi-threading


Keisuke Nishida <kxn30@po.cwru.edu> writes:

> Russell McManus <russell.mcmanus@msdw.com> writes:
> 
> > If you want to support dynamic-wind in combination with continuations,
> > there is some additional book keeping to be done, and winding and
> > unwinding thunks to call.  'Essentials of Programming Languages',
> > Section 9.5 has a discussion of this topic.
> 
> Right.  Hmm, after all, supporting continuations is not very trivial..

But not very hard either...  :)

continuations.c:219:

SCM
scm_call_continuation (SCM cont, SCM val)
{
  if ((SCM_SEQ (cont) != SCM_SEQ (scm_rootcont))
      || (SCM_BASE (cont) != SCM_BASE (scm_rootcont)))  
    /* base compare not needed */
    scm_wta (cont, "continuation from wrong top level", s_cont);
  
  scm_dowinds (SCM_DYNENV (cont),
	       scm_ilength (scm_dynwinds) - scm_ilength (SCM_DYNENV (cont)));
  
  scm_dynthrow (cont, val);
  return SCM_UNSPECIFIED; /* not reached */
}

scm_dowinds moves up or down (by adding frames from SCM_DYNENV (cont))
the current dynwind chain (scm_dynwinds) to sync it with SCM_DYNENV (cont).

The common type of frame has a CAR part which is called when moving
into dynamic context, while the CDR part is called when moving out.

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