Function Calls

Syntax

function_call ::= id "(" [expression ("," expression)*] ")"

Semantics

Function-call expressions are used to invoke functions, which in the current version can be built-in (system) functions only. Syntactically, a function call starts with an id which identifies the function to call by name, followed by a parenthesized list of zero or more argument expressions separated by a comma.

Each function has a signature, which specifies the sequence type of its result and a sequence type for each of its parameters. Evaluation of a function-call expression starts with the evaluation of each of its arguments. The result of each argument expression must be a subtype of the corresponding parameter type, or otherwise, it must be promotable to the parameter type. In the latter case, the argument value will actually be cast to the expected type. Finally, after type checking and any necessary promotions are done, the function's implementation is invoked with the possibly promoted argument values.

The following type promotions are currently supported:
  • INTEGER is promotable to FLOAT or DOUBLE.
  • LONG is promotable to FLOAT or DOUBLE.
  • STRING is promotable to ENUM, but the cast will succeed only if the ENUM type contains a token whose string value is the same as the input string.

The list of currently available functions is given in the Built-in Functions chapter.