iant <email@example.com> wrote:
| Kent M Pitman <pit...@nhplace.com> wrote:
| > It is recommended that, absent some strong compelling reason (not in
| > evidence), you always use global variables that have *...* around
| > their names. The *'s are just alphabetic characters, but this
| > different naming is commonly used and helpful for reasons I'll
| > explain.
| Is this because there are no variables with local scope?
[I assume by "local scope" here you really mean "lexical scope"...]
No, there are certainly variables with lexical scope, but in
standard CL there are no global variables with lexical scope.
Said another way, the global environment contains only variables
with dynamic scope (with the exception noted in ), and if you
rebind one with LET or LAMBDA you will give it a new *dynamic*
binding, which is not "local", and thus have effects you might not
expect if coming from languages with global lexical variables, e.g.:
> (defparameter foo 13)
> (defun foo () foo)
> (defun bar () 27)
> (let ((foo 54)
(list foo (foo) bar (bar)))
(54 54 91 27)
For this reason the Lisp community style [a *very* strong convention!]
is to use the *FOO* form for global (dynamic) variables so you won't
accidentally rebind one dynamically when you were intending to just
create a fresh lexical binding.
 You can fake up global lexical variables by using symbol
macros -- Google for DEFLEX, DEFLEXICAL, or DEFGLOBAL.
Such "variables" are reliably shadowed by lexical rebindings,
so there's no reason to use the *...* convention in their case.
Rob Warnock <firstname.lastname@example.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607