Next: , Up: Writing Methods

6.1 Generics

Each EIEIO method has one corresponding generic. This generic provides a function binding and the base documentation for the method symbol (see Symbol Components).

— Macro: defgeneric method arglist [doc-string]

This macro turns the (unquoted) symbol method into a function. arglist is the default list of arguments to use (not implemented yet). doc-string is the documentation used for this symbol.

A generic function acts as a placeholder for methods. There is no need to call defgeneric yourself, as defmethod will call it if necessary. Currently the argument list is unused.

defgeneric signals an error if you attempt to turn an existing Emacs Lisp function into a generic function.

You can also create a generic method with defmethod (see Methods). When a method is created and there is no generic method in place with that name, then a new generic will be created, and the new method will use it.

In CLOS, a generic call also be used to provide an argument list and dispatch precedence for all the arguments. In EIEIO, dispatching only occurs for the first argument, so the arglist is not used.