Previous section: Statement bodies

Dylan reference manual -- Special function call syntax

Special function call syntax

Infix Operators

Certain predefined operators are called using standard algebraic syntax. Operators and their arguments must be separated by whitespace or parentheses. All binary operators are left-associative, except for the assignment operator :=, which is right-associative.

These are listed in descending order of precedence. Operators within a group share the same precedence.

unary	-	negative
unary	~	not (boolean)

binary	^	exponentiation

binary	*	multiplication
binary	/	division

binary	+	addition
binary	-	subtraction

binary	=	equality
binary	==	identity
binary	~=	not equals
binary	<	less than
binary	>	greater than
binary	<=	less than or equals
binary	>=	greater than or equals

binary	&	and
binary	|	or

binary	:=	assign
Except for the last three, all of these infix operators are functions. These functions are first class, like all Dylan functions, but in order to use one where a variable name is expected (for example, as the variable name in a define method, or as a function argument) the operator must be prefixed with the infix operator escape character (\).

The order of evaluation for general infix expressions is as follows:

In an expression of the form

arg1 op ... op argn

arg1 ... argn are evaluated in that order. The evaluation time of module variables that op 's are defined to invoke (e.g. the plus function for +), is unspecified.

The last three infix operators listed here (&, |, and :=) are syntax forms. They have special evaluation rules which are described where these forms are defined.

Slot Reference

Dylan provides a shorthand syntax for slot reference. The syntax argument.function applies function to argument. This syntax is usually used for slot reference, to access the function slot of the object argument.

This can be cascaded and is left associative (i.e., gets the pan slot of the gai slot of the goo slot of moo.).


"Washington, D.C."
? me.mother.current-husband.favorite-child == me

Dylan's left-to-right evaluation rule applies here: argument is evaluated first, followed by function.

Array Reference

Dylan provides a shorthand syntax for array reference. The syntax foo[i] is equivalent to the function call element(foo, i). The syntax foo[i1, i2, ... in] where n != 1 is equivalent to the function call aref (foo, i1, i2, ... in).

? define constant vect = #[7, 8, 9]
defined vect
? vect[0]

In expressions of the form

sequence[arg1, ..., argn]

sequence is evaluated first, then arg1 ... argn in that order.

The evaluation time of the variable <element in Dylan module> or <aref in Dylan module>, which this expression is defined to invoke, is unspecified.

Next section: Syntax of Dylan Files