planck

Planck ClojureScript REPL
moxaj 2017-06-14T19:40:09.031171Z

@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 ..

mfikes 2017-06-14T19:41:03.049258Z

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

moxaj 2017-06-14T19:41:21.055271Z

I'm not trying to modify ns-resolve

mfikes 2017-06-14T19:43:04.088561Z

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

moxaj 2017-06-14T19:45:33.137098Z

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

moxaj 2017-06-14T19:45:49.142214Z

and yes, currently I use cljs.js directly

mfikes 2017-06-14T19:50:17.229863Z

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

moxaj 2017-06-14T19:51:11.247816Z

yes, would that be advised against?

moxaj 2017-06-14T19:51:41.257414Z

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

moxaj 2017-06-14T19:52:18.269890Z

or maybe it makes it worse 🙂

mfikes 2017-06-14T19:52:49.280611Z

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)

moxaj 2017-06-14T19:53:19.290833Z

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

mfikes 2017-06-14T19:54:24.312778Z

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)

moxaj 2017-06-14T19:55:16.330129Z

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

moxaj 2017-06-14T19:55:23.332588Z

so I'm in clojure land

mfikes 2017-06-14T19:55:30.335108Z

Ahh OK

moxaj 2017-06-14T19:55:31.335533Z

with JVM cljs

moxaj 2017-06-14T19:58:01.386206Z

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

mfikes 2017-06-14T19:58:38.398792Z

👍