Self-host: Don't resolve unqualified symbols / keywords with $macros
Description
Background: Since, in self-hosted ClojureScript, macro namespaces are compiled as ClojureScript, a $macros suffix is appended to macros namespace names in order to differentiate them from same-named runtime namespaces. As a concrete example: The foo.core runtime namespace will be processed normally, but the same, when compiled as a macro namespace is internally renamed to be foo.core$macros.
A consequence is that the internal $macros suffix surfaces in a few places where it is undesired. Specifically this ticket focuses on the cases of unqualified symbols subject to syntax-quote resolution and namespaced keywords that use the :: construct (as in ::bar). When these are used in macro namespaces, and then compiled with bootstrapped ClojureScript, a symbol like `baz would turn in to foo.core$macros/baz, and a keyword like ::bar would turn in to :foo.core$macros/bar.
In the case of symbols, it might be the case that the user wanted the symbol to refer to a var in the runtime namespace, in which case foo.core/baz is desired. And, even if the desire was that it end up referring to a macro named baz, then foo.core/baz works just fine. To achieve this, when porting regular ClojureScript code to be compatible with bootstrapped ClojureScript, one common pattern is the need to qualify symbols inside of syntax-quote scope so that they don't end up with the $macros suffix.
The same, parallel arguments essentially go for keywords: You want ::bar to turn into :foo.core/bar in both JVM and bootstrapped ClojureScript, and today, to achieve that, you must qualify those kinds of keywords when they appear in macros namespaces.
This ticket asks that when unqualified symbols in syntax quote are resolved and when the analogous thing occurs for keywords, that the $macros suffix be avoided as experience has shown now that it is practically always not the thing that you want (and perhaps also not correct from the desired language semantics.)
Background: Since, in self-hosted ClojureScript, macro namespaces are compiled as ClojureScript, a
$macros
suffix is appended to macros namespace names in order to differentiate them from same-named runtime namespaces. As a concrete example: Thefoo.core
runtime namespace will be processed normally, but the same, when compiled as a macro namespace is internally renamed to befoo.core$macros
.A consequence is that the internal
$macros
suffix surfaces in a few places where it is undesired. Specifically this ticket focuses on the cases of unqualified symbols subject to syntax-quote resolution and namespaced keywords that use the::
construct (as in::bar
). When these are used in macro namespaces, and then compiled with bootstrapped ClojureScript, a symbol like`baz
would turn in tofoo.core$macros/baz
, and a keyword like::bar
would turn in to:foo.core$macros/bar
.In the case of symbols, it might be the case that the user wanted the symbol to refer to a var in the runtime namespace, in which case
foo.core/baz
is desired. And, even if the desire was that it end up referring to a macro namedbaz
, thenfoo.core/baz
works just fine. To achieve this, when porting regular ClojureScript code to be compatible with bootstrapped ClojureScript, one common pattern is the need to qualify symbols inside of syntax-quote scope so that they don't end up with the$macros
suffix.The same, parallel arguments essentially go for keywords: You want
::bar
to turn into:foo.core/bar
in both JVM and bootstrapped ClojureScript, and today, to achieve that, you must qualify those kinds of keywords when they appear in macros namespaces.This ticket asks that when unqualified symbols in syntax quote are resolved and when the analogous thing occurs for keywords, that the
$macros
suffix be avoided as experience has shown now that it is practically always not the thing that you want (and perhaps also not correct from the desired language semantics.)