Subject: Re: faking dynamic-wind ?
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 23 Dec 2000 05:14:14 GMT
Newsgroups: comp.lang.scheme
Message-ID: <921cb6$etvho$1@fido.engr.sgi.com>
Joe Marshall  <jrm@content-integrity.com> wrote:
+---------------
| dynamic-wind started off as a `first-class continuation aware' version
| of lisp's unwind-protect.  Unwind-protect is used for cleaning things
| up, never for multithreading.  If dynamic-wind is unsuitable for
| cleanup, I don't think that attempting to shoehorn it into a
| multithreading role is appropriate.
+---------------

And as I pointed out in <URL:news:91uk40$f165j$1@fido.engr.sgi.com>,
dynamic-wind (at least, the R5RS version) is not suitable for cleanup
at all, since it doesn't allow you to stop the unwinding! [Result of
call/cc in "after" thunk is undefined.]

+---------------
| > Anyway, call/wc is a more complicated construct than call/cc.
| > That R5RS provides the complicated one and not the simple one
| > as a primitive is what I consider the deficiency.
| 
| Maybe we should figure out two things:
|   1.  How do you do `unwind-protect' in Scheme if not via
|       dynamic-wind?
+---------------

You don't, at least not an conform to the standard. [My article ref'd
above showed a non-standard way that works in SCM & MzScheme, but...]

But even if you did, there's no guarantee in the standard that *system*
errors will unwind, so it's useless in any case. Whereas in Common Lisp,
there *is* a guarantee that an unwind-protect will catch exceptions:

	<URL:http://www.xanalys.com/software_tools/reference/HyperSpec/
	     Body/speope_unwind-protect.html>
	Unwind-protect protects against all attempts to exit from
	"protected-form"...


-Rob

-----
Rob Warnock, 31-2-510		rpw3@sgi.com
Network Engineering		http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.		Phone: 650-933-1673
1600 Amphitheatre Pkwy.		PP-ASEL-IA
Mountain View, CA  94043