From: tichy
Subject: How to check that symbol denotes type ?
Date: 
Message-ID: <drj9hj$s4e$1@nemesis.news.tpi.pl>
Hi.

How to check (in portable way) that symbol is a type specifier ?
For symbols which are names for classes I can use FIND-CLASS, but
not all types have corresponding classes (ATOM, BOOLEAN, ...)

TIA, Szymon.

From: sross
Subject: Re: How to check that symbol denotes type ?
Date: 
Message-ID: <1138569140.032196.34370@o13g2000cwo.googlegroups.com>
Hi,
you should be able to use subtypep for this.

(defun designates-type-p (symbol)
  "Returs T if SYMBOL designates a type."
  (values (ignore-errors (subtypep symbol t))))  

Cheers,
 Sean.
From: Christophe Rhodes
Subject: Re: How to check that symbol denotes type ?
Date: 
Message-ID: <sqpsmavhnk.fsf@cam.ac.uk>
"sross" <······@gmail.com> writes:

> you should be able to use subtypep for this.
>
> (defun designates-type-p (symbol)
>   "Returs T if SYMBOL designates a type."
>   (values (ignore-errors (subtypep symbol t))))  

Maybe you "should", but do you have any actual evidence that you
/can/?

Christophe

(Hint: no.  I know of no portable way to check whether something is a
type specifier.)
From: sross
Subject: Re: How to check that symbol denotes type ?
Date: 
Message-ID: <1138643723.332281.284930@g49g2000cwa.googlegroups.com>
> Maybe you "should", but do you have any actual evidence that you
> /can/?

Ummm, not really.
I've been working off the CLHS definition of subtypep and
my reasoning is that if something is a recognizable subtype
of T then it should designate a type.
I've just noticed the behaviour of SBCL (and I'm assuming CMUCL
is the same) and can't quite understand why
(subtypep 'not-a-type t) would return T, T.

Cheers, 
  Sean.
From: Thomas A. Russ
Subject: Re: How to check that symbol denotes type ?
Date: 
Message-ID: <ymi7j8hr0yr.fsf@sevak.isi.edu>
"sross" <······@gmail.com> writes:

> I've just noticed the behaviour of SBCL (and I'm assuming CMUCL
> is the same) and can't quite understand why
> (subtypep 'not-a-type t) would return T, T.

I would guess that this is perhaps some optimization or reasoning
special case based on the idea that EVERYTHING is a subtype of T.

-- 
Thomas A. Russ,  USC/Information Sciences Institute
From: Peter Seibel
Subject: Re: How to check that symbol denotes type ?
Date: 
Message-ID: <m2d5i95z7z.fsf@gigamonkeys.com>
"sross" <······@gmail.com> writes:

>> Maybe you "should", but do you have any actual evidence that you
>> /can/?
>
> Ummm, not really. I've been working off the CLHS definition of
> subtypep and my reasoning is that if something is a recognizable
> subtype of T then it should designate a type.

Unfortunately for this theory the documentation of SUBTYPEP requires
that the first two argumens be "type specifiers". If you pass it
something that is *not* a specifier, the implementation is at liberty
to do whatever it feels like.

-Peter

-- 
Peter Seibel           * ·····@gigamonkeys.com
Gigamonkeys Consulting * http://www.gigamonkeys.com/
Practical Common Lisp  * http://www.gigamonkeys.com/book/
From: sross
Subject: Re: How to check that symbol denotes type ?
Date: 
Message-ID: <1138648362.292041.267030@o13g2000cwo.googlegroups.com>
Thanks,

 1.4.4.3 : Except as explicitly specified otherwise, the consequences
               are undefined if these type restrictions are violated.

CLHS : 259
Sean : 0

Cheers.
From: Thomas F. Burdick
Subject: Re: How to check that symbol denotes type ?
Date: 
Message-ID: <xcv7j886982.fsf@conquest.OCF.Berkeley.EDU>
"sross" <······@gmail.com> writes:

> > Maybe you "should", but do you have any actual evidence that you
> > /can/?
> 
> Ummm, not really.
> I've been working off the CLHS definition of subtypep and
> my reasoning is that if something is a recognizable subtype
> of T then it should designate a type.
> I've just noticed the behaviour of SBCL (and I'm assuming CMUCL
> is the same) and can't quite understand why
> (subtypep 'not-a-type t) would return T, T.

You really don't have any hope of doing what you want portably.
However, the concept probably isn't hard to port to any given Lisp.
So, I'd just do that:

  (defun symbol-names-a-type-p (symbol)
    #+sbcl (sb-int:info :type :kind symbol)
    #+cmu (ext:info :type :kind symbol))

-- 
           /|_     .-----------------------.                        
         ,'  .\  / | Free Mumia Abu-Jamal! |
     ,--'    _,'   | Abolish the racist    |
    /       /      | death penalty!        |
   (   -.  |       `-----------------------'
   |     ) |                               
  (`-.  '--.)                              
   `. )----'