[comp.lang.lisp] Common LISP Binding Dilemma

pepke@loligo.cc.fsu.edu (Eric Pepke) (12/20/89)

The original CLtL says that makunbound "causes the dynamic (special) variable
named by symbol to become unbound (have no value).  How does it behave when
a new binding has been established over an old one?

One interpretation is to take the makunbound definition literally and assume
that it should make the variable unbound regardless of how many nested 
bindings have been established.

Another interpretation is to change the definition somewhat and say that
makunbound edits the current established binding in such a way that, as long
as that binding remains in effect, attempts to use the variable will have
results that are indistinguishable from attempts to use an unbound variable,
but when that binding unwinds, the previous binding will still be available.

As an example, consider this:

(setq foo 'toad)
(let ((foo 'bar)) (declare (special foo)) (makunbound 'foo))
foo

What should the interpreter do in response to the last foo?  Should it 
evaluate it to TOAD or should it barf?

Allegro CL returns TOAD, which indicates that it takes the second, looser
interpretation, but that does not automatically make it correct.

I know this may seem like a trivial detail, but it has a fairly large impact
on the binding strategy used in the implementation.

Any ideas?  Does CLtL II clarify?

Eric Pepke                                     INTERNET: pepke@gw.scri.fsu.edu
Supercomputer Computations Research Institute  MFENET:   pepke@fsu
Florida State University                       SPAN:     scri::pepke
Tallahassee, FL 32306-4052                     BITNET:   pepke@fsu

Disclaimer: My employers seldom even LISTEN to my opinions.
Meta-disclaimer: Any society that needs disclaimers has too many lawyers.

barmar@Think.COM (12/21/89)

In article <414@fsu.scri.fsu.edu> pepke@loligo.cc.fsu.edu (Eric Pepke) writes:
>The original CLtL says that makunbound "causes the dynamic (special) variable
>named by symbol to become unbound (have no value).  How does it behave when
>a new binding has been established over an old one?

See the first sentence of section 7.1.2.  It says that the functions
described in that section (including MAKUNBOUND) alter "the value
associated with the current binding of the variable."
Barry Margolin, Thinking Machines Corp.

barmar@think.com
{uunet,harvard}!think!barmar