3 ms·
Can you point out something that talks about macros in Clojure vs Common Lisp, or SBCL in particular?
by DigitalJack 9y ago
Can you point out something that talks about macros in Clojure vs Common Lisp, or SBCL in particular?
- spdegabrielle 9y agoSee https://clojure.org/about/lisp https://clojure.org/about/lisp for the relationship between clojure and other lisps. Variable capture is a problem with lisp macros that lisp and clojure programmers have tools and strategies to manage. A number or languages use hygienic macros to avoid the variable capture problem: Scheme, Racket, Dylan, Elixir, Rust, Julia & Perl 6 (which has hygienic AND unhygienic macros) Racket has more advanced macro facilities specifically aimed at making new languages languages and DSLs. Syntax-parse is very interesting in how it addresses the problem of error reporting with macros.
- shakna 9y ago> Scheme, Racket, Dylan, Elixir, Rust, Julia & Perl 6 (which has hygienic AND unhygienic macros) Just want to add that Racket, and most Schemes also support both hygienic and unhygienic macros, through defmacro. [0][1] Though, their use is heavily discouraged. (And it may be worth pointing out that Guile's defmacro is actually implemented using syntax-case, which is hygienic most of the time, but flexible enough to let you do madcap things. [2]). [0] https://docs.racket-lang.org/compatibility/defmacro.html https://docs.racket-lang.org/compatibility/defmacro.html [1] https://www.gnu.org/software/guile/manual/html_node/Defmacros.html https://www.gnu.org/software/guile/manual/html_node/Defmacro... [2] http://stackoverflow.com/a/19666120 http://stackoverflow.com/a/19666120
- KirinDave 9y agoRacket has hygenic template macros, which are quite nice. Common Lisp offers a whole bunch of machinery around macros and more types of macros (most famously symbol macros). Clojure picks the worst of all worlds by making reduced-power backtick macros, not stack tracing the macro output on failures, and then having a culture that discourages the use of macros.
- lemming 9y agoDo you know of any template based macro systems which are more powerful than syntax-rules, but without going to the other extreme of full turing completeness? As I understand it, syntax-rules doesn't even let you concatenate strings to create new identifiers - everything in the output must come verbatim from the input or the template.