Subject: Re: setq Question.
From: Erik Naggum <erik@naggum.no>
Date: 2000/02/29
Newsgroups: comp.lang.lisp
Message-ID: <3160842339136874@naggum.no>

* npak@kazbek.ispras.ru (Nick V. Pakoulin)
| Will the binding created by setq become dynamic or lexical?

  setq doesn't create bindings, it modifies bindings.  the binding modified
  by a top-level setq is the symbol-value slot of the symbol.  if this
  symbol was previously unbound (i.e., it had no value), you might be
  confused about the resulting behavior into believing that something
  happened other than merely setting the symbols-value slot of the symbol,
  but nothing else actually happened.

| I've looked about `setq' in the standard but there is nothing about it.
| I tried CLISP and it looks like it makes variables in this case to be
| dynamic.

  no, you're confusing an unbound variable with the creation of a binding.

  we've recently been through this, as well as several times in the past.
  some will tell you that this is a major big deal with Common Lisp --
  don't listen to them.  just note that the semantics of a top-level setq
  is well-defined, but confusing to people who don't realize that setting a
  free variable, whether the symbol is declared special or not, is
  operationally identical to setting the symbol-value slot of the symbol,
  and setting a lexical variable is not affecting the symbol-value slot of
  any symbol.

  the ultimate advice, however: it is not a good idea to use free variables
  without declaring them special or knowing _exactly_ what's going on.

#:Erik