2

What is nested quasiquote processing rule in Clojure? I am writing a Lisp variant where symbols are hygienic (auto gensymed). I got single level quasiquote working with auto gensym, but I am not sure when two or more level of nesting gets in.

How to process quasiquotes with hygienic symbols which can be nested?


What's the general rule for expanding? Example:

(quasiquote (quasiquote (unquote (quasiquote (unquote (unquote-splice x))))))
(quasiquote (quasiquote (unquote (quasiquote (unquote (unquote x))))))
(def a '(1 2))

``~`~~a
John Doe
  • 2,225
  • 6
  • 16
  • 44
  • Can you show us an example of what you are trying and where the problems are? – pete23 May 08 '19 at 12:31
  • 1
    Not sure how this works in closure but in scheme and in my lisp I just use syntax (let ((name (gensym))) '(list '(list ,,name))) (comments don't allow escape of backquote so there is quote instead) Check this question [Using two backquotes and commas, Common Lisp](https://stackoverflow.com/q/7549550/387194) – jcubic May 08 '19 at 12:36
  • It's not really clear what your examples have to do with your question. They all trivially resolve to just `a`, and don't involve gensyms at all. – amalloy May 08 '19 at 17:11

1 Answers1

1

I can recommend "Quasiquotation in Lisp" by Allan Bawden:

https://3e8.org/pub/scheme/doc/Quasiquotation%20in%20Lisp%20(Bawden).pdf

I am 95% sure Clojure uses the same rules, but try the examples in Clojure to check.

soegaard
  • 30,661
  • 4
  • 57
  • 106