4 Program Control
Operators and their operands must be separated by whitespace or parentheses. All binary operators are left-associative, except for the assignment operator, :=
, which is right-associative.
Each operator that is syntactic shorthand for function call corresponds to a binding name, given in the table below. When an operator is called, the corresponding name is looked up in the environment of the call. (It is not looked up in the Dylan module, and will only refer to a binding in the Dylan module if that binding has been imported in the current module and has not been shadowed by a lexical binding.)
If the name given in the table has the same spelling as the operator, it must be escaped with \ to be used as a named value reference. For example, to add a method to +
with define method
, you use \+
. To use <
as an argument to sort
, you write \<
.
Special operators do not correspond to any binding name, and cannot be used with any alternate syntax.
With the exception of calls to the three special operators (&, |, and :=), the operands of a binary operator call are executed in left to right order. Special operators have their own flow of control rules, described in "Special Operators" on page 395.
The operators are listed below in descending order of precedence. Operators within a group share the same precedence. When a function call using slot reference syntax reference appears as an operands, it has greater precedence than any of the binary operators.
Operator | Unary/Binary | Description | Name | |
---|---|---|---|---|
- | unary | arithmetic negation | negative | |
~ | unary | logical negation | ~ | |
|
| |||
^ | binary | exponentiation | ^ | |
|
| |||
* | binary | multiplication | * | |
/ | binary | division | / | |
|
| |||
+ | binary | addition | + | |
- | binary | subtraction | - | |
|
| |||
= | binary | equality | = | |
== | binary | identity | == | |
~= | binary | non-equality | ~= | |
~== | binary | non-identity | ~== | |
< | binary | less than | < | |
> | binary | greater than | > | |
<= | binary | less than or equals | <= | |
>= | binary | greater than or equals | >= | |
& | binary | logical and | {none} | |
| | binary | logical or | {none} | |
:= | binary | assignment | {none} |
Generated with Harlequin WebMaker