Unary Operators
The following prefix unary operators supported:
Arithmetic operators | ||
---|---|---|
+ |
Plus. Returns unchanged value for numeric operand. Can be overridden. | |
- |
− (U+2212) |
Minus. Returns negated value for numeric operand. Can be overridden. |
Logical Operators | ||
---|---|---|
-- |
¬ (U+00AC) |
Logical NOT. Negates the logical value and discards the value itself. The result has a void type. |
++ |
Logical value. Discards the value and leaves the logical value unchanged. The result has a void type. |
Other operators | |
---|---|
\ |
Value of. Extracts the value from any object. |
# |
Macro expansion. |
Only arithmetic operators can be overridden.
Value Of
The value of operator is a convenience expression to extract the value from any object. The same effect can be achieved by other means, but the resulting expression will be longer.
The operator can be used in situation like this:
C := \(a + b)
This declares a field C
, which value is a sum of A
and B
.
Given the A
and B
are integers, this can be written other way:
C := integer (= a + b)
This means exactly the same, but is longer and involves an explicit type specification, while the shorter form works for any type of value.
Note how the value of operator differs from it’s operand. The similar expression without operator:
A := a + b
means that A
is inherited from the sum object, while the original declaration
makes the A
inherited from Integer
.
In some situations the value of operator is useless however. The following statements mean exactly the same, and the value of operator usage is redundant:
= a
= \a
Also, it is necessary to be careful with this operator when using it within links:
A := `b
The code above declares a link A
, which target is an existing object B
.
But if the value of operator used:
A := `\b
then the link A
will be linked to a newly constructed object, which value is
the one of object B
, which is not the same, and actually means:
A := `integer (= B)
Operators Precedence
Unary operators has lower precedence than reference qualifiers, and higher precedence than binary operators.