rpk@lmi-angel.UUCP (02/17/87)
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
jjacobs@well.UUCP (02/22/87)
In <145@lmi-angel.UUCP>, Bob Krajewski writes: >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. Let me change the example a little bit; let's make it (DEFVAR LOSE-P NIL) (DEFUN NOT_SURE_YET (LOSE-P) (SAVE-THE-WORLD)) Possible reasons for this: 1. NOT_SURE_YET isn't completely defined, yet. 2. It is anticipated that NOT_SURE_YET might, in the future, need to change the value of LOSE-P. 3. It is a primary function of a package, such as an editor, with LOSE-P the key global variable. Think of calling a structure editor with the form to be edited. Remember that the domain under discussion is that of debugging *other* people's code, not reading people's code for interest or fun. If they were writing reasonable code, I wouldn't have to be debugging it :-) Jeffrey M. Jacobs CONSART Systems Inc. Technical and Managerial Consultants P.O. Box 3016, Manhattan Beach, CA 90266 (213)376-3802 CIS:75076,2603 BIX:jeffjacobs USENET: jjacobs@well.UUCP