Re: Variables and closures (Was: Objects and Relations)

From: Chris Smith <cdsmith_at_twu.net>
Date: Fri, 9 Feb 2007 21:25:02 -0700
Message-ID: <MPG.2036f70ecccee5e39897ea_at_news.altopia.net>


Bob Badour <bbadour_at_pei.sympatico.ca> wrote:
> I don't know as much about the Java world, but the C++ world knows a
> dynamic variable is still a variable.

It really doesn't matter. If you want to push the point, though, you'll lose. From the C++ spec:

    "A name is a use of an identifier (2.10) that denotes an entity or

     label (6.6.4, 6.1). A variable is introduced by the declaration of
     an object. The variable?s name denotes the object."

In Java, variable has a different. From the Java language spec:

    "A variable is a storage location and has an associated type ..."

    "When an expression ... is evaluated ..., the result denotes one      of three thing: ... a variable ... a value ... nothing."

So in Java, for example, a[5] (where a is an array) is a variable. In C++, it is not; but the definitions share a lot. In neither Java nor C++ is an object considered a variable. In C++, but not Java, a variable name denotes an object; but that's actually a semantic difference between the languages, not a definitional one. Of course, variables in ML have a completely different meaning. Variables in Prolog, furthermore, have yet another completely different meaning.

Whether there is another definition of variable that includes objects is, to me, actually rather immaterial. Ditto for the discussion of whether anyone erred in using "variable" when they should have said "object". The only rational approach to the world these days is to accept that the word "variable" has multiple meanings. Figure out what is meant, and move on.

-- 
Chris Smith
Received on Sat Feb 10 2007 - 05:25:02 CET

Original text of this message