[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Types in CL



    Date: Thu, 17 Dec 87 17:46 EST
    From: David A. Moon <Moon@stony-brook.scrc.symbolics.com>

    This is probably all a digression from your real point.  Since DEFTYPE
    can do anything, especially in connection with SATISFIES, it is certainly
    possible to create logically inconsistent type specifications, even though
    the particular example you gave is not actually one.

Ah, yes, I just did

(deftype random-type () `(member ,(random 10)))

In this case, even

		   (and (typep x 'random-type)
			(typep x 'random-type))

can be false, and you can go crazy trying to call a function defined

(defun random-function (x)
  (check-type x random-type)
  ...)

By the way, this shows that I was wrong in my last message, when I said
that recursion isn't possible unless SATISFIES is used.  All you need to
do is

(deftype int-greater-than (n)
  (labels ((rest (n) (cons n (rest (1+ n)))))
    `(member .,(rest (1+ n)))))

Conceptually, the type specifier (int-greater-than N) is equivalent to
(integer (N) *), but it'll never work with TYPEP.

                                                barmar