<- -- assignment with left side evaluated

assignment to symbols

• Usage:
x <- e
• Inputs:
• x, , (evaluated)
• e,
• Outputs:
• the value of the expression is the value of e
• Consequences:
• assuming the value of x is a symbol, t, say, the value of e is assigned to t so that future references to the value of t yield e.
 i1 : x = t o1 = t o1 : Symbol i2 : x <- 4 o2 = 4 i3 : x o3 = t o3 : Symbol i4 : t o4 = 4

Initially, the value of a symbol y is y itself, and then y = e and y <- e do the same thing.

 i5 : y <- 44 o5 = 44 i6 : y o6 = 44

The code to the left of the arrow can be any expression whose value is a symbol.

 i7 : f = () -> symbol z o7 = f o7 : FunctionClosure i8 : (f()) <- 44 o8 = 44 i9 : z o9 = 44

installing new assignment methods

• Usage:
installMethod(symbol <-, X, (x,e) -> ...)
• Inputs:
• X, a type
• (x,e) -> ..., of two arguments
• Outputs:
• the value returned is the function provided
• Consequences:
• the function (x,e) -> ... is installed as the method for assignment to objects of type X. See the next subsection below for using it.
 i10 : installMethod(symbol <-, String, peek) o10 = peek o10 : FunctionClosure

using installed assignment methods

• Usage:
x <- e
• Inputs:
• x, an object of type X
• e,
• Outputs:
• the value of the expression is the value returned by the previously installed method
• Consequences:
• the previously installed method for assignment to objects of type X is called with arguments (x,e), unless x is a symbol, in which case the internal assignment method applies, as described above. If there is no method for X, then the ancestors of X are consulted, starting with the parent of X and ending with Thing (see inheritance).

The following example used the method for assignment to strings installed above.

 i11 : "foo" <- "bar" o11 = ("foo", "bar")

As before, the left hand side is evaluated, and in this case, it can be any expression whose value is a string.

 i12 : "foo" | "foo" <- "bar" o12 = ("foofoo", "bar")

assignment to an indexed variable

• Usage:
x <- e
• Inputs:
• x,
• e,
• Outputs:
• the value of the expression is the value returned by the previously installed method
• Consequences:
• assuming the value of x is , the value of e is assigned to it, so that future references to value x or to s_i, if that's what the value of x is, yield e. Moreover, the value of s is set to s.

This assignment method is pre-installed.

 i13 : u = s_4 o13 = s 4 o13 : IndexedVariable i14 : s = 3 o14 = 3 i15 : u <- 555 warning: clearing value of symbol s to allow access to subscripted variables based on it : debug with expression debug 6001 or with command line option --debug 6001 o15 = 555 i16 : s o16 = s o16 : IndexedVariableTable i17 : s_4 o17 = 555 i18 : u o18 = s 4 o18 : IndexedVariable i19 : value u o19 = 555

parallel assignment

• Usage:
x <- e
• Inputs:
• x,
• e,
• Outputs:
• the value of the expression is the value of e
• Consequences:
• assuming the values of x and of e are , with the same length, each member of e is assigned to the corresponding member of x

This assignment method is pre-installed.

 i20 : (symbol a, symbol b) <- (3,4) o20 = (3, 4) o20 : Sequence i21 : a o21 = 3 i22 : (symbol r_1 .. symbol r_3) <- (5,6,7) o22 = (5, 6, 7) o22 : Sequence i23 : r_2 o23 = 6