From: pete kirkham
Subject: Expected type of value of form
Date: 
Message-ID: <3f2bbaaf$0$961$cc9e4d1f@news.dial.pipex.com>
Is there a standard way to get the type of the expected value of a form 
without evaluating it?

eg

(declaim (type fixum *count*))
=>T

(type-of '*count*)
=> SYMBOL

(type-of *count*)
=> [condition type: UNBOUND-VARIABLE]

(typep *count* 'fixnum)
=> NIL

(typep *count* fixnum)
=> [condition type: UNBOUND-VARIABLE]

what I want is:

(expected-type-of '*count*)
=> FIXNUM

Is there a standard place where type declarions are put? In allegro

(get '*count* 'EXCL::.TYPE.)
=> (INTEGER -536870912 536870911)

but I think that is implementation specific, and only work on symbols.

I don't need to know how to write such a function, but was wondering if 
it already exists.


Pete

From: Paul F. Dietz
Subject: Re: Expected type of value of form
Date: 
Message-ID: <AU-dnUJ6-OVXILaiU-KYvg@dls.net>
pete kirkham wrote:

> Is there a standard way to get the type of the expected value of a form 
> without evaluating it?

No.

	Paul
From: Kenny Tilton
Subject: Re: Expected type of value of form
Date: 
Message-ID: <3F2BBE96.30904@nyc.rr.com>
pete kirkham wrote:
> what I want is:
> 
> (expected-type-of '*count*)
> => FIXNUM

That is not the Lisp Way, you know. Why do you want that? Maybe there is 
a Lispier way.

-- 

  kenny tilton
  clinisys, inc
  http://www.tilton-technology.com/
  ---------------------------------------------------------------
"Everything is a cell." -- Alan Kay
From: pete kirkham
Subject: Re: Expected type of value of form
Date: 
Message-ID: <3f2bc843$0$959$cc9e4d1f@news.dial.pipex.com>
Kenny Tilton wrote:
> pete kirkham wrote:
> 
>> what I want is:
>>
>> (expected-type-of '*count*)
>> => FIXNUM
> 
> 
> That is not the Lisp Way, you know. Why do you want that?

I writing a compiler for a subset of lisp to use as a scripting language 
in a Java bytecode manipulation tool. It would be more efficient to use 
the most specific type, eg a Java primative int for something declare to 
be fixum, for the variables in the compiled version of a given form.

CL defines standard means of setting type information for variables and 
functions; if there is a standard/common means of extracting it, then 
it'd be nice to support it.

Or are the type and ftype declarations write only to anyone not privy to 
the compiler implementation? (that would be OK too)


Pete
From: Kenny Tilton
Subject: Re: Expected type of value of form
Date: 
Message-ID: <3F2BD296.5090505@nyc.rr.com>
pete kirkham wrote:
> Kenny Tilton wrote:
> 
>> pete kirkham wrote:
>>
>>> what I want is:
>>>
>>> (expected-type-of '*count*)
>>> => FIXNUM
>>
>>
>>
>> That is not the Lisp Way, you know. Why do you want that?
> 
> 
> I writing a compiler for a subset of lisp to use as a scripting language 
> in a Java bytecode manipulation tool. 

oh. never mind. :) I'll let folks who know these things answer. But you 
said "standard" and the upshot of declaim is implementation-dependent 
according to the standard.

Did you really want to do the declaim? Or were you just going to use 
that as a way to store the info? If the latter, seems to me:

(fixnum *count*) or (static fixnum *count*)

...translated suitably by your own macros are more readable, they're 
portable, and you can stash as much info as you like in them, including 
even a declaim.

they are better self-documenting, too, since at a glance someone can see 
something special is going on. making it (jdecl fixnum *count*) would be 
even clearer.

jes thnkin out loud. i'll go back to my mindlessly spinning (RoboCup!) 
goalie now. :)



-- 

  kenny tilton
  clinisys, inc
  http://www.tilton-technology.com/
  ---------------------------------------------------------------
"Everything is a cell." -- Alan Kay
From: pete kirkham
Subject: Re: Expected type of value of form
Date: 
Message-ID: <3f2bdc97$0$961$cc9e4d1f@news.dial.pipex.com>
Kenny Tilton wrote:
> Did you really want to do the declaim? Or were you just going to use 
> that as a way to store the info? 

That's how it's done in 'ANSI common lisp', so I assumed it'd be familiar.

I assumed that it would be implementation dependant, but didn't know if 
there's a commonly accepted means for compiler introspection like MOP is 
for introspection of the object model.

Cheers,

Pete
From: Alexey Dejneka
Subject: Re: Expected type of value of form
Date: 
Message-ID: <m3ptjnhp2z.fsf@comail.ru>
pete kirkham <············@cafemosaic.co.uk> writes:

> Is there a standard way to get the type of the expected value of a
> form without evaluating it?

No.

> Is there a standard place where type declarions are put? In allegro
> 
> (get '*count* 'EXCL::.TYPE.)
> => (INTEGER -536870912 536870911)

By the standard - no. But look at "SYNTACTIC-ENVIRONMENT-ACCESS" issue
in CLHS
(http://www.lispworks.com/reference/HyperSpec/Issues/iss343_w.htm) or
Macros->Environments section in CLtL2,
your implementation may support it.

-- 
Regards,
Alexey Dejneka

"Alas, the spheres of truth are less transparent than those of
illusion." -- L.E.J. Brouwer
From: pete kirkham
Subject: Re: Expected type of value of form
Date: 
Message-ID: <3f2eca23$0$958$cc9e4d1f@news.dial.pipex.com>
Alexey Dejneka wrote:
> By the standard - no. But look at "SYNTACTIC-ENVIRONMENT-ACCESS" issue
> in CLHS
> (http://www.lispworks.com/reference/HyperSpec/Issues/iss343_w.htm) or
> Macros->Environments section in CLtL2,
> your implementation may support it.
> 

Thanks,

Pete