[plt-scheme] define-struct-for-syntax?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sun Jul 16 13:38:41 EDT 2006

At Sat, 15 Jul 2006 12:37:04 -0400, "Kimberley Burchett" wrote:
> Is there any way to define a struct in the transformer environment
> other than putting it in a separate module and then
> require-for-syntax'ing that module?  I tried wrapping the
> define-struct in a begin-for-syntax, but got an error saying "syntax
> definitions not allowed within begin-for-syntax".
> The separate module hack works, obviously, but it makes me sad.

In case the problem is not clear, it's that `define-struct' expands to
`define-syntax' to bind the struct type name, and MzScheme has no
`define-syntax-for-syntax' to accommodate the binding.

For now, I don't have a solution other than Noel's. I sometimes just
use `define-values' and `make-struct-type' directly. Most often, I
create another module (as you say).

We'd like to generalize the module+macro system to support arbitrary
kinds of definitions at arbitrary phases, but I don't think that will
happen very soon.


Posted on the users mailing list.