Fork me on GitHub
#planck
<
2017-06-14
>
moxaj19:06:09

@mfikes re ns-resolve: as far as I can tell, it does not handle resolving vars from namespaces which have not been loaded. Trying to eval a (require ...) before the actual eval (which resolves the symbol) does not always work, as in some cases the analyzer complains that the require isn't at top level. Would you say it's safe wrap it with (binding [cljs.analyzer/*allow-ns* true] ...)? At first glance it seems to work ..

mfikes19:06:03

Hmm. I don’t have a strong opinion other than it should strive to mimic Clojure as closely as possible

moxaj19:06:21

I'm not trying to modify ns-resolve

mfikes19:06:04

Ahh. Right. Interesting that you can’t eval a require… you could drop to using cljs.js directly from self hosted to cause a require to occur, I suspect

moxaj19:06:33

yeah, it's strange, if I have say (def x (somehow-resolve 'foo.bar/y)), then the analyzer (`parse`) sees a 'def form, disallows 'ns* forms, and then throws at the 'ns* form

moxaj19:06:49

and yes, currently I use cljs.js directly

mfikes19:06:17

Are you attempting to write a function that will potentially load a namespace as a side effect?

moxaj19:06:11

yes, would that be advised against?

moxaj19:06:41

it would happen at compile time, if that makes a difference

moxaj19:06:18

or maybe it makes it worse 🙂

mfikes19:06:49

I suppose if your code isn’t meant to be portable, it doesn’t really matter (in other words, you wouldn’t expect this code to work in regular JVM ClojureScript)

moxaj19:06:19

I mean it to be portable, and it seems to be working

mfikes19:06:24

Oh. Well, in that case, consider that the ClojureScript compiler loads all namespaces up front as it processes requires. It also looks at the beginning of the file in order to properly figure out a topological sort (especially important if compiling in parallel)

moxaj19:06:16

I'm not sure if that affects me, since this is a compile time construct

moxaj19:06:23

so I'm in clojure land

moxaj19:06:31

with JVM cljs

moxaj19:06:01

anyway, thanks for the directions! I'll do some testing, see how it works out.