Welcome to Racket, Alejandro.

The different Racket macro tools are harder to learn than CL's. But once you invest in learning the Racket ones, in my experience, they feel much more sophisticated than CL's. Macros are easily one of Racket's biggest strengths over other languages.

There are a few different ways to define macros in Racket. The most sophisticated is "syntax-parse", but the documentation is imposing. If you want to start with something sophisticated, but "syntax-parse" is just a little too much, try a "syntax-case" tutorial first.

I recommend ignoring "define-syntax-rule" and "syntax-rules". Those forms are fine for many simple things, but you probably will soon want to do things that those forms make hard to do. So why not just start with "syntax-parse" or "syntax-rules", and then you can learn their features smoothly and incrementally?

One tip for writing macros: make your transformer pattern variables be all-uppercase. This convention makes reading and writing macros much easier for humans, and also less confusing to learn (because people seeing examples are less confused over what is a pattern variable and what is a normal Racket variable).

Neil V.

____________________
 Racket Users list:
 http://lists.racket-lang.org/users

Reply via email to