[comp.lang.scheme] Re : unwind-protect

maeda@MCC.COM (Christopher Maeda) (10/03/88)

    Date: 3 Oct 88 07:08:04 GMT
    From: pierce@locus.ucla.edu


    ** Subject: unwind-protect
    ** Message-ID: <10180@eddie.MIT.EDU>
    ** Date: 3 Oct 88 03:41:57 GMT
    ** Sender: uucp@eddie.MIT.EDU
    ** Reply-To: jbs@fenchurch.MIT.EDU (Jeff Siegal)
    ** Organization: MIT EE/CS Computer Facilities, Cambridge, MA
    ** Lines: 5
    ** 
    ** How can one do something like UNWIND-PROTECT in Scheme?  Is the
    ** concept completely ill-defined in the presence of first-class
    ** continuations, or is there an idiom which "sometimes works?"
    ** 
    ** Jeff Siegal

    Kent Dybvig's Chez Scheme has what seems to be a much more powerful construct
    called "dynamic-wind".  A brief sketch of its uses is given in Dybvig's
    "The Scheme Programming Language".

    -- Brad Pierce

Hmm.  How would unwind-protect be expressed with just call/cc?

will@uoregon.uoregon.edu (William Clinger) (10/04/88)

>Hmm.  How would unwind-protect be expressed with just call/cc?

UNWIND-PROTECT is trivial to implement in terms of DYNAMIC-WIND, which can
be implemented in terms of CALL-WITH-CURRENT-CONTINUATION provided the
Scheme system permits CALL-WITH-CURRENT-CONTINUATION to be redefined,
uses close-coded calls to CALL-WITH-CURRENT-CONTINUATION for all captures
of a continuation, and contains no pre-captured continuations.

An implementation appears in Haynes and Friedman, Embedding Continuations
in Procedural Objects, TOPLAS 9, 4 (October 1987), pages 582-598.

Peace,
William Clinger