Home Manual Packages Global Index Keywords Quick Reference Language Reference Starting and Quitting Yorick Getting Help Error Recovery Array Data Types Constants Defining Variables Arithmetic and Comparison Operators Logical Operators Creating Arrays Indexing Arrays Array Conformability Rules Calling Functions Defining Functions Variable Scope Returning from Functions Compound Statements Conditional Execution Loops Function Reference I/O Reference | # Yorick Language Reference ## Defining Functions A function of N dummy arguments is defined by: `func` func_name`(`dummy1, dummy2, ..., dummyN`) {` body_statements`}` If the function has no dummy arguments, the first line of the definition should read: `func` func_name`(void)` Mark output parameters with a `&`, as dummy2 here: `func` func_name`(`dummy1, `&`dummy2, dummy3`)` If the function will take keyword arguments, they must be listed after all positional arguments and marked by a `=`: `func` func_name`(`..., dummyN, key1=, ..., keyN=`)` If the function allows an indeterminate number of positional arguments (beyond those which can be named), place the special symbol `..` after the final dummy argument, but before the first keyword. For example, to define a function which takes one positional argument, followed by an indeterminate number of positional arguments, and one keyword, use: `func` func_name`(`dummy1, `..`, key1=`)` The function `more_args()` returns the number of unread actual arguments corresponding to the `..` indeterminate dummy argument. The function `next_arg()` reads and returns the next unread actual argument, or nil if all have been read.