[plt-scheme] Obtaining hierarchal info about structs

From: Bruce Hauman (bhauman at cs.wcu.edu)
Date: Fri Apr 25 11:19:22 EDT 2003

On Fri, 25 Apr 2003, Matthew Flatt wrote:

> At Fri, 25 Apr 2003 09:26:32 -0400 (EDT), Bruce Hauman wrote:
> > I am just trying to get a list of super types for a structure
> > at expansion time.
> >
> > I don't know if this is possible but it seems like it should be
> > given the supplied functions syntax-local-value and struct-type-info.
> The problem is that the struct type descriptor doesn't exist at
> expansion time.
> > When syntax-local-value is applied to the syntax of a struct-name it
> > returns a list of information about that struct.
> But this information says nothing about the super-type part of the
> declaration --- and that's the source of the problem, I think.
> Given your example:
>  (define-struct universe () (make-inspector))
>  (define-struct (solar-sys universe) () (make-inspector))
> the expansion-time information bound to `solar-sys' should include that
> it's derived from `universe'. There still aren't any struct types at
> this point; it's just information about the declaration. But I think
> that's all you need.
> In particular, you can statically assume that `(solar-sys? x)' implies
> `(universe? x)' for the `universe?' and `solar-sys?' bound by the above
> declarations.
> Does that sound right?
> Matthew

Yes, that sounds right.  Does this mean you are going to make that
information available through syntax-local-value?  Or am I missing

If it is made available, will it be possible to traverse up the
chain of super-types at expansion time?  This will be independant of
whether a struct is declared to be "transparent to peer code"?

Also, I wanted to state that this information will allow match.ss to
compile match expressions with structures in them much more efficiently.

The number of nodes generated (roughly the number of if exps) for
the problematic Dromedary match expression was around 7500.  By assuming
that all structure types are disjoint the number of nodes was reduced to
48.  A dramatic improvement, except that I can't assume that all
structures are disjoint.

Thanks again,
Bruce Hauman

Posted on the users mailing list.