NextPrevUpTopContentsIndex Referencing types via methods

Code can reference type names either directly as shown in Avoid referencing type names or via type-of in code like this:

(defun foo (x)
  (let ((type (type-of x)))
    (cond ((eq type 'class1) ...)
          ((eq type 'class2) ...)
          ((eq type 'class1000) ...))))

Instead, you could express the conditional clauses as methods specialized for each class:

(defmethod foo ((x class1)) ...)
(defmethod foo ((x class2)) ...)
(defmethod foo ((x class1000)) ...)

This would allow any unused classes to be removed by delivery, because each method is a separate function.

LispWorks Delivery User Guide - 14 Mar 2008