In theory, standard Lisp functions are not typed explicitly : their arguments are not predefined, and they are supposed to accept any type of argument. However, internal errors may still occur if the input data is not of the expected type.
On the contrary, most OM functions actually refer to what is known as generic functions1. In CLOS2, a generic function is a kind of "meta" function that applies to several distinct types of arguments3 via several methods4. Each method is specialized to adapt the behaviour of the function – the way it operates – to the type of argument it is assigned. Hence, the input data is "filtered" before computation starts and the relevant method is applied to it.
For instance, a generic function "add" could be considered a set of two different methods.
![]() The OM+ generic function comprises four internal methods. The accepted types of arguments for this function are: list+list, list+number, number+list and number+number. | Double click on the icon of a function to open the generic function editor. This window provides :
|
The universal type, which means "any type", or "T" for "true" in Lisp is represented by this icon :
. This means that the method accepts any type of argument.
The applications of a generic function can be extended by user-defined methods , so that it can accept new types of input arguments.
In a patch, "calling" – using – a generic function with the wrong types of arguments, triggers an error message of the type : "No method is defined for this type of box ...".
For instance, this can occur if a function is connected to a data type it cannot accept.
Here is a widespread error when using object boxes :
In this case, we want to transpose a chord. To execute an operation, a function must apply to the right argument : the relevant output must be connected to the function.
No method is defined, for, as seen previously, the chord + number method is not part of the om+ generic function.
The wrong output, "self" is connected to om+ . The "pitch" output should be connected to it.
The "compiled function" or "compiled method" messages appear when clicking on a Lisp function box or in a method icon within a generic function editor. This means the function is protected. It is internally defined in OM and cannot be modified through the graphic interface.
However, user-defined methods can be open in method editors.
In object oriented programming, a generic function is a collection of methods – elementary specialized functions – with the same name and argument structure, but with arguments typed differently.
See also : Method
CLOS is an object-oriented programming protocol defined in the Common Lisp language specification. It is based on classes, instances of classes, generic functions and methods to be used in Lisp programs.
See also : Class, Function, Generic Function, Method, Instance.
An argument represents a parameter upon which a function operates. For instance, the (om+ x y) function has two arguments : x and y.
An elementary function or part of a generic function defining rules for its behaviour depending on a type of argument. Defining a generic function amounts to defining at least one method.
For instance, the OM+ function is made of four methods : 1. number + list / 2. list + number / 3. number + number / 4. list + list