14 The Built-In Macros and Special Operators
|Stores a new value in a location.||395|
|Returns the value of the first of two operands which is true.Returns the value of the first of two operands which is true.||397|
|Executes a second operand and returns its values if the value of the first operand is true.||398|
:=stores new-value in place and returns new-value.
place may be a variable, a getter function or macro with a corresponding setter, a slot access, or an element reference.
new-value may be any operand. It is executed, and its value is stored in place.
In all cases, new-value must be an appropriate type for place or an error is signaled.
The new-value of an assignment statement is executed first, followed by the place (assuming the place requires any execution, which will only be true if it is not a binding name).
:=cannot be used to create bindings, only to change their values.) An error is also signaled if place is a binding specialized to a type and the new-value is not of that type.
define variable *number* = 10; *number*
Þ 10 *number* := *number* + 10;
Þ 20 *number*
:=will invoke the corresponding setter function. Given a binding named fun, the corresponding setter is the binding named fun
-setterin the current environment.
:= maps place to place
-setter without regard for whether place is a function or a macro. It does not expand a macro call on the left-hand side before determining the setter.
With the exception of the order of execution and a guaranteed return value, the following three expressions are equivalent:
*top-view*.subviews := generate-subviews() subviews(*top-view*) := generate-subviews() subviews-setter(generate-subviews(), *top-view*)(The differences are as follows: the execution time of
subviews-setteris undefined in the first two expressions but defined in the last; the first two expressions will return the value of the call to
generate-subviewswhile the last will return the value of the call to
name(arg1,...argn ) := new-valuebehaves exactly the same as
begin let temp = new-value; name-setter(temp, arg1,...argn ); temp endThis is true regardless of whether
name-setterare functions or macros. Here temp stands for a variable with a unique name. If
name-setteris a macro, it is responsible for the order of executation of
The same considerations apply to
arg.name := new-value.
can be used as syntax for
:=can be used as syntax for
aref-setter. For example, the following three expressions are equivalent:
foo := "quux" element (foo, 2) := "quux" element-setter ("quux", foo, 2).
|(logical or) executes one. If the first value of one is true, that value is returned. Otherwise another is executed and its values are returned.
& anotherÞ values
&(logical and) executes one. If the first value returned by one is false,
#fis returned and another is not executed. Otherwise, another is executed and its values are returned.
Generated with Harlequin WebMaker