cljs-dev

ClojureScript compiler & std lib dev, https://clojurescript.org/community/dev
borkdude 2019-12-13T10:46:20.489800Z

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

thheller 2019-12-13T10:59:53.490Z

@borkdude in tools.reader

borkdude 2019-12-13T11:00:59.490300Z

thanks!

borkdude 2019-12-13T11:02:16.491100Z

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

thheller 2019-12-13T11:03:11.491800Z

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

borkdude 2019-12-13T11:04:03.492800Z

@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

thheller 2019-12-13T11:05:37.494100Z

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

😂 1
bronsa 2019-12-13T11:05:41.494300Z

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

borkdude 2019-12-13T11:06:50.495400Z

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

bronsa 2019-12-13T11:07:00.495700Z

yeah same thing

bronsa 2019-12-13T11:07:05.495900Z

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

❤️ 2
bronsa 2019-12-13T11:07:18.496400Z

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

borkdude 2019-12-13T11:07:34.497Z

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 😕

bronsa 2019-12-13T11:08:19.497900Z

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

borkdude 2019-12-13T11:08:34.498200Z

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

lread 2019-12-13T16:38:35.006300Z

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 Silva 2019-12-13T17:44:51.006800Z

I think I've seen something similar in the past

Filipe Silva 2019-12-13T17:48:45.007300Z

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 Silva 2019-12-13T17:49:31.007500Z

I think the important part was this

Filipe Silva 2019-12-13T17:49:39.007900Z

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

Filipe Silva 2019-12-13T17:50:46.008300Z

which I think corresponds to a test for https://clojurescript.org/reference/javascript-module-support

2019-12-13T19:52:55.009400Z

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?

1
dnolen 2019-12-13T19:59:06.009900Z

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

lread 2019-12-13T20:27:06.010500Z

ya that’s what I am referring to

alexmiller 2019-12-13T21:39:00.012300Z

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.