Fork me on GitHub
#cljs-dev
<
2019-12-13
>
borkdude10:12:20

where should I look for the implementation of syntax-quote in (self-hosted) CLJS?

borkdude11:12:16

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)))))

thheller11:12:11

hmm second pass shouldn't do anything I'd think? if everything is already namespace qualified it should just return the same result?

borkdude11:12:03

@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

thheller11:12:37

oh right there is some weirdness .. macros writing macros is confusing as heck 😛

😂 4
bronsa11:12:41

user=> 
``foo
Execution error (NoClassDefFoundError) at clojure.main/main (main.java:40).
Could not initialize class clojure.lang.Compiler$CompilerException
:)

borkdude11:12:50

cljs.user=> 
``x
Unexpected error (RangeError) compiling at (<cljs repl>:1).
Maximum call stack size exceeded.

bronsa11:12:00

yeah same thing

bronsa11:12:05

@borkdude syntax-quote needs to "explode" every sequence literals in order to support unquote-splicing

❤️ 8
bronsa11:12:18

so each layer of syntax-quote "explodes" more and more sequence literals producing more and more sequence literals

borkdude11:12:34

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 😕

bronsa11:12:19

the tools.reader impl of syntax-quote is mostly a 1:1 reimpl of that in LispReader.java

borkdude11:12:34

thanks for the pointers, now I have the proper implementation details I was looking for

lread16:12:35

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.

Filipe Silva17:12:51

I think I've seen something similar in the past

Filipe Silva17:12:45

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

Filipe Silva17:12:31

I think the important part was this

Filipe Silva17:12:39

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

lread20:12:06

ya that’s what I am referring to

dnolen19:12:06

it's possible but I'm somewhat skeptical much time is lost there

Alex Miller (Clojure team)21:12:00

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.