|
|||||
Functions: argument recognition | |||||
Prerequisite Concepts | Related Syntax |
OmniMark programmers should understand how function arguments are recognized to avoid syntax errors or ambiguous constructs.
Function argument recognition behaves differently for functions with the parenthesized comma-separated argument list, and those whose arguments are heralded by names.
An argument in the parenthesized, comma-separated argument list begins after the opening parenthesis that begins the argument list, or the comma that ends the previous argument.
The argument continues until the comma that ends it is found, or until the closing parenthesis that ends the argument list is found.
An argument heralded by a name actually consists only of the immediately following subexpression. OmniMark stops recognizing the argument as soon as it has a valid expression, regardless of whether the expression has the correct type, or whether the code following the expression could also be interpreted as part of the expression.
A function which takes a single argument can actually be considered a monadic operator like name of
or like a negative sign ("-") applied to a numeric value. In OmniMark, monadic operators always bind more tightly than other operators. Functions which take a single argument behave exactly the same way.
When a function takes more than one argument, the recognition of each argument is the same as it is for the last argument: the argument is only recognized up until a valid expression has been formed.
By using the same method to recognize every argument in a function, the programmer can be sure that adding optional arguments to the end of a previouslycorrect function definition will have the least impact on existing programs.
Prerequisite Concepts Functions Functions: argument classes |
Related Syntax define function name of |
---- |