2009/10/21 Stas Boukarev stassats@gmail.com:
"Scott L. Burson" Scott@sympoiesis.com writes:
Historically and throughout most of the CL and pre-CL world -- at least, the MIT and MIT-influenced pole thereof -- the practice has been, on a top-level interpreted SETQ of a previously unseen variable, to set the symbol-value of the variable and do nothing else -- specifically, not to declare the variable special. MacLisp and ZetaLisp (Lisp Machine Lisp) did this, and many important implementations still do: Allegro, LispWorks, the MCL family(*), CLISP, the KCL family(*). (Don't know about Lucid or Corman; nor InterLisp, Spice Lisp, or the other pre-CL implementations.)
(*) I am reasonably certain of these. OpenMCL 1.1 and a recent ECL both do, by experiment.
AFAIK it was CMUCL that broke from this practice; and AFAIK it is only the CMUCL family that declares the variable globally special, or indeed does anything other than just set the symbol-value.
CMUCL indeed does declare it special, but not SBCL. (progn (setq fooo 10) (sb-cltl2:variable-information 'fooo)) => NIL, NIL, NIL
There you go for a portable, standard-conformant solution to your problem.
(defpackage lexicals) (defmacro deflexical (name &optional value doc) (let ((special (intern (format nil "~W" name) :lexicals))) `(progn (defvar ,special ,@(when value `(,value)) ,@(when doc `(,doc))) (define-symbol-macro ,name ,special))))
Should probably be added to alexandria or some such.
(Thanks to Nikodemus or whoever suggested that idea, long ago.)
[ François-René ÐVB Rideau | Reflection&Cybernethics | http://fare.tunes.org ] Backwards compatible -- If it's not backwards it's not compatible -- Greg Newton gregnewton@netscape.net
alexandria-devel@common-lisp.net