Fork me on GitHub
#cljs-dev
<
2017-07-20
>
mfikes13:07:23

I was curious if using dotted symbols (outside of js/) to access nested JavaScript object properties is correct or an abuse. A concrete example is (def x #js {:foo #js {:bar 17}}) followed by evaluating x.foo.bar. This was made to work with https://dev.clojure.org/jira/browse/CLJS-697. Similarly (let [y #js {:foo #js {:bar 17}}] y.foo.bar) works (I suppose we could find the code and or ticket justifying it as well). My takeaway is that perhaps this is legit, and should be documented in the JavaScript interop page as being equally valid to more verbose constructs like (.. x -foo -bar) On the other hand, I suspect that things like #'x.foo.bar result in a working Var, may be simply an unintentional consequence.

anmonteiro15:07:47

@mfikes I think although undocumented nested dotted access is valid and would result in a great amount of breakage if removed

mhuebert16:07:05

Would there be something equivalent to cljs.closure/find-cljs-dependencies that also includes macro namespaces? I’m trying to find a way to build a dependency graph that includes macros, without actually requiring everything into a compiler state.

mhuebert17:07:22

I can currently build this graph by requiring everything into Planck or Lumo and then crawling the compiler state for transitive dependencies, but this is tricky because some namespaces don’t actually run in Planck/Lumo (they require a browser environment), so I had to stub out *eval-fn* with one that doesn’t throw on errors. It feels like there should be a more direct and fast way to figure this stuff out statically.

mhuebert17:07:06

I made a recursive parse-ns fn in Lumo which seemed to work but was rather slow.

thheller20:07:57

@mhuebert anything in particular you want to achieve? shadow-cljs has some functions that might help

mhuebert21:07:42

@thheller still trying to get a better experience for bundling deps for the self-host compiler

mhuebert21:07:04

I’ve had things ‘working’ for several months, but it’s a brittle pipeline, half Clojure script and half in Planck