+ Christian Nybø <[EMAIL PROTECTED]>:

| CL-USER> (subtypep 'not-a-type-spec t)
| T
| T
| CL-USER>
| 
| Not quite right, is it?

Well, according to the hyperspec, subtypep cannot signal an exception.
So it must return something meaningful.  If you read the spec
carefully, it is not allowed to return false, false either, so we're
left with false, true, or true, true.  Of the two, the latter seems
clearly right to me.  You may think of not-a-type-spec as a type
specifier for some as yet unknown type about which nothing is known
except that nil is a subtype of it, and it is itself a subtype of t.

| I am looking for something like a type-specifier-p in cmucl

I suspect there is no portable way.  In cmucl, this seems to work:

(defun type-specifier-p (name)
  (handler-case (typep nil name)
    (simple-error () nil)
    (:no-error (ignore) (declare (ignore ignore)) t)))

On a related note, while the following seems reasonable:

CL-USER> (subtypep 'not-a-type-spec 'number)
nil
nil

it is a result expressly forbidden by the hyperspec:

  subtypep is permitted to return the values false and false only when
  at least one argument involves one of these type specifiers: and,
  eql, the list form of function, member, not, or, satisfies, or
  values.

I suppose nil and t would be more correct.

But I'll leave that to the language lawyers.

- Harald


Reply via email to