A method is a function that is executed if the first argument passed to it matches the method's class. Different EIEIO classes may share the same method names.
Methods are created with the
defmethod macro, which is similar
method is the name of the function to create.
:afterspecify execution order (i.e., when this form is called). If neither of these symbols are present, the default priority is used (before
:before); this default priority is represented in CLOS as
:STATICmethod tags were in all capital letters in previous versions of EIEIO.
arglist is the list of arguments to this method. The first argument in this list—and only the first argument—may have a type specifier (see the example below). If no type specifier is supplied, the method applies to any object.
doc-string is the documentation attached to the implementation. All method doc-strings are incorporated into the generic method's function documentation.
forms is the body of the function.
In the following example, we create a method
mymethod for the
(defmethod mymethod ((obj classname) secondarg) "Doc string" )
This method only executes if the obj argument passed to it is an
EIEIO object of class
A method with no type specifier is a default method. If a given class has no implementation, then the default method is called when that method is used on a given object of that class.
Only one default method per execution specifier (
:after) is allowed. If two
defmethods appear with arglists lacking a type specifier,
and having the same execution specifier, then the first implementation
When a method is called on an object, but there is no method specified
for that object, but there is a method specified for object's parent
class, the parent class' method is called. If there is a method
defined for both, only the child's method is called. A child method
may call a parent's method using
If multiple methods and default methods are defined for the same method and class, they are executed in this order:
If no methods exist, Emacs signals a
error. See Signals.
If replacement-args is non-
nil, then use them instead of
eieio-generic-call-arglst. At the top level, the generic argument list is passed in.
next-method-pto find out if there is a next method to call.
At present, EIEIO does not implement all the features of CLOS: