A call to a feature executes the code of the feature and yields the result of that feature.
A call typically has the form
target itself is a call that determines the instance the call
is executed on and
arguments specify the initial values of the
argument fields of the called feature.
target is not given, target is the instance of the current
feature or, in case this feature does not declare a feature
called_feature, the target is the instance of the closest outer
feature that does declare a feature
Here is a small example that defines and calls the
After the declaration of
my_int, the example starts by
my_int 7 and assigning the result to a new
seven. This call does not explicity specify a target.
The implicit target is the current instance of
call, the argument field
be initialized to 7.
A feature that does not define an explicit result type (or
=> and type inference to infer the result type) implicitly
returns its current instance as a result. So in the case of the call
my_int 7, the result is an instance of
v set to 7.
Next, the call
seven.minus1 is performed. The target of the call
is the value stored in field
seven. There are no arguments expected
minus1, so none are given to the call and parentheses are also
not needed. The result of the call to
minus1 is a new instance
The following call
six.pow 3 calls
pow on the
six given the argument
3. If you look at the
pow, you can see that it takes the current object to the
given exponent using a recursive call to itself.
Finally, at the end of this example,
For clarity, the previous example did not use syntactic sugar. It can be simplified to equivalent code as follows:
The use of any operator such as
infix + to add numeric values is a
call to a feature. To define an operator, the feature name must
postfix followed by
the operator to define.
Here is the same example as above using prefix, infix and postfix operators instead of normal feature names:
The use of operators as feature names is purely syntactic, the code is equivalent to the version using normal names.
It is even possible to use dot-notation for calls to features whose name is
an operator. E.g., the call
--seven is equivalent