A subroutine is a named "black box" that performs a specific task, depending on the values that are specified for the subroutine’s parameters, if any, and possibly on the values of some global variables (Global Variables).
name [, arg1, arg2 … ]
calls the subroutine that has name
name, with the listed
arguments, separated by commas. A subroutine call need not have any
arguments. See Arguments to learn more about the various ways in
which arguments can be specified for subroutines.
LUX offers many internal subroutines (Internal Routines), and also allows the user to define subroutines written in the LUX language (Subroutine Definition).
Because internal subroutines, user-defined subroutines, and subroutine
pointer variables (Pointers) all have their own name spaces,
symbols of these three kinds can exist at the same time even if they all
have the same name. For instance, in addition to the internal
limits (limits), one can also have a
subroutine pointer named
limits and a user-defined subroutine
limits, all at the same time (remember that upper case and
lower case letters are equivalent in this situation).
Which of these three possibilities is to be executed is determined at compile time, as described below. The first match (at the time that the statement is compiled) is taken.
If during execution a user-defined subroutine turns out not to have been
compiled yet, then LUX tries to find a file that contains a definition
for that subroutine. LUX looks for a file with the same name as the
subroutine, transformed to all lower-case letters, and with the
.lux suffix added. LUX looks for this file in the directories
which are listed, separated by colons (:) in the environment
LUX_PATH (Environment), and in the directory, if
any, that was specified using
ulib (ulib). If such a file
is found, then it is included at this point. If the sought subroutine
is still not defined after the file has been included, then an error
message is displayed.
The way of linking a subroutine symbol to a particular subroutine at
compile time allows various kinds of shadowing, of hiding a
particular subroutine behind some other one. E.g., you can hide the
internal definition for
limits by defining your own version
(Subroutine Definition), or by creating a pointer with that same
name that points at a subroutine of your choice, and you can hide a
user-defined subroutine named
mycode by defining a pointer with
that same name that points at another subroutine. The hidden
definitions are not deleted; they are merely hidden and can be restored
as first choice by deleting the overlaid definitions.
Subroutines can be called recursively. See Recursion for details.
Some subroutines can be called with more arguments than it has parameters. See Extended Parameter Lists for details.