Common Lisp the Language, 2nd Edition
![]()
Next: Type Specifiers That
Up: Type Specifiers
Previous: Predicating Type
Specifiers
The following type specifier lists define a type in terms of other types or objects.
(memberobject1object2...)
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.
(eqlobject)
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
(eqlobject) denotes the
same type as
(memberobject), only
(eqlobject) may be used
as a CLOS parameter specializer.
(nottype)
This denotes the set of all those objects that are not of the
specified type.
(andtype1type2...)
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.
(ortype1type2...)
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
AI.Repository@cs.cmu.edu