Is there a set of exercises I can solve to grok how to use racket macros well?
https://www.greghendershott.com/fear-of-macros/\|https://www.greghendershott.com/fear-of-macros/ is a good starting point, though I recommend syntax/parse after that
umm I gave it a quick glance, I couldn’t find any exercises :confused: For reference, I’ve gone through the plai and racket guide chapters on macros, I just need a concrete set of problems that’ll help me get a hang of how to use macros :slightly_smiling_face:
I’m not sure about exercises. beautiful racket has a bit of macro writing, too, though it’s a slightly different interface. I recommend looking for opportunities to write macros in your code (syntactic abstraction when functional abstraction isn’t enough; mini DSLs; etc.) and treat those as “exercises”
Racket Summer School also has several macro exercises.
A worthwhile exercise is to implement existing constructs using simpler ones. Such as: • implement cond
in terms of if
• implement and
and or
• implement let*
For inspiration: https://schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-10.html#%_sec_7.3
https://docs.racket-lang.org/syntax-parse-example/index.html\|https://docs.racket-lang.org/syntax-parse-example/index.html is a another valuable resource for learning macros
Except that don’t look at how Racket actually implements these macros :laughing: . The context is different.