From: Charles Sutton
Subject: Determining whether something is a type specifier
Date: 
Message-ID: <62a38dc8.0304071445.47afd4b7@posting.google.com>
Given a thingy FOO (say it's a symbol), how can I tell 
whether it specifies a type?  I can't find a function in
the standard that does this, and as far as I can tell

  (subtypep 'foo t)

is undefined if FOO does not specify a type.

Can anyone help?

Charles

From: Kent M Pitman
Subject: Re: Determining whether something is a type specifier
Date: 
Message-ID: <sfw8yul28wx.fsf@shell01.TheWorld.com>
············@yahoo.com (Charles Sutton) writes:

> Given a thingy FOO (say it's a symbol), how can I tell 
> whether it specifies a type?

You can't.

> I can't find a function in
> the standard that does this, and as far as I can tell
> 
>   (subtypep 'foo t)
> 
> is undefined if FOO does not specify a type.

There isn't one.

> Can anyone help?

This was recently discussed.  Google for SUBTYPEP.

What program do you want to write that cares about this anyway?
(just curious)
From: JP Massar
Subject: Re: Determining whether something is a type specifier
Date: 
Message-ID: <3e924a2e.19536124@netnews.attbi.com>
On 07 Apr 2003 19:18:54 -0400, Kent M Pitman <······@world.std.com>
wrote:

>············@yahoo.com (Charles Sutton) writes:
>
>> Given a thingy FOO (say it's a symbol), how can I tell 
>> whether it specifies a type?
>
>You can't.
>
>> I can't find a function in
>> the standard that does this, and as far as I can tell
>> 
>>   (subtypep 'foo t)
>> 
>> is undefined if FOO does not specify a type.
>
>There isn't one.
>
>> Can anyone help?
>
>This was recently discussed.  Google for SUBTYPEP.
>
>What program do you want to write that cares about this anyway?
>(just curious)


Writing a language on top of and embedded in Lisp.

The *Lisp compiler, which ran 'inside' the Lisp compiler, triggered by
macro expansion, wanted to recognize type declarations.

So if someone did

(deftype foo () 'fixnum)

and that got into the environment

the *Lisp compiler wanted to know when it saw 

(*defun foo (x y)
  (declare (type foo x) (type (pvar single-float y))
  ...
  )

what X is.  Knowing that it is a fixnum it could then
optimize certain parallel expressions involving X.


The solution, IIRC, was to hack (redefine) DEFTYPE itself.  And find
ways of figuring out whether something was a DEFSTRUCT,
specific to each implementation.  And other equally vile
hacks.  (This was CLtL I.)

It is, IMHO, a significant failure of ANSI Common Lisp not
to allow itself to be 100% introspective, in the sense of
being able to ask these types of questions and questions about
the environment, and slot names of a defstruct, etc.
From: Kent M Pitman
Subject: Re: Determining whether something is a type specifier
Date: 
Message-ID: <sfwk7e5xmy3.fsf@shell01.TheWorld.com>
······@alum.mit.edu (JP Massar) writes:

> It is, IMHO, a significant failure of ANSI Common Lisp not
> to allow itself to be 100% introspective, in the sense of
> being able to ask these types of questions and questions about
> the environment, and slot names of a defstruct, etc.

I agree that it would be a great thing to add.  I doubt you'll find
many who will disagree.

But I think the word you're looking for is "shortcoming", not "failure".
Nothing about what it does precludes doing what you want, so far as I know.

We tried to provide the introspection tools you're talking about, but
the spec was buggy and we couldn't fix it in the timeframe allotted.
I suppose you can call that a failure, but it suggests a "necessary
failure" as in "the base system was bankrupt and caused it", which was
not so.  We considered it better to leave this facility to implementors
as fodder for layered standards.