- Single assignment
Single assignment is used to describe a programming language or representation in which one cannot bind a value to a name if a value has already been bound to that name. In other words, a variable is "initialized" with (i.e. "bound" to) a value at the time that it is created, and it cannot be assigned to. It prevents some types of side effects, which is claimed to reduce
software bug s and simplifydebugging .Note: in some cases
partial value s could be used in more than one assignment as far as the partial values used in these assignments are compatible. Sometimes such variables are calleddeclarative variable s ordataflow variable s. For further reading see CTM.Implementations
Single assignment is used in several
compiler s and languages.Compilers
Static single assignment form , SSA form, SSA, compiler representationLanguages
*Functional (these use single assignment to reduce side effects)
**Erlang
**Haskell
**SASL
**SISAL
**Oz
**OCaml - in OCaml, "variables" can only be single-assigned; however, members of arrays and mutable members of records and objects can be assigned to regularly
*Object-oriented
**Lava
**OzSome languages also support single assignment as an option.
*C# uses the "
readonly
" keyword next to a variable declaration.
*Java uses the "final
" keyword next to a variable declaration.
*C++ uses the "const
" keyword next to a variable declaration (only when the const modifies the type; not for "pointer-to-const" things).
*Scala when declaring variables with "val
" instead of "var
".The use of these features, is however generally restricted to OO design decisions, such as making an object immutable.
ee also
*
Immutable object
*Const-correctness
Wikimedia Foundation. 2010.