Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!europa.eng.gtefsd.com!howland.reston.ans.net!news.sprintlink.net!EU.net!uunet!sytex!smcl
From: smcl@sytex.com (Scott McLoughlin)
Subject: DEFTYPE/TYPECASE interaction
Message-ID: <FXaBVc3w165w@sytex.com>
Sender: bbs@sytex.com
Organization: Sytex Access Ltd.
Date: Sat, 5 Nov 1994 09:59:14 GMT
Lines: 48

Howdy,
        I'll try to explain my question better this time
concerning what a compiler is allowed to do with DEFTYPE
types. Can a compiler "inline" the "predicate" of a 
DEFTYPE in, say, a TYPECASE form. CLtL2 is clean on
DECLARE's: if the DEFTYPE type is evaluable at compile
time (no weird SATISFIES predicates, etc.) then the
compiler views the type specifier as gospel. So, 
I imagine, even a "safe" compilation of + on 
arguments (3 x) where we have a (DECLARE (TYPE 
(OR SINGLE-FLOAT FIXNUM) X) could simplify
branch logic for the type dispatch on +. Moreso, I
assume a DEFTYPE'd MYNUMBER as (OR SINGLE-FLOAT FIXNUM)
and subsequent DECLARE (TYPE MYNUMBER X) form would
be treated the same way, even if MYNUMBER was 
DEFTYPE'd "later on" in the program.
        OK. But what about constructs such as
TYPECASE. As a simple example, can I inline
compile DEFTYPE'd FOOTYPE as (MEMBER X Y Z)
in a TYPECASE clause as (CASE #:ARG1021
((X Y Z) T) (T NIL))  or is this not kosher
given that FOOTYPE could be DEFTYPE'd to some
other type spec "later" in the program.
        This ain't a DECLARE issue, but it is
a compile time behavior issue that could
seriously effect the running time of programs
and I can't seem to find treatment of the issue
in CLtL2. It's a big book, maybe I'm missing
something.
        And yes, I'm building a CLtL2 subset
bytecode compiler, so I's gotsta know.
        In general, it really pisses me off
that treatment of the compiler is placed in
the "MISCELLANEOUS FEATURES" section of CLtL2
with other relevant material, such as EVAL-WHEN,
scattered whilly nilly around the rest of the
text. Is there any better, coherent, focused
discussion/explanation/elucidation on how a
compiler must/can behave???????????
        As usual, all advice/comments are very
appreciated. This group has saved my fanny and
hours/days/weeks of rather philosophical 
speculation more than once ;-)

=============================================
Scott McLoughlin
Conscious Computing
=============================================
