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

dynamic-wind vs. call/cc [Was: DYNAMIC-WIND vs. multi-processing]

   Date: Mon, 10 May 93 10:57:30 -0400
   From: Aubrey Jaffer <jaffer@martigny.ai.mit.edu>

   Before DYNAMIC-WIND was incorporated into R5RS, process switching
   could be trivially implemented using CALL-WITH-CURRENT-CONTINUATION.
   Except for top-level variables, CALL-WITH-CURRENT-CONTINUATION
   captured the whole state of a computation.

   With DYNAMIC-WIND, state is alterred when a continuation is called
   which is outside its dynamic scope (for instance to a separate
   computation).  This means that a separate primitive construct will be
   needed in order to implement process switching in R5RS Scheme.

   Alternately, one might say that users should just avoid the use of
   DYNAMIC-WIND if they want to multi-process.  But does the user really
   have control over all uses of DYNAMIC-WIND?  A library or
   implementation defined function might use it and the user would be
   "continuation unsafe" in R4RS Scheme.  Are there others?

Yes, yes, yes!  I agree wholeheartedly!  I really don't think that
dynamic-wind is a good idea.  IMHO, it even conflicts with the concept
of the ``current continuation''.

The continuation of ``(+ a b)'' in ``(* (+ a b) c)'' is simply to
multiply the result by ``c'' and NOT to do some other cleanup work first!
Either we would have to rename ``call-with-current-continuation'' to
something else or ``dynamic-wind'' should leave it alone and only affect
some higher construct (which can be built on top of call/cc).
The term ``continuation'' has a certain meaning in denotational semantics
and I would prefer call/cc to capture something equivalent to it.