LSPS documentation logo
LSPS Documentation
Function Calls

Function calls are calls to function definitions which are special kinds of closures defined in a function definition: Function definitions are model elements which cannot be created directly in the Expression Language; however, you can call functions and use their return value in your expressions.

A function call follows the syntax

<FUNCTION_NAME>(<COMMA_SEPARATED_ARGUMENTS>)

or alternatively

<FUNCTION_NAME>(<PARAMETER_NAME_1> -> <ARGUMENT_1>, <PARAMETER_NAME_2> -> <ARGUMENT_2>)

Example function call:

getModel("Delivery", 1.4)
//alternatively:
getModel(name -> "Delivery", version -> "1.4")

If a function uses type parameters, their types are inferred. However, you can define the types explicitly if required:

<FUNCTION> | <COMMA_SEPARATED_TYPES_PARAMETER_TYPES> | (<ARGUMENTS>)

The list of types in <COMMA_SEPARATED_TYPES> is used in the same order as the type parameters are defined. Note that you need to define the types for all type parameters.

A function call is resolved into the function based on the call arguments: overloading is supported.

Call to a Standard Library function with the types of type parameters:

//collect has the E and T type parameters:
//E will be handled as Employee and T as Decimal:
sum(collect|Employee, Decimal|(e, {e -> e.salary}))