Common Lisp Object System

CLtL2 Reference 

macro DEFPOLYMORPHIC : (name lambda-list &body body)

Defines a new polymorphic function that dispatches on the type of its first argument. <body> defines a default method. The function define-method can be used to define additional methods. For example:

(defpolymorphic test (a b)

(list a b))

(define-method test ((a cons) b)

(cons b a))

(define-method test ((a fixnum) b)

(+ a b))

The defpolymorphic form defines the function TEST with a default method.

The two define-method forms specialize the behavior of TEST for lists and fixnums.

(test ‘foo ‘bar) => (FOO BAR)

(test ‘(foo) ‘bar) => (BAR FOO)

(test 2 3) => 5

macro DEFINE-METHOD : (name lambda-list &body body)

Defines a method for the polymorphic function <name> that runs if

<dispatch-arg> is of type <type>. The lambda list must have the same

structure as in the DEFPOLYMORPHIC call.

Miscellaneous Features Home SubL-Specific Features