[plt-scheme] create complex object @ compile time but made available @ run time?

From: Robby Findler (robby at cs.uchicago.edu)
Date: Wed Jun 13 05:28:00 EDT 2007

On 6/13/07, YC <yinso.chen at gmail.com> wrote:
>
> On 6/13/07, Jens Axel Søgaard <jensaxel at soegaard.net> wrote:
> >
> > > The problem here is not that it is a complex object, but that
> > > structure definitions are generative - it would have worked
> > > if you used vectors. Back to the structure problem. To quote the
> > > documentation:
> >
> > >   "Each time a define-struct expression is evaluated, a new structure
> > >    type is created with distinct constructor, predicate, accessor, and
> > >    mutator procedures."
>
> Thanks for the great explanation Jens - this makes great sense - but is
> there a way to prevent struct being evaluated twice, once for (require) and
> once for (require-for-syntax)?  In the example you cited the double eval is
> clearly intended because each define-struct is enclosed lexcially and it
> makes sense that they are different structs (like enclosed lambda &
> variables are different), but IMHO (require-for-syntax) and (require)
> evaluate the same code twice is _surprising_ (I thought it's more like
> "importing" names to the transformation environment) - love to hear your and
> others' take on whether this is expected.

It is expected. For more on the rationale, see this paper:

http://www.cs.utah.edu/plt/publications/macromod.pdf

Robby

Posted on the users mailing list.