Warnings compiling



Stavros Macrakis <macrakis at alum.mit.edu> wrote:

   Most programming languages require explicit declaration of local
   variables (other than function arguments), including all varieties of
   Lisp I'm aware of. ?A few do this implicitly for variables which are
   assigned to, e.g. Python and R. ?Maxima does not.

Two minor points (which are barely relevant to the discussion :-)

Common Lisp assigns no semantics whatever to a free (i.e. undeclared)
reference to a variable, but essentially every implementation treats the
variable implicitly as though it had been declared special in that
context.  Most warn, at least in the compiler.  This is because there is
a long history of Lisp dialects that provided _only_ special variables,
so no declarations were necessary or meaningful.

Your "except function arguments" distinction is not a real distinction.
Constructs such as LET that bind variables are really just semantic
sugar for the same kind of lambda binding that lambda functions do.

  (let ((y (* x x))
        (c (+ x 1)))
    ...)

is semantically equivalent to

  (apply (lambda (y c) ...)
         (* x x)
         (x (+ x 1)))

hence LET binding is sometimes confusingly called "lambda binding".  Of
course, implementations usually try to rewrite internal lambdas as lets
rather than the other way around.