[plt-scheme] duplicate structure types

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Mar 24 11:50:17 EST 2004

At Wed, 24 Mar 2004 01:48:53 -0500, Doug Orleans wrote:
> If I define a struct type in a module, then both require and
> require-for-syntax that module, then try to access at runtime a struct
> that was created at expansion time, I get an error like this:
>   foo-bar: expects args of type <struct:foo>; given instance of a
>   different <struct:foo>
> How can I make it so only one struct type get created?

You can't.

Arguably, the macro expander should not have let you wrap the structure
instance as a syntax object, preventing you from transferring it across
phases (i.e., preventing 3-D syntax).

In principle, even the pair type at run time is different from the pair
type at compilation time. If you convert `(list 1)' to syntax, then it
becomes a syntax pair, and if you put the syntax pair under quote, then
the run-time result is a different pair (of a different type, in
principle) than the one that existed at compile time.

In other words, the specialness of pairs is not that the type exists
across phases, but that `quote' knows how to construct pair literals at
run time. It doesn't know how to constructs instances of arbitrary
run-time types.


Posted on the users mailing list.