# Variable

A variable is represented by a symbol. It is used to mark a role in a Formule, a Prédicat or a Algorithme. One distinguishes the qualitative variables , quantitative and ordinal.

Mathematically, one distinguishes variable and unknown which is both represented by symbols. If the symbol is the subject of the sufficient system of equations, one can calculate his value, i.e. the quantity which it replaces. In this context, the use of the variable word is abusive because the variable would have an unknown, but fixed value a priori .

In Statistical, a variable can also represent a quality. In Probability, the Random variable is a function.

In the fields like the Physical , the Biology, the Mechanical or the Chemistry, the variable represents a measurable Paramètre like the temperature, time, speed or the intensity.

In Data-processing, a variable associates a name (the Symbole) with a value or an object. The concept of variable is then closely related to Computer programming language. It is notable that many of these languages authorize the variables to change value at the court of time!

## In Data processing

In a computer programming language, a variable is a storage space for a result. However the possibilities of a variable are closely related to the computer programming language to which one refers. For example a variable in C++ will have six characteristics:

• its name i.e. under which name the variable is declared;
• its standard , it is the convention of interpretation of the sequence of bits which constitutes the variable. The type of the variable specifies also the length of this sequence (8 bits, 32 bits, 64 bits);
• its value , it is the sequence of bit it even, it cannot vary during time if one uses the key word const;
• its addresses , it is the place in the memory or it is stoquée;
• its visibility , it is a whole of rules which fixes which can use the variable (key words public, private, protected);
• its lifespan , it is the portion of code in which the variable exists, out of C and C++ the variable is contained in a block of code limited by accodances " {} ". One should not confuse the lifespan of a local variable and its visibility.

However one can find languages which simplify these characteristics:

• the notion of the name of the variable is problematic in all the languages which allow the dynamic creation of variable (new in C++);
• does not have it a strong typing, like most of the languages scripts;
• the Prolog does not allow that a variable changes value during time once the first made identification;
• the visibility of the variable is public by defect out of C;
• the concept of pointer in C++ is replaced by the concept of reference in Java, in prolog the address of a variable does not have any direction;

### Name of the variables

In certain languages, the names of variables (Identifying) must necessarily start with a letter (capital or tiny) or with a _ (underlined). The other characters composing the name of the variable must be a letter, a figure or a _ . The differentiation of the capital letters and tiny (sensitivity to breakage) in the name of a variable is left with the discretion of the languages.

Examples of valid names of variables, in C:

• _var
• __var2
• Var
Example of nonvalid name of variable out of C:
• 2var

Thus, the first character cannot be a figure, because that makes it possible to facilitate the compilation or the interpretation of the program by removing an ambiguity: when the compiler reads a figure, it knows that the characters which will follow will constitute a numerical value. In the same way, if it reads a letter or one underlined, it will know that it deals with variable.

All these names of variables are valid in Lisp.

### Typing

When the type of a variable is given with compilation (explicitly by the programmer or automatically by Inférence of the types), one speaks about static Typage. The values of this variable will have to be obligatorily of this type (in the broad sense, i.e. of the same type or of a derived type)

Static typing helps with the generation of more effective object code (in consumption memory and speed of execution). It prohibits however reflexivity with the execution.

Otherwise, whenever in fact the variables have a type, but the values, one speaks about dynamic Typage, or latent typing.

One speaks about strong Typage when the language imposes that the variables are declared in a type and are used in this type (ex: Ada or C++). One speaks about weak Typage when the language admits that a variable can change type during its existence (to conform in particular to the semantics of an expression).

### Life cycle of the variables

One generally distinguishes four operations on the variables, each one being able to take different syntactic forms.

• the declaration makes it possible to declare a name of variable, if required to associate a type to him, as well as an initial value,

• the assignment consists in allotting a value to a variable,
• the reading consists in using the value related to the variable,
• the suppression realized either automatically or by an instruction of the language.

The languages, like the C, Caml or Pascal, force to state a variable to even give him a type before its use. The Déclaration imposed variables allows the Compilateur or the Interpréteur to identify the typographical errors like not declared variables or homonymous variables. Other languages carry out the declaration at the time of the first assignment (it is the case of the majority of the languages of script) or during their first appearance in the code (as in Prolog).

With regard to the initialization of the variables, i.e. the association of a first value, certain languages force to initialize a variable before its first reading whereas others provide a default value (specified or unspecified). Languages like OZ or Prolog do not carry out initialization strictly speaking. At the time of the declaration of the variables no value is associated, one says that the variable is not dependant . The value of the variable is progressively given of the execution of the program, one speaks then about unification .

In the languages of functional Programming or logical Programming, the variables can be associated only with only one value during their existence.

### Reflexivity

In the majority of the languages, the variables exist only as tools for the programmer. Thus, to re-elect all the occurrences of a variable will not modify the operation of the program.

On the contrary, to offer an additional expressivity, certain languages make it possible to regard a name of variable as a value like another (for example, they are the Symbole S of Common Lisp and Smalltalk). It is a very useful technique to implement effectively calculation algorithms symbolic system.

 Random links: Mike Quigley | Cut clubs champions Europeans 1959-1960 | Joannice of Moscow | Lépontique | Frank Auerbach | Élément_synthétique