Assignments

Assignments: Statements used by imperative languages to update memory (destructively).

On Type — In most languages, the types must be the same. In some dynamic languages, this is not enforced.

Example: Types of Assignments

Simple

x := E

Conditional

x := if b then E_1 else E_2

Compound (combine operation with assignment)

x += 7

Unary

x++

Multiple

x,y,z := 1

Parallel

x,y,z := 1,2,3

Assignments as Expressions

Some languages make assignments expressions.

Definition — Pure Expression: An expression which lacks side effects

Example: Assignments as Expressions
x := (y := (z := 42))
y := 1 \text{$+$} (y+=1)