ENSURE-CAR
[alexandria.git] / types.lisp
blobcaa5ea89b27dbc1c58e70b08e4bcd852fe419d19
1 (in-package :alexandria)
3 (declaim (inline of-type))
4 (defun of-type (type)
5 "Returns a function of one argument, which returns true when its argument is
6 of TYPE."
7 (lambda (thing) (typep thing type)))
9 (declaim (inline type=))
10 (defun type= (type1 type2)
11 "Returns a primary value of T is TYPE1 and TYPE2 are the same type,
12 and a secondary value that is true is the type equality could be reliably
13 determined: primary value of NIL and secondary value of T indicates that the
14 types are not equivalent."
15 (multiple-value-bind (sub ok) (subtypep type1 type2)
16 (cond ((and ok sub)
17 (subtypep type2 type1))
18 (ok
19 (values nil ok))
21 (multiple-value-bind (sub ok) (subtypep type2 type1)
22 (declare (ignore sub))
23 (values nil ok))))))