~technomancy/fennel#59: 
Can't nest unquote

Nested quasiquotes should increase amount of allowed unquotes:

>> (macro m [] (let [name1 'x name2 'y] `(a `(b ,,name1 ,',name2 d) e)))
Compile error: Compile error in unknown:5
  unknown global in strict mode: unquote

* Try looking to see if there's a typo.
* Try using the _G table instead, eg. _G.unquote if you really want a global.
* Try moving this code to somewhere that unquote is in scope.
* Try binding unquote as a local in the scope of this code.

This, with some alterations, works in Scheme and in Clojure.

Status
RESOLVED BY_DESIGN
Submitter
~andreyorst
Assigned to
No-one
Submitted
2 months ago
Updated
27 days ago
Labels
bug macros

~technomancy a month ago

Unquote should only work inside quasiquote.

There's no such distinction in Fennel; we only have one quote. ' is an undocumented alias for backtick.

Nested quasiquotes should increase amount of allowed unquotes

Yeah, this is definitely a bug we should fix.

Unquoting non-existend variable fails silently:

This is unrelated to unquote; it's a problem that globals-checking can get disabled in compiler scope due to the compiler sandbox. I'll create a separate issue for this.

~technomancy referenced this from #62 a month ago

~technomancy REPORTED BY_DESIGN 27 days ago

Thinking about this further, it shouldn't be expected that a nested quote would work. It works in Clojure and Scheme because lists exist at runtime, but that's not true of Fennel. Quote can only be used inside another quote if there's an unquote in between:

(macro m [name] `(print ,[`(table.concat ,name)]))
(macrodebug (m x)) ; -> (print [(table.concat x)])

~andreyorst 27 days ago

It works in Clojure and Scheme because lists exist at runtime, but that's not true of Fennel.

Oh, right, I forgot about that

Register here or Log in to comment, or comment via email.