From: Seth Tisue
Subject: Re: How to do this in Lisp?
Date: 
Message-ID: <53m8i5$4l3@Godzilla.cs.nwu.edu>
In article <·················@netcom.com>,
Bill Newman <·······@netcom.com> wrote:
>I received e-mail suggesting -- if I understood correctly -- that I
>can't overload assignment in Lisp, but the same effect could be
>achieved by defining my own (REVERSIBLE-ASSIGN VAR VALUE) function or
>macro in Lisp.  I can't figure out how to do even this.  Also, even if I
>could, I'd still prefer to have the reversible-ness associated with
>each variable, rather than with each assignment to each variable.  (I
>used to do it the other way around in C before I switched to C++, and
>it was a major maintenance hassle tracking down things which
>accidentally changed something irreversibly.)

I realized after sending my last message that actually there is
already a way of doing this built into Lisp -- it's not exactly the
same thing, but it might be just what you need.  Suppose you're
storing your board in the global variable *board*.  If you declare
*board* to be "special" (i.e., to have dynamic scope), then saying:

  (let ((*board* <new-value>))
    ...)

does exactly what you want.  *board* takes on a new value for the
duration of the dynamic extent of the LET, and automatically returns
to its old value when the LET exits.  Dynamic scope means that *board*
has the new value even in the bodies of functions invokved in the body
of the LET.

-- 
== Seth Tisue <·······@nwu.edu>         http://www.cs.nwu.edu/~tisue/