Closed moxuze closed 1 year ago
(local t (merge { :a "A" } (b)))
It seems you're expecting macros to be expanded from the inside out, but they are actually expanded from the outside in. The merge
macro cannot see the expansion of b
; it just sees the call to b
as a literal list instead, and uses pairs
to loop over that list, resulting in an attempt to merge with {1 b}
which cannot compile.
The error message is confusing, but I can't think of a way to improve it here.
(local t (merge { :a "A" } b))
The strange results here come from the fact that symbols are tables, even if they don't look like it. So your merge
macro is looping over the fields of the symbol, which include source data about where the symbol was read from.
Thank you, that is clear. I find that macroexpand
can solve my demand although its document is somewhat ambiguous.
If you have suggestions for how to make it clearer, please let me know.
Codes Here:
Is that a bug of Fennel? I really love this language, thanks for discussion.