<< Prev | - Up - | Next >> |
Oz supports infix and prefix notation for very common procedures (see Section 3.5 of ``The Oz Notation'').
In the following table, we give the prefix and infix notations and the corresponding expansions. The operators are grouped together according to their precedence. Members of the same group have the same precedence, groups further up have lower precedence than groups further down. ``Having higher precedence'' means ``binding tighter''; e. g., the term X.Y + Z
is equal to (X.Y) + Z
. Ambiguities within each group are resolved by the associativity given before each group (e. g., X - Y + Z
is equivalent to (X - Y) + Z
).
Infix | Normal |
---|---|
right-associative | |
|
|
right-associative | |
| Cell, Attribute, Dictionary or Array element assignment |
| Cell, Attribute, Dictionary or Array element exchange |
| Dictionary or Array element assignment |
| Dictionary or Array element exchange |
|
|
|
|
non-associative | |
|
|
|
|
|
|
|
|
|
|
|
|
left-associative | |
|
|
|
|
left-associative | |
|
|
|
|
|
|
|
|
right-associative | |
|
|
prefix | |
|
|
left-associative | |
| get content of Record, Dictionary, or Array element |
prefix | |
| get content of Cell, Attribute, Dictionary or Array element |
|
|
The expansion of the state-manipulation operators (.
, :=
, and @
) depends on the type of the expressions involved. The expansions are simplified, suitable error messages are returned if the type of the expressions are not valid.
E1.E2
E1.E2
expands toif {Record.is E1} then {Value.'.' E1 E2} else @(E1#E2) end
returns the content of a record, dictionary, or array element.
E1.E2 := E3
E1.E2 := E3
expands to@(E1#E2) := E3
'. :='
is a ternary operator for updating dictionary and array elements.
E1 := E2
E1 := E2
expands tocase E1
of (D#K) andthen {Dictionary.is D} then {Dictionary.put D K E2}
[] (A#I) then {Array.put A I E2}
elseif {IsCell E1} then
{Cell.assign E1 E2}
else
{Object.assign self E1 E2} %% E1 <- E2 (Object.assign is internal)
end
':='
updates dictionaries, arrays, cells, and attributes. Note, Object.assign
is a dummy routine and not actually visible to the library user.
@E
@E
expands tocase E
of (D#K) andthen {Dictionary.is D} then {Dictionary.get D K}
[] (A#I) then {Array.get A I}
elseif {IsCell E} then
{Cell.access E}
else
{Object.access self E} %% @E (Object.access is internal)
end
'@'
returns the current value stored in dictionaries, arrays, cells, and attributes. Note, Object.access
is a dummy routine and not actually visible to the library user.
X = E1 := E2
X = E1 := E2
expands to'atomic'
X = @E1
E1 := E2
'end'
In an expression context ':='
performs an atomic exchange with the current value stored in the dictionary, array, cell, or attribute. Note 'atomic' ... 'end'
is pseudo code to indicate that the exchange is an atomic action.
<< Prev | - Up - | Next >> |