Assignment (computer Science)

Assignment (computer Science)

In computer programming, an assignment statement sets and/or re-sets the value stored in the storage location(s) denoted by a variable name. In most imperative programming languages, the assignment statement (or expression) is one of the fundamental constructs. Technically, what is traditionally known as an assignment is basically just a copying of a value or an object (or of a reference to it).

Today, the most commonly used notation for this basic operation has come to be x=expr (originally Fortran 1957, popularised by 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) does not allow that kind of "destructive" re-assignment, as it might imply changes of non-local state. The purpose is to enforce referential transparency, i.e. functions that do not dependent on the state of some variable(s), but procedure 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.

Read more about Assignment (computer Science):  Semantics, Value of An Assignment, Chained Assignment, Parallel Assignment, Assignment Versus Equality, Notation, Assignment in Object Oriented Languages