[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
MAKUNBOUND vs. special binding
The description of the function MAKUNBOUND is as follows:
MAKUNBOUND causes the dynamic (special) variable named by
"symbol" to become unbound (have no value).
I'm not sure I understand what this means in certain circumstances.
Consider the following program:
(defvar *foo* 17)
(defun foo ()
(test-it) ; First
(let ((*foo* 18))
(bar)
(test-it)) ; Fourth
(test-it)) ; Fifth
(defun bar ()
(test-it) ; Second
(let ((*foo* 19))
(baz)
(test-it))) ; Third
(defun baz ()
(makunbound '*foo*))
(defun test-it ()
(format t "~S " (not (null (boundp '*foo*)))))
(foo)
What should this print? At the time the makunbound is performed, there
are three bindings of *foo*.
1) Are all of them destroyed? That is, should this print out T T NIL
NIL NIL?
2) Or is only the innermost binding undone (T T NIL T T)?
3) Alternatively, perhaps it should simply make the innermost binding
invisible, so that this would print T T T T T...
Should the function have different effects in deep-bound implementations
from shallow-bound ones?
I would greatly prefer that it were "an error" to MAKUNBOUND any symbol
that had a binding other than the one at top level. Otherwise, you can
get into this nonsensical situation where a variable is unbound in one
function but somehow becomes bound again when you return from that
function, as is the case in the second of my proposed answers.
It should be noted that Lucid, VaxLisp, and CLisp all print T T NIL T T.
Ugh.
Pavel