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

Firstclass continuations



    Now I have some questions and a "wish list".  Questions: how do upward
    continuations (the ones created with CALL-WITH-CURRENT-CONTINUATION),
    which can be multiply invoked, interact with dynamic binding and
    UNWIND-PROTECT?  E.g., if a continuation is created in the (dynamic)
    scope of an unwind-protect, do the cleanup forms get executed only the
    first time the continuation is invoked, or every time, or what?

MIT Scheme has a procedure (rather than a special form) called
DYNAMIC-WIND, which is a generalization of UNWIND-PROTECT.

(dynamic-wind
 (lambda () <entry>)
 (lambda () <body>)
 (lambda () <exit>))

is similar to

(begin
  <entry>
  (let ((val <body>))
    <exit>
    val))

except that <exit> is executed whenever <body> is "escaped", and
<entry> is executed whenever <body> is (re)entered.