Talk:Variable (computer science)

Unnamed section
See the discussion page Talk:Variable for the common discussion history of Variable (mathematics) and Variable (programming). prohlep (talk) 15:49, 3 October 2009 (UTC)

Dubious
The current definition is not correct. It seems to define what an identifier (computer science) is. This difference becomes important when you start to consider scoping, aliasing and life time of variables (and identifiers). For example, the "symbolic name" may go out of scope, but the variable might continue to exists. There might be multiple identifiers bound to the same variable, etc. —Ruud 13:08, 22 June 2011 (UTC)
 * You seem to suggest it's synonymous with a storage location, which has problems of its own. Where's a good fundamental CS reference when you need one... --Cyber cobra (talk) 05:49, 23 June 2011 (UTC)
 * I did not want to state that explicitly as I'm not sure that is correct either (variables have life time, while storage locations are always there, the semantics of a variable are more complex than that of a storage location). I've added a good number of texts at Programming language and Semantics of programming languages a while ago. One of those will probably have something useful to say on this. Finkel states that: "Imperative languages (such as Pascal and Ada) have variables, which are named memory locations." —Ruud 13:52, 23 June 2011 (UTC)

Robert Harper recently posted some relevant comments on this issue. —Ruud 20:20, 11 February 2012 (UTC)
 * Also the article should probably differentiable between what Harper calls "assignables" (i.e. imperative variables) and what I would call "substitutables" (i.e. purely functional variables). —Ruud 14:04, 7 March 2012 (UTC)
 * I'd recomend not no be too wrapped-up on getting an exact definition in the first sentences. The main ideas to transmit are 1) that a computer variable is built from both a name and a storage space, as opposed to mathematical variables where both the name and the value are always interchangeable; and 2) that the name is the usual way to access the value. Although there are alternate mechanisms and special conditions to use the variable, those should be clarified in a later paragraph or even an introductory "definition" section. The lead should be written for a general audience that may not even be programmers; even if we get some reference definition from Computer Science, that shouldn't be used for the first sentence since it has a different target audience. If we state the above two ideas in a clear way, we will have included 90% of what anybody should know about computer variables. Diego (talk) 14:30, 7 March 2012 (UTC)
 * Perhaps, yes. But we shouldn't get the definition so wrong that we in fact give the definition of another concept (a previous version of the article essentially gave the definition of an identifier). I'm still trying to get the concept of a variable clear to myself, though. A big problem with variables is that how they work 90% of the time (one memory location with one name) is not at all how they work 100% of the time. A garbage collector might move the variable in memory or a variable might have multiple or no names.* So to me it seems variable is a more elementary concept with associated properties such as a memory location, type and set of names that reference it. I still have to do a more thourough literative review, what's on my shelf mostly concerns itself with the kind of variables you find in the lambda calculus.
 * * Another problem with this operational view is that the latter could also be phrased as "multiple variables might share the same memory location." Harper's algebraic view – dissecting an imperative variable into a functional variable containing a reference to an assignable – is much more elegant in this respect, but is a novel prescriptive definition instead of the descriptivist definition an encyclopedia should give.
 * —Ruud 15:10, 7 March 2012 (UTC)

Naming Conventions
It would be useful to include example naming conventions, eg use of case, whether recommended or imposed for use in specific languages or conventions adopted by organisations. FreeFlow99 (talk) 20:45, 9 August 2013 (UTC)

Scalars
Why do we redirect here from "Scalar (computer science)" and not mention scalars anywhere on the page or the discussion? 118.208.247.51 (talk) 09:44, 15 September 2013 (UTC)
 * I think the term "scalar" as applied to variables and types, is quite language-specific (mainly used for Perl and PHP); it roughly corresponds to "primitive" or "non-composite". It probably deserves explanation, but where? There are several candidate pages:
 * this one
 * Type system
 * Data type
 * Composite type
 * Rp (talk) 11:36, 16 September 2013 (UTC)

The end of this paragraph makes no sense
In the section "Actions on a variable," the last line ("...which value can be changed at run time or execution time is called variable") in the second paragraph [below] makes no sense. The logic of the rest of the paragraph seems to be complete without it. Is it, perchance, just something that has inadvertently remained following a revision? Or does the first part of it possibly belong after the phrase, "...may be associated only with the current value,..."?

"Depending on the type system of a programming language, variables may only be able to store a specified datatype (e.g. integer or string). Alternatively, a datatype may be associated only with the current value, allowing a single variable to store anything supported by the programming language. which value can be changed at run time or execution time is called variable" Wikifan2744 (talk) 06:33, 9 March 2014 (UTC)

Contradiction with another page
This page seems to contradict how “parameter” is defined in https://en.wikipedia.org/wiki/Parameter#Computing and https://en.wikipedia.org/wiki/Parameter#Computer_programming.

Variable doesn't have to be in memory
I have issue with "In computer programming, a variable or scalar is a storage location (identified by a memory address)". So fully optimized variable that is only stored in a registry is not a variable?