I’ve noticed that the Racket macro system seems to have a reputation for
being impenetrably complicated, which I do not fully understand. Hackett
has, indeed, exposed a great deal of complexity, but Hackett is not an
ordinary macro, and I found writing macros with syntax/parse to be quite
pleasant long before I had any real idea of what was happening under the
hood.

My macro style has evolved considerably as I’ve grown accustomed to all
the bells and whistles of syntax/parse, but even when I was beginning,
I never had any real desire to fall back to stx-car, stx-cdr, and
friends. I agree with Matthias that syntax-parse seemed like an obvious,
objective improvement over syntax-case — in the simplest case, if you
avoid all its features, it is identical to syntax-case with slightly
better error messages — and the features it provided were declarative
and easy to use. Things that were obnoxious with syntax-case become
trivial with syntax-parse without needing to learn anything of great
complexity, especially things like ~optional.

My early macro code[1] was certainly not beautiful, tending to use a lot
of define/with-syntax and never really using syntax classes at all.
Still, I think that’s intrinsic to learning any new thing, and I’d
imagine it’s the case for traditional Lisp macros as well. (It’s
unfortunate that things like syntax-local-introduce are necessary for
certain macros, since I found syntax-local-introduce highly confusing
before I understood more about Racket’s hygiene model, but it isn’t
necessary for the vast majority of small macros.)

I agree that it would be nice to have a better introduction to Racket’s
macro-writing facilities that starts with basics and scales to advanced
topics (the syntax-rules/syntax-case/syntax-parse duplicity is
confusing, and a lot of useful utilities are tucked away in the syntax
collection), and maybe the fact that no such resource exists is an
indication that Racket’s macro system is too complicated. But that
conclusion confuses me, since I know myself and others have been able
to pick things up with a little bit of tinkering, so surely that same
learning process can be captured somehow, right? I’m not sure.

Alexis

[1]: 
https://github.com/lexi-lambda/racket-alexis/blob/0268afb688231e0d6d76ded3291538dd5d3db37c/alexis-util/alexis/util/struct.rkt

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to