Subject: Re: Why seperate function namespaces?
From: rpw3@rpw3.org (Rob Warnock)
Date: Sat, 10 May 2003 03:27:44 -0500
Newsgroups: comp.lang.lisp
Message-ID: <Zs2dnbceieydJSGjXTWc-g@speakeasy.net>
Erann Gat <gat@jpl.nasa.gov> wrote:
+---------------
| Joe Marshall <jrm@ccs.neu.edu> wrote:
| > (define (unwind-protect-function body-form cleanup-form)
| >   (let ((cleaned-up #f))
| >     (dynamic-wind
| >      (lambda () 
| >        (if cleaned-up
| >            (unwind-protect-error)))
| >      body-form
| >      (lambda ()
| >        (cleanup-form)
| >        (set! cleaned-up #t)))))
|
| You probably want:
| (define (unwind-protect-function body-form cleanup-form)
|    ...
|      body-form
|      (lambda ()
|        (set! cleaned-up #t)
|        (cleanup-form)))))
| 
| Otherwise if cleanup-form does a non-local exit then you could get
| multiple entires without an error.
+---------------

But cleanup-form is not *allowed* to do a non-local exit!! R5RS says:

	The effect of using a captured continuation to enter or exit
	the dynamic extent of a call to BEFORE or AFTER is undefined.

[I ran into this when I was trying to write a "safe-eval" in Scheme,
what would have been in CL simply IGNORE-ERRORS wrapped around EVAL.
Can't be done in Scheme, at least not portably in conformance to R5RS...]


-Rob

-----
Rob Warnock, PP-ASEL-IA		<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607