Inline and Regular User-Defined Functions

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  Functions > User-Defined Functions >

Inline and Regular User-Defined Functions

There are two kinds of user-defined functions: inline and regular. You can specify whether a function should be inline or regular when creating the function, see Creating User-Defined Functions. Inline and regular functions behave differently in terms of code generation, recursiveness, and the ability to have multiple output parameters.

 

Inline functions

Regular functions

Inline functions are extracted in all instances where they occur in generated code, which makes the code longer but also slightly faster.

 

Note that inline functions can significantly increase the amount of generated program code. The user-defined function code is actually inserted at all locations where the function is called, and thus increases the code size substantially - as opposed to using a regular function.

Each user-defined function component generates code for a function call, where inputs are passed as parameters, and the output is the function (component) return value.

 

At runtime, all the input parameter values are evaluated first, and then the function is called for each occurrence of the input data.

Inline functions can have multiple outputs and thus return multiple values.

Regular functions can have only one output. To return multiple values, you can declare the output to be of complex type (for example, XML structure), which would allow you to pass multiple values to the caller.

Inline functions cannot be called recursively.

Regular functions can be called recursively.

Inline functions do not support setting a priority context on a parameter, see Priority Context node/item.

Regular functions support setting a priority context on a parameter.

 

On the mapping, inline user-defined functions are displayed with a dashed border. For example, the middle component in the mapping below is an inline user-defined function.

mf_udf_06

Regular functions are displayed with a solid border. For example, the middle component in the mapping below is a regular user-defined function.

mf_udf_05


© 2019 Altova GmbH