Assignment (computer science)
In computer programming, an assignment statement (or operator, or expression) sets and/or re-sets the value stored in the storage location(s) denoted by a variable name.
In other words, it assigns a value into the variable.
In most imperative programming languages, the assignment statement (or expression) is a fundamental construct.
Description
Today, the most commonly used notation for this basic operation has come to be x = expr (originally Superplan 1949–51, popularized by Fortran 1957 and C) followed by x := expr (originally ALGOL 1958, popularised by Pascal), although there are many other notations in use.
In some languages the symbol used is regarded as an operator (meaning that the assignment has a value) while others define the assignment as a statement (meaning that it cannot be used in an expression).
Assignments typically allow a variable to hold different values at different times during its life-span and scope. However, some languages (primarily strictly functional) do not allow that kind of "destructive" reassignment, as it might imply changes of non-local state. The purpose is to enforce referential transparency, i.e. functions that do not depend on the state of some variable(s), but produce the same results for a given set of parametric inputs at any point in time.
Modern programs in other languages also often use similar strategies, although less strict, and only in certain parts, in order to reduce complexity, normally in conjunction with complementing methodologies such as data structuring, structured programming and object orientation.
See also
External links
- Assignment (computer science) @ Wikipedia