This is an excellent explanation. Thanks. I'd like to add a little-understood that Lisp-style macros as found in Common Lisp and Clojure are LESS expressive than Racket macros.
In essence, Racket (and Scheme) chose to use a data structure called SYNTAX instead of S-EXPRESSION but one can argue that the former is 'just' a generalization of the latter. (Plus we made it an 'abstract' type instead of a transparent one so that the expander can preserve a large number of invariants -- which programmers usually lose track off.) -- Matthias On Jul 14, 2011, at 7:35 AM, Thomas Chust wrote: > Markku Rontu wrote: >> [...] >> On the topic of macros, I find it a bit confusing that to metaprogram in >> Racket, I must use such a different language of macros (with >> syntax-rules et al.), instead of being able to manipulate common data >> structures with plain old Racket functions. >> [...] > > Hello, > > this is not really true. The domain specific languages of syntax-rules > and syntax-case macro transformers exist purely for your convenience. > You can always manipulate syntax objects directly, all the necessary > procedures are available and documented in section 11 of the Racket > reference manual. > >> [...] >> The approach in Clojure, >> that the code is just a common data structure, easily manipulatable with >> Clojure code, is intriguing. >> [...] > > The approach taken by Clojure and Common Lisp looks simple but lacks > support for hygienic macros and is therefore error prone and actually > not at all simple, if not impossible, to use correctly. > > While Clojure *mitigates* the problems of non-hygienic macros using > namespaces and a shorthand syntax for freshly generated identifiers, it > doesn't *solve* the problems. Racket's macro system, on the other hand, > does solve the problems and since that involves some heavy lifting, it > may seem more complicated at first glance. > > Ciao, > Thomas > > > -- > When C++ is your hammer, every problem looks like your thumb. > _________________________________________________ > For list-related administrative tasks: > http://lists.racket-lang.org/listinfo/users _________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users