where should I look for the implementation of syntax-quote in (self-hosted) CLJS?
@borkdude in tools.reader
thanks!
I recently discovered that syntax-quotes may be nested:
``[x]
now I'm trying to wrap my head around that:
(cljs.core/vec (cljs.core/sequence (cljs.core/concat (cljs.core/list (quote cljs.user/x)))))
hmm second pass shouldn't do anything I'd think? if everything is already namespace qualified it should just return the same result?
@thheller the second one introduces a new level of unquote: https://github.com/borkdude/clj-kondo/issues/648 I've never encountered this before in code, but now someone posted an issue about this at clj-kondo
oh right there is some weirdness .. macros writing macros is confusing as heck 😛
user=>
``foo
Execution error (NoClassDefFoundError) at clojure.main/main (main.java:40).
Could not initialize class clojure.lang.Compiler$CompilerException
:)cljs.user=>
``x
Unexpected error (RangeError) compiling at (<cljs repl>:1).
Maximum call stack size exceeded.
yeah same thing
@borkdude syntax-quote needs to "explode" every sequence literals in order to support unquote-splicing
so each layer of syntax-quote "explodes" more and more sequence literals producing more and more sequence literals
yeah. in a clojure interpreter I wrote I did this using metadata, but same idea. I wasn't aware of the tools.reader impl yet 😕
the tools.reader impl of syntax-quote is mostly a 1:1 reimpl of that in LispReader.java
thanks for the pointers, now I have the proper implementation details I was looking for
Heya, I stumbled upon some suspicious output from the cljs build when testing js engines: https://travis-ci.org/mfikes/clojurescript/builds/613780247#L3156. I dug back to previous builds, and this seems to have been happening for a long while, so probably not a problem? But looks weird so thought I should raise it here.
Looking at .travis.yml
, If it weren’t for the tee
:
jsc builds/out-adv/core-advanced-test.js | tee test-out.txt
this would have returned a non-zero.I think I've seen something similar in the past
I commented about it on a jira ticket but can't find it now... but I also think at the time I didn't really understand what was happening very well
I think the important part was this
Ran 480 tests containing 19679 assertions.
0 failures, 0 errors.
Exception: ReferenceError: Can't find variable: test
builds/out-adv/core-advanced-test.js:7059:516
global code@builds/out-adv/core-advanced-test.js:7091:3
which I think corresponds to a test for https://clojurescript.org/reference/javascript-module-support
Stumbled on this TODO https://github.com/clojure/clojurescript/blob/8f38049d543b04b8da55029f140b6577e3ec245a/src/main/clojure/cljs/closure.clj#L1086 Looks like potential improvement to reduce compilation time?
it's possible but I'm somewhat skeptical much time is lost there
ya that’s what I am referring to
I test stuff like this all the time in Clojure by hardcoding an oracle that knows all the answers for a particular test. just compile something, capture all the inputs/outputs at that point, then hard-code a map in the compiler. diff the times and see if it makes any difference.