2.4 Variables

A variable can be viewed as a binding between a name and a location containing a value, which in many programming languages can be changed while a program is executed.

A constant can be viewed as a variable where the value cannot be changed.

Are there variables/constants for every data type supported by the language?

x := x + 1;

This typical assignment statement shows that the meaning of a variable name usually depends on context: it delivers a typed value (r-value) or it is the target of assignment (l-value).

How does the language decide on the type of a variable?

no typing

each operation interprets a value
usually in machine languages

strong typing

variables have predeclared attributes
usually in compiled languages

dynamic typing

(re)assigned value determines current type
often in interactive languages