The next command is used to call implementations of a method by a class,
superclass or mixin that are overridden by the current method. It can only be
used from within a method. It is also used within filters to indicate the
point where a filter calls the actual implementation (the filter may decide to
not go along the chain, and may process the results of going along the chain
of methods as it chooses). The result of the next command is the result
of the next method in the method chain; if there are no further methods in the
method chain, the result of next will be an error. The arguments,
arg, to next are the arguments to pass to the next method in the
chain.

The nextto command is the same as the next command, except that it
takes an additional class argument that identifies a class whose
implementation of the current method chain (see info objectcall) should
be used; the method implementation selected will be the one provided by the
given class, and it must refer to an existing non-filter invocation that lies
further along the chain than the current implementation.

When constructing the method chain, method implementations are searched for in
the following order:

In the classes mixed into the object, in class traversal order. The list of
mixins is checked in natural order.

In the classes mixed into the classes of the object, with sources of mixing in
being searched in class traversal order. Within each class, the list of mixins
is processed in natural order.

In the object itself.

In the object's class.

In the superclasses of the class, following each superclass in a depth-first
fashion in the natural order of the superclass list.

Any particular method implementation always comes as late in the
resulting list of implementations as possible; this means that if some class,
A, is both mixed into a class, B, and is also a superclass of B, the instances
of B will always treat A as a superclass from the perspective of inheritance.
This is true even when the multiple inheritance is processed indirectly.

When an object has a list of filter names set upon it, or is an instance of a
class (or has mixed in a class) that has a list of filter names set upon it,
before every invocation of any method the filters are processed. Filter
implementations are found in class traversal order, as are the lists of filter
names (each of which is traversed in natural list order). Explicitly invoking
a method used as a filter will cause that method to be invoked twice, once as
a filter and once as a normal method.

Each filter should decide for itself whether to permit the execution to go
forward to the proper implementation of the method (which it does by invoking
the next command as filters are inserted into the front of the method
call chain) and is responsible for returning the result of next.

Filters are invoked when processing an invokation of the unknown
method because of a failure to locate a method implementation, but not
when invoking either constructors or destructors. (Note however that the
destroy method is a conventional method, and filters are invoked as
normal when it is called.)

This example demonstrates how to build a simple cache class that applies
memoization to all the method calls of the objects it is mixed into, and shows
how it can make a difference to computation times: