cljs / api

ClojureScript API parser
http://cljs.github.io/api/
MIT License
193 stars 23 forks source link

syntax-quotes work fine outside macros (except syntax-quoted symbols inside read-string) #180

Closed shaunlebron closed 2 years ago

shaunlebron commented 5 years ago

Saying that syntax-quotes are only intended inside macros is 1) not technically true, and 2) fostering a misunderstanding in how they work. While it is true that they are not normally used outside macros, I would rather say it that way instead of implying that they cannot.

Based on an example by Matt Huebert:

code>`[~@x]</code is equivalent and compiles to (vec (sequence (concat x)))

And an example by Nicola Mometto:

`[~@(when x whatever) 1 2 ] is literally a shortrand for typing (vec (concat (when x whatever) (list 1) (list 2)))

slack conversation

matt’s question followed by nicola’s explanation for full context

Screen Shot 2019-03-27 at 11 43 56 AM Screen Shot 2019-03-27 at 11 44 10 AM Screen Shot 2019-03-27 at 11 44 29 AM Screen Shot 2019-03-27 at 11 44 39 AM Screen Shot 2019-03-27 at 11 44 51 AM Screen Shot 2019-03-27 at 11 45 07 AM Screen Shot 2019-03-27 at 11 45 17 AM
shaunlebron commented 2 years ago

finally fixed this entry! Thanks @bronsa and @mhuebert!

http://cljs.github.io/api/syntax/syntax-quote

CleanShot 2022-09-30 at 18 59 46@2x CleanShot 2022-09-30 at 18 59 55@2x