Common Lisp the Language, 2nd Edition

Next: Type Specifiers That Up: Type Specifiers Previous: Predicating Type Specifiers

# 4.4. Type Specifiers That Combine

The following type specifier lists define a type in terms of other types or objects.

`(member object1 object2 ...)`
  This denotes the set containing precisely those objects named. An object is of this type if and only if it is `eql` to one of the specified objects.

Compatibility note: This is roughly equivalent to the Interlisp DECL package's `memq`.

`(eql object)`
  X3J13 voted in June 1988 (CLOS) to add the `eql` type specifier. It may be used as a parameter specializer for CLOS methods (see section 28.1.6.2 and `find-method`). It denotes the set of the one object named; an object is of this type if and only if it is `eql` to object. While `(eql object)` denotes the same type as `(member object)`, only `(eql object)` may be used as a CLOS parameter specializer.

`(not type)`
  This denotes the set of all those objects that are not of the specified type.

`(and type1 type2 ...)`
  This denotes the intersection of the specified types.

Compatibility note: This is roughly equivalent to the Interlisp DECL package's `allof`.

  When `typep` processes an `and` type specifier, it always tests each of the component types in order from left to right and stops processing as soon as one component of the intersection has been found to which the object in question does not belong. In this respect an `and` type specifier is similar to an executable `and` form. The purpose of this similarity is to allow a `satisfies` type specifier to depend on filtering by previous type specifiers. For example, suppose there were a function `primep` that takes an integer and says whether it is prime. Suppose also that it is an error to give any object other than an integer to `primep`. Then the type specifier

      (and integer (satisfies primep))

  is guaranteed never to result in an error because the function `primep` will not be invoked unless the object in question has already been determined to be an integer.

`(or type1 type2 ...)`
  This denotes the union of the specified types. For example, the type `list` by definition is the same as `(or null cons)`. Also, the value returned by the function `position` is always of type `(or null (integer 0 *))` (either `nil` or a non-negative integer).

Compatibility note: This is roughly equivalent to the Interlisp DECL package's `oneof`.

  As for `and`, when `typep` processes an `or` type specifier, it always tests each of the component types in order from left to right and stops processing as soon as one component of the union has been found to which the object in question belongs.

Next: Type Specifiers That Up: Type Specifiers Previous: Predicating Type Specifiers