Next: Precedence, Previous: Operators, Up: Expressions [Contents][Index]
A function is a piece of code that returns a value, depending on the values the user specifies for the parameters of the function, if any. LUX offers many built-in functions (Internal Routines), and also allows you to define and call your own functions, written in the LUX language (Function Definition).
A general function call consists of the name of the function, followed by a pair of parentheses enclosing the arguments (if any), which are separated by commas. Some functions can be called without any arguments, but the parentheses must be specified also in this case.
See Arguments to learn about the various ways to specify arguments to a function.
If the function name in a function call is not one of the names of a
built-in function or of an already defined user-defined function, then
LUX tries to find a file that contains a definition for the as yet
undefined function. LUX looks for a file with the same name as the
function, in lower-case letters, and with the _f.lux suffix
added. LUX looks for this file in the current directory, in the
directory, if any, that was specified using ulib
(ulib),
and in the directories which are listed, separated by colons (:),
in the environment variable lux_path
(see Environment). If
such a file is found, then it is included at this point. If the sought
function is still not defined after the file has been included, then an
error message is displayed.
A function is required to return a value (using the return
command – return). If the end of a function is reached and no
value has been return
ed, then an error is generated.
Some functions can be called with more arguments than it has parameters. See Extended Parameter Lists for details.
• Arguments: | Arguments to subroutines and functions | |
• Recursion: | LUX allows recursion of routines |
Next: Precedence, Previous: Operators, Up: Expressions [Contents][Index]