This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
On Wed, 2007-12-26 at 17:55 -0500, Jake Miles wrote:
> I've never understood why
> dynamic-wind includes a 'before' function - maybe someone can
> enlighten me.
(define-syntax special-let
(lambda (stx)
(syntax-case stx ()
((special-let ((?var ?val) ...) ?body ...)
(let-syntax ((?old ...) (generate-temporaries (syntax (?var ...))))
(syntax (let ((?old ?var) ...)
(set! ?var ?val) ...
(dynamic-wind values ;ignore
(lambda () ?body ...)
(lambda () (set! ?var ?old) ...)))))))))
(let ((reenter-special-let #f) (myvar 42))
(display myvar)
(special-let ((myvar 21))
(call/cc (cut set! reenter-special-let <>)))
(display myvar)
(set! myvar "never displayed")
(reenter-special-let))
Anyone would expect "never displayed" to be displayed forever after 42
is displayed twice. Instead 42 is displayed forever.
`special-let' can only be implemented correctly with the "before" thunk.
This is a specific example of the general problem of controlling dynamic
wind in the face of multiply-restartable continuations.
Returning to the thread's topic, for a full `time-process'
implementation that counts all execution in the dynamic context of
`process', the thunks must be altered to handle restarting. This
doesn't matter for Kawa, but should be noted if you might want to port
this code later.
--
The foremost obstacle standing in the way of the public's acceptance of
evolutionary theory is not a dearth of common sense. Instead, it is the
public's erroneous belief that common sense is a dependable guide to
evaluating the natural world. --Scott O. Lilienfeld, SkI 5/2006
Attachment:
signature.asc
Description: This is a digitally signed message part
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |