Search code examples
common-lispclos

In CLOS method definitions, can a specializer be a list of classes and not a single class?


While it does not make much sense in the general case as it should be done via superclasses, I want to allow "nil" for a particular parameter and avoid having to define a separate method.

I'm trying to do something like that (pseudo-code)

(defmethod my-method ((obj1 my-class1) (obj2 (or my-class2 null)))
   method-body       )

Solution

  • This is not supported in plain CLOS.

    Supported are:

    • no class -> T
    • EQL
    • one class