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 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:
However one can find languages which simplify these characteristics:
Examples of valid names of variables, in C:
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.
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).
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 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.
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: | Patrice Larcenet | Irles | Arthur (cartoon) | Jose de San Martín (Chubut) | Automobile Grand Prix of Japan 1999 |