3.2.6 Use of TYPEP, TYPECASE and SUBTYPEP for type discrimination

If you use typep , typecase , and subtypep to discriminate between types, Delivery is forced to keep additional information in the delivered image. This is because these operations are open-ended and require the presence of information about all possible types. Large functions and tables containing this information must be retained in order for them to work.

Built-in predicates, such as consp and floatp , can, on the other hand, be retained with little cost in image size. The same applies to structure predicates. (For example, the predicate foo-p for (defstruct foo) would not be costly.)

If you retain CLOS, we recommend that you use methods for type discrimination instead of open-ended type operations, as an unused method has a greater chance of being deleted. For example,

(typecase x
  (integer (process-an-integer x))
  (string (process-a-string x))


(cond ((integerp x) (process-an-integer x))
      ((stringp x) (process-a-string x)))


(defmethod process-anything ((x integer)) ...)
(defmethod process-anything ((x string)) ...)
(process-anything x)

LispWorks Delivery User Guide - 12 Sep 2005