[racket-dev] Access to the structure internal API within define-struct's body

From: Danny Yoo (dyoo at cs.wpi.edu)
Date: Thu Jul 7 16:56:22 EDT 2011

> I built something like this as a toy for *SL a while back, a throw-away prototype. I decided to set up a different property, not to use the procedure property. Any reason for the preference?

It's not an important preference.  Using a separate structure property
would have worked too for this example.

I wanted a small, quick example that showed why I'd like to introduce
those two syntax parameters (struct-field-ref, struct-field-set!) for
use with define-struct definitions.  Without it, it's too tempting to
try to use datum->syntax or try to fiddle with the struct-type, with
messy results that either involve unhygienic operations or the
structure type inspector.

In fact, the undergrad I'm working with during the summer hit several
of these snags.  We tried using datum->syntax, and ran into a wall
with silly hygiene issues.  We ended up resorting to the
unsafe-struct-ref approach in my previous email.  If there's an
alternative approach to the task that's clear and obvious, I'd love to
change ours to use it.

My proposed additional syntax parameters will allow those who care to
be able to access the bindings from the internal use of
make-struct-type, and I think that's ok.  But I want to see if this is
something that other people agree is a nice thing to have.

Posted on the dev mailing list.