Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!mit-eddie!genrad!decvax!cca!lmi-angel!rpk From: rpk@lmi-angel.UUCP Newsgroups: comp.lang.lisp Subject: Special variables in Common Lisp Message-ID: <145@lmi-angel.UUCP> Date: Tue, 17-Feb-87 14:35:32 EST Article-I.D.: lmi-ange.145 Posted: Tue Feb 17 14:35:32 1987 Date-Received: Fri, 20-Feb-87 02:00:30 EST Organization: LISP Machine, Inc; Cambridge Engineering Headquarters Lines: 43 Keywords: special, lexical, scope Oops, I forgot about the screw case of special variables. I said that it was lexically apparent if a variable is special, but of course a globally special variable (whose proclamation of being special need not be lexically apparent) can be the parameter in a lambda list or bound in LET and friends. However, there are some heuristics. * The least convention-specific clue is binding a variable, but then not using it anywhere inside the lexical scope of the binding. In other words, why would anybody do (let ((lose-p nil)) (save-the-world)) unless LOSE-P was a special variable which evidently affected the behavior of the SAVE-THE-WORLD function ? If the variable LOSE-P were not special, the compiler would probably warn about the useless binding. * There is, of course, the *foo* convention. So somebody who proclaims LOSE-P special and the writes stuff like (defun mumble (n lose-p) (frob n) ; and let's say that LOSE-P affects FROB, too (glork (+ n 1) lose-p)) will foil a reasonable code reader, if the reader can't figure out whether LOSE-P is special with an implementation tool. Other musings: There is no VARIABLE-GLOBALLY-SPECIAL-P function in Common Lisp, but there ought to be, at least in a language tools package (or maybe that mysterious SYS package fleetingly mentioned in the CLtL). Compiled functions which make use of local special declarations should record a list of what variables were declared special locally, so that the debugger's version of the evaluator can catch references to such variables, and make clear to the user what kind of variable he is dealing with. -- Robert P. Krajewski Internet/MIT: RPK@MC.LCS.MIT.EDU UUCP: ...{cca,harvard,mit-eddie}!lmi-angel!rpk