Navigation
Synopsis Function call.
Syntax Name ( Exp1, Exp2, ... )
Types
Exp1 Exp2 ... Name ( Exp1, Exp2, ... )
T1 T2 ... Determined by Name, Ti and function declarations
Description First, the actual parameter expressions Expi are evaluated resulting in values Vi. Based on Name and the argument types Ti, the identity of the function to be called is determined.

The values Vi are bound to the formal parameter names of the declared functions and the function body is executed. The value returned by the function is used as value of the function call.



A constructor call has identical syntax to that of a function call, see Constructor,

See Function for more details about function declarations.
Examples First declare a function square with argument n that returns n2:
rascal>int square(int n) { return n * n; }
int (int): int square(int);
Next call square. This results in the following steps:
  1. Based on the name square and the int argument 12 we identify the function to be called (= the function square we just defined).
  2. Compute the value of the actual parameter (= 12).
  3. Bind the formal parameter n to the actual value 12.
  4. Execute the body of square.
  5. The return value of square is the vale of the call:
rascal>square(12);
int: 144
Is this page unclear, or have you spotted an error? Please add a comment below and help us to improve it. For all other questions and remarks, visit ask.rascal-mpl.org.