Self-host: Protocol prefixing broken for three- (or more) segment namespaces
Description
There is a protocol-prefix method in core.cljc (and also, in compiler.cljc) which employs .replace. In Java, this ends up replacing all occurrences of the old character with the new character, while in JavaScript, the same call only replaces the first character.
This results in breakage if attempting to make use of protocols in three- (or more) segment namespaces under self-host as the resulting emitted JavaScript will have some . characters in the namespace not converted to $ characters as desired.
Take for example the following REPL interaction
This will work fine in, say, noderepljs, where a line like the following appears in the emitted JavaScript:
but in a self-host REPL, this will cause JavaScript to be emitted that looks like this:
There is a
protocol-prefix
method incore.cljc
(and also, incompiler.cljc
) which employs.replace
. In Java, this ends up replacing all occurrences of the old character with the new character, while in JavaScript, the same call only replaces the first character.This results in breakage if attempting to make use of protocols in three- (or more) segment namespaces under self-host as the resulting emitted JavaScript will have some
.
characters in the namespace not converted to$
characters as desired.Take for example the following REPL interaction
This will work fine in, say,
noderepljs
, where a line like the following appears in the emitted JavaScript:but in a self-host REPL, this will cause JavaScript to be emitted that looks like this:
which will fail to be evaluated properly.