Previous: , Up: Writing Methods   [Contents][Index]

6.3 Static Methods

Static methods do not depend on an object instance, but instead operate on a class. You can create a static method by using the subclass specializer with cl-defmethod:

(cl-defmethod make-instance ((class (subclass mychild)) &rest args)
  (let ((new (cl-call-next-method)))
    (push new all-my-children)
    new))

The argument of a static method will be a class rather than an object. Use the functions oref-default or oset-default which will work on a class.

A class’s make-instance method is defined as a static method.

Note: The subclass specializer is unique to EIEIO.