sci

https://github.com/babashka/SCI - also see #babashka and #nbb
2020-08-18T05:42:37.469900Z

I've got an issue with clojurescript sci, I'm trying to use d3.js as a :binding in a function that sci compiled. With d3.js it's normal to first grab a bunch of dom elements that you want to use and then apply some operations e.g.

(-> (.select d3 "body")
    (.append "svg")
    (.style  "z-index" 30)
    (.style  "position" "absolute")
    (.style  "background" "tomato")
    (.append "g")
    (.call (-> (.brushX d3)
               (.extent #js [#js [0 0] #js [400 200]])
               (.on "brush" (fn [e] (js/console.log "brush" e)))
               (.on "end" (fn [e] (js/console.log "ended brushing" e))))))
would select the body, append an svg with a brush element with listeners etc. However as soon as .append gets called on the selection sci gives an error with:
this.select is not a function [at line 1, column 62]
Which is this source https://github.com/d3/d3-selection/blob/master/src/selection/append.js#L5

2020-08-18T05:46:06.470900Z

I'm wondering what is going wrong, and if there's maybe a config option to fix it.

borkdude 2020-08-18T06:57:42.474100Z

@bbss there is a fn? check in interpreter.cljc before the function gets called. Maybe sci is overly protective there. You could try to disable that check. Iā€™m curious what the type of this thing is you are calling.

2020-08-18T06:58:29.474300Z

okay, checking interpreter.cljc

2020-08-18T07:00:00.475600Z

ah, that error message is not the same as "Cannot call x as function"

borkdude 2020-08-18T07:01:13.477Z

Ok, can you do more digging and make a small repro? Could also be a bug in the JS interop code

2020-08-18T07:02:15.477200Z

okay, will do

2020-08-18T08:38:18.481300Z

I was on 0.0.13-alpha.13 , updated to latest git version, fixed some warnings about .- style property access by replacing it for goog.object/get with reader :cljs conditionals in impl/vars.cljc and my problem is gone. Turns out just updating to latest version also works. Those warnings are probably just because I was using :local/root and shadow-cljs warns more strictly for that.

2020-08-18T08:39:04.481800Z

sci remains awesome as ever šŸ™‚

borkdude 2020-08-18T08:41:38.482Z

ok, so no changes needed, also not for the goog.object/get thing?

2020-08-18T08:57:25.484100Z

well, I'm not sure why those warnings started happening, I think a newer version of clojurescript/closure compiler started be more restrictive in property access. But I don't know if that's necessary to fix and if the goog.object/get fix is the way to go. If it comes up for anyone give me a ping and I'll push what fixed it for me. Not much code.