2.3.1 Assignment, initialization, and equality

People new to Dylan may find = and := confusing, because the names are similar, and the meanings are related but distinct.

The meaning of = depends on whether it appears an expression, or in a definition of a variable or constant. In an expression, = is a function that tests for equality; for example,

? 3 = 3;
#t

In a definition of a variable or constant, = precedes the initial value of the variable or constant; for example,

? define variable *her-number* = 3;

After you initialize a variable with =, the = function returns true:

? *her-number* = 3;
#t

The assignment operator, :=, performs assignment, which is setting the value of an existing variable; for example,

? *her-number* := 4;
4

After you have assigned a value to a variable, the = function returns true:

? *her-number* = 4;
#t

Dylan offers an identity predicate, which we discuss in Section 3.3.1, page 35.