Can someone explain Clojure’s unquote-splice in simple terms

clojure

I am banging my head against the wall trying to understand some Clojure macros which use unquote-splice, and I can't seem to find out any clear expanation of whay they are needed. Can anyone explain it to me in dummy terms?

Best Answer

I'm no expert on Clojure, but since it's basically a Lisp, things should be like that unquote-splice is unquote which merges the list to the position where it's used. Difference looks like this:

`(1 2 ~(list 3 4))   =>  (1 2 (3 4))
`(1 2 ~@(list 3 4))  =>  (1 2 3 4)

`  == syntax-quote
~  == unquote
~@ == unquote-splice
Related Topic