# Assignment

An assignment is an association of an identifier to a *value*. The statement,

```
> a := 6;

```

establishes an association between the identifier $a$ and the value 6 (6 is said to be *the value of* $a$, or to be *assigned to* $a$). A collection of such assignments is called a *context*. When a value $V$ is assigned to an identifier $I$ one of two things happens:

**(1)**
if $I$ has not been previously assigned to, it is added to the current context and associated with $V$. $I$ is said to be *declared* when it is assigned to for the first time.

**(2)**
if $I$ has been previously assigned to, the value associated with $I$ is changed to $V$. $I$ is said to be *re-assigned*.

The ability to assign and re-assign to identifiers is why Magma is called an *imperative* language. One very important point about assignment is illustrated by the following example. Say we type,

```
> a := 6;
> b := a+7;

```

After executing these two lines the context is `[ (a,6), (b,13) ]`. Now say we type,

```
> a := 0;

```

The context is now `[ (a,0), (b,13) ]`. Note that changing the value of $a$ does *not* change the value of $b$ because $b$’s value is statically determined at the point where it is assigned. Changing $a$ does *not* produce the context `[ (a,0), (b,7) ]`.
