A.5.6 User-Defined Functions

With the IDDL new functions can be defined in a simple and flexible way. So the functionality of the description language can be easily enlarged and customized.

Functions can be defined similarly to variables. The function name is followed by an argument list enclosed in parentheses, e.g.,

add(x,y) = x + y;
sub(x,y) = x - y;
inc(x)   = x + 1;
dec(x)   = x - 1;

In this example four functions named add(), sub(), inc(), and dec() are defined.

Parameters like x and y are not variables but parameters, valid within the function definition only. Defining a variable named x anywhere in the input file would not influence the behavior of a function using a parameter x.

User-defined functions can be used in the same way as built-in functions, for example:

a = 11;
b = 23;
sum = add(a,b);
sum = inc(sum);

The value of the variable sum will evaluate to 35.

Robert Klima 2003-02-06