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

4 Program Control


Dylan provides a small number of unary and binary operators. Three of these are special operators with explicitly defined syntax and execution rules. The remainder are syntactic shorthand for function calls.

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/BinaryDescriptionName
- unaryarithmetic negationnegative
~ unarylogical negation~
^ binaryexponentiation^
* binarymultiplication*
/ binarydivision/
+ binaryaddition+
- binarysubtraction-
= binaryequality=
== binaryidentity==
~= binarynon-equality~=
~== binarynon-identity~==
< binaryless than<
> binarygreater than>
<= binaryless than or equals<=
>= binarygreater than or equals>=
& binarylogical and{none}
| binarylogical or{none}
:= binaryassignment{none}

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

Generated with Harlequin WebMaker