Next: , Up: Functions   [Index]


9.1 Calling Functions

Functions are called with arguments in the number and types prescribed by the function parameters lists.

Implicit convertions are performed between related types for function arguments, notably between intrinsic numerical types and between the ‘object’ type and any other type.

The types of the argument values must either match or be convertible to the function described parameter types.

See The Object Type.

See The Intrinsic Types.

See Implicit Convertions.

Function calls evaluate to values of the function return type.

The primary function call syntax has the function name followed by the parantheses enclosed list of arguments, with the arguments comma separated.

    abs(-3);
    pow(4, 4);
    o_integer(0);
    o_real(4, sin(.5));
    r_put(r, "key", "data");
    o_newline();

A secondary function call syntax has the first argument before the function name, with a period sign (‘.’) between the two.

Certain prefixes may be stripped from the function names, provided that the leading function argument matches exactly for type.

    4.pow(4);
    l.length();
    "syntax".length();
    r.put("key", "data");

The prefix stripped name is a calling convenience and its usefulness goes only so far. It does not by itself identify the function (in the above examples, ‘length’ refers to two functions, the ‘length’ and ‘l_length’ ones).

For the reversed secondary call syntax, the parentheses may be omitted for functions taking only one argument:

    375.bcount;
    "syntax".length + "777".atoi;

Reference parameters command read/write variable arguments, except for variadic reference typeless parameters.