[plt-scheme] Obtaining hierarchal info about structs

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Apr 25 09:57:11 EDT 2003

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



Posted on the users mailing list.