joshibharathiramana
2021-8-30 10:28:25

Is there a set of exercises I can solve to grok how to use racket macros well?


ben.knoble
2021-8-30 11:47:12

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


joshibharathiramana
2021-8-30 11:59:08

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:




ben.knoble
2021-8-30 13:07:40

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”


sorawee
2021-8-30 13:08:40

Racket Summer School also has several macro exercises.



soegaard2
2021-8-30 13:28:53

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


spdegabrielle
2021-8-30 13:44:20

shu--hung
2021-8-31 03:21:22

Except that don’t look at how Racket actually implements these macros :laughing: . The context is different.