Skip to content

Would be nice if 'typep' signalled on invalid type specifiers #722

Description

@slburson

[Previously filed on gitlab.common-lisp.net, but that doesn't seem to have been the right place.]

AFAIK, CL provides no portable way to determine whether a symbol has been deftyped. The only semi-portable way I know to do it is to try passing it to typep and see whether I get an error:

(defun is-type? (x)
  (handler-case 
       (progn (typep nil x) t) 
     (error () nil)))

This works on SBCL, CCL, ECL, CLASP, Allegro, and LispWorks, but fails on ABCL:

> (typep nil 'garbage)
NIL

It is true that the spec for typep says

The consequences are undefined if the type-specifier is not a type specifier.

but it would be nice if ABCL would signal an error, as other implementations do. Wouldn't it make sense to do this in normalize-type?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions