Re: Non-declared Variables

Pascal Bourguignon <>
28 Oct 2006 01:23:53 -0400

          From comp.compilers

Related articles
Non-declared Variables (Avatar) (2006-10-16)
Re: Non-declared Variables (Wolfram Fenske) (2006-10-17)
Re: Non-declared Variables (2006-10-24)
RE: Non-declared Variables (Quinn Tyler Jackson) (2006-10-26)
Re: Non-declared Variables (Peter Flass) (2006-10-26)
Re: Non-declared Variables (Pascal Bourguignon) (2006-10-28)
Re: Non-declared Variables (2006-10-28)
Re: Non-declared Variables (Gene Wirchenko) (2007-01-28)
| List of all articles for this month |

From: Pascal Bourguignon <>
Newsgroups: comp.compilers
Date: 28 Oct 2006 01:23:53 -0400
Organization: Informatimago
References: 06-10-098 06-10-108
Keywords: design
Posted-Date: 28 Oct 2006 01:23:50 EDT

Quinn Tyler Jackson <> writes:

>> I don't think that it is a good idea when language definition allows
>> you to use variables without declaration.
> I think languages should forbid the declaration of variables, for the
> following reasons:
> [...good reasons...]

But there's one thing where you need to declare the variables, it's
when you have lexical scope.

            print x;
      print x;

What does this print? Is there one or two variables? What about: {{
x=1; } print x;} and other such cases? Of course you can have only
dynamic variables and no lexical scope.

But I think the conclusion reached 20 years ago was that having only
dynamic scope without lexical scope was bad, and even that it'd be
better to have only lexical scoping...

That said, in lisp for example, we don't really declare the variables,
we directly bind them:

(let ((x 0))
      (let ((x 1))
            (print x))
      (print x))

and we get printed 0 and 1.

[Additionnal declarations can be inserted, but are optional.

  (let ((x 0))
        (declare (type integer x)
                          (special x))
        (let ((x 1.0))
              (declare (type float x))
              (print x))
        (print x))

__Pascal Bourguignon__

"Klingon function calls do not have "parameters" -- they have
"arguments" and they ALWAYS WIN THEM."

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.