Outputs a list of three numbers: the minimum, default, and maximum number of inputs for the procedure whose name is the input. It is an error if there is no such procedure. A maximum of -1 means that the number of inputs is unlimited.
procedurename input must be a word.
ARITY is provided to enable introspection. For example, if you wanted to write a Logo syntax checker in FMSLogo, you would need to know how many inputs each procedure accepts.
In some cases, the ARITY may output seemingly incorrect results. For example the FOR command is documented to accept exactly two inputs, but ARITY outputs that it can accept 7. This is because FOR is library command that, for implementation convenience, accepts additional, undocumented inputs that have default values, and invokes itself recursively. This does not mean that you should provide more than two inputs, just that FMSLogo does not complain if you do. Wherever ARITY and the documentation appear to be in conflict, follow the documentation.
It is an error for the
procedurename input to be the name of a procedure with a special form like TO.
These procedures cannot be called in the normal way and their inputs are processed in a special manner.
As such, the notion of minimum, default, or maximum inputs is irrelevant.
The following example shows ARITY used on some well-known primitives.
SHOW ARITY "FORWARD[1 1 1]
SHOW ARITY "WORD[0 2 -1]
The following example shows ARITY on a user-defined procedure that has one required input but accepts an infinite number of inputs.
TO MYPROC.WITHREST :required [:rest] END SHOW ARITY "MYPROC.WITHREST[1 1 -1]
This following example shows ARITY on a user-defined procedure that has an optional input which defaults to "foo if not given.
TO MYPROC.WITHDEFAULT :required [:optional "foo] 1 END SHOW ARITY "MYPROC.WITHDEFAULT[1 1 2]