Printer FriendlyEmail Article Link

TTworkbench: May I leave out/omit some parameter with default value when calling a function in TTworkbench?

Environment/Versions
 TTworkbench 32/64 Bit, Microsoft Windows/Linux
Answer

There is a confusion between the english 'to omit' (a parameter in the parameter list) and the TTCN-3 omit (of an optional field in a record/set value).

If you want to pass an optional field to a parameter, you need to declare that parameter (that shall otherwise only allow values) as 'template(omit)' in front of the type in the formal parameter declaration.

If you want the default value of the parameter to be used, you have to pass <unchanged> (that is the dash symbol -) as an actual parameter
(or really omit it by shortening the parameter list).

An example:
  function f(octetstring x := '0000'O) { ... }

to get a function instance where the default is used,you can write:
  f(-)
or
  f()
or
  f(x := -)

Shortening of the parameter list only works if all following parameters also have a default value (and these shall all be used with
default values).

In case of the named-parameter-assignment-notation (last version in the above example), only the parameters which are mandatory (i.e. have
no default value) have to be given. The other ones can be omitted or written with a - if they shall use the default value.

In case of parametrized templates that have only formal parameters with default values, the whole parameter list can be omitted, as well.


Product : TTCN-3 Language