[plt-scheme] define-union

From: Anton van Straaten (anton at appsolutions.com)
Date: Sat Apr 19 14:43:16 EDT 2003

Stephen Bloch wrote:
> Yes, I could easily have written either of those.  But the goal is to
> give students with six weeks of programming experience something as
> closely analogous as possible to define-struct.

I think there's something to be said for giving students tools whose
internals they can relatively easily understand, even if they haven't been
taught the specific details.  The message it sends is "look, you can build
and understand these constructs yourself, quickly, easily, and
understandably".  It gives a sense of empowerment, and may help foster a
tool-building mindset.

You originally mentioned wanting to use define-syntax for this, but with the
more demanding spec, you won't get away with syntax-rules.  You'll need to
use syntax-case, and it won't be as small or simple.  For a six-week
student, the result will be much more of a black box: a magical construct
they're being supplied with, whose ultimate conceptual simplicity is
obscured by its implementation.  It's less transparent, and the students'
understanding of the operation in question may be affected by this.  "Pay no
attention to the macro-implementing wizard behind the curtain!"

I hope you'll forgive me for pointing this out, but the fact that you're
asking for help in implementing your define-union spec, rather illustrates
my point.  The choice is one between giving students a tool that they could
implement themselves with a little assistance, vs. one which their teacher
wants assistance in implementing.

Of course, add a big "IMO" to everything above, and it's meant


Posted on the users mailing list.