yorick banner

Home

Manual

Packages

Global Index

Keywords

Quick 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.