Closed Mercerenies closed 3 years ago
As we discovered (the hard way) with macrolet
, implementing this functionality will require some care, as the IR layer is not currently equipped to keep track of local variables in the value namespace, and it would be responsible for doing so in this case.
Remember that symbol-macrolet
is not a simple walk down the tree. Like ordinary macros, symbol macros should only expand when the symbol is used in an expression-like or declaration-like context. Incidentally, unlike normal macros, I don't think symbol macros can ever reasonably be bound in a scope where a symbol could expand in a declaration context, so we may only have to worry about expression context.
As of 7dd8e80, define-symbol-macro
is implemented.
This issue is still open, as symbol-macrolet
is not implemented yet.
Additionally, symbol macros forbid anything in the function namespace from sharing a name with them. This is arguably acceptable behavior, provided we document it, but I'll open an issue for it nonetheless (#51)
Note that symbol macros cannot be used in declaration context as of now. They can only be used in situations where an expression is expected and they can only produce expression results, so a symbol macro that produces, for instance, a defn
form, would be useless. It is probably not too difficult to fix this, but I frankly fail to see the use case.
symbol-macrolet
works likemacrolet
(#19) but operates on symbols in the value namespace, rather than transforming function-like forms as a global macro would.