Post by firstname.lastname@example.org
The standard seems quite precise in its use of the noun 'variable'.
There is no entry for 'variable' either in the terms list in section 3
(not even as a deprecated term) or the index. Almost always in
normative text, 'variable' is used as an adjective, as in
'variable length array' or 'variable arguments'. 7.6 (fenv.h)
describes certain 'system variables'.
There are however quite a lot of uses of 'variable' (noun) in the
non-normative footnotes, where it seems to mean an object.
Then finally, 7.17 (atomics) uses 'variable' freely in normative
text, and 7.21 (threads) uses 'condition variable'.
So is 'variable' a synonym for 'object with an identifier' or just
'object'? Is an element of an aggregate, a variable? A bit field?
Or does it specifically mean an atomic object - is its use in 7.17
significant, rather than sloppy? Does it need defining in section 3?
I guess the noun "variable" before C11 is avoided intionally thoughout the normative text. The meaning of condition variables introduced by C11 are significantly different, so it seems things are not changed in C11.
As I learned, in general (among different languages), the meaning of this concept is disputed, e.g. https://existentialtype.wordpress.com/2012/02/01/words-matter/ .
Historically, "variable" is a notion of mathematics. The word "variable" basically means the property of relations between names and some other entities being denoted, i.e. the "binding", rather than the "stored value" or something else, can vary in different places on demand.
Therefore it has nothing to do with mutability, until someone invents a system can hold mutable states associated with names and calls them "variables". Note there is still nothing wrong.
However, when more and more people learned "variables", few of them have thought why they are called so. Most of them are neither language lawyers and nor historians, with little interest on reasoning of wording. After they meet a few languages (mostly imperative), they easily infers "variable" is "variable state". This is not true in some other languages. For instance, variable in Haskell is immutable.
Because there are too many people think as that, we cannot just say it is wrong, even it is certainly not reasonable to randomly narrow the extension of a formerly well-known concept.
In C, there is no normative term "variable". Despite naming, the term "object" implements this notion with one more exposed thing: "storage", which effectively models the ability of expressing mutable states. When declared, the identifier is the name of the object. There are no need to define what is a "variable". No need of ISO/IEC 2382 here.
Post by email@example.com
A variable is introduced by the declaration of a reference other than a non-static data member or of an object. The variable’s name, if any, denotes the reference or object.
Namely there are "variables" not implemented by "objects" in C++. Thus we need a normative definition. This is still nothing to do with ISO/IEC 2382 even if it is a normative reference of ISO/IEC 14882.
Note C++11 has also condition variables in library clauses. It is quite clear that thay are not variables mentioned above.
To be honest, I don't think this concept is totally clear in C++, and would be worse in C. Is "variable" a name, an identifier, an expression, or otherwise an entity? Each option is more or less plausible according to the traditional meaning of mathematics.
BTW, the term "entity" is defined in Clause 3 of ISO C++ due to the need of One Definition Rule. In ISO C it is not defined normatively, but used several times. This could be a problem.