[Next] [Previous] [Up] [Top] [Contents] [Index]

4 Program Control

Assignment

The special operator := is used to set variables to new values and as an alternate syntax for calling setter functions and macros.

The assignment operator is described in detail on page 395.

The following examples show the use of := to change the value of a module binding.

define variable *foo* = 10;
*foo*
   10
*foo* := *foo* + 100;
   110
*foo*
   110
The following examples show the use of := as shorthand for calling a setter function. In general, using this syntax to call a function fun is equivalent to calling the function fun-setter.

define variable *foo* = vector (10, 6, 8, 5);
element(*foo*, 2)
   8
element(*foo*, 2) := "bar"
   "bar"
*foo*
   #[10, 6, "bar", 5]
The following examples show the use of := as shorthand for calling a setter function using slot access notation.

window.position := point(100, 100)
vector.size := 50
The following examples show the use of := as shorthand for calling element-setter or aref-setter.

my-vector[2] := #"two"
my-array[1,1] := #"top-left"

Dylan Reference Manual - 17 OCT 1995
[Next] [Previous] [Up] [Top] [Contents] [Index]

Generated with Harlequin WebMaker