planck

Planck ClojureScript REPL
slipset 2017-03-28T07:29:34.790514Z

Being a bit nit-picky here...

slipset 2017-03-28T07:30:42.805250Z

cljs.user=> (planck.repl/resolve "does-not-exist")
Could not eval (var "does-not-exist")
Doesn't support namespace: does-not-exist
nil
cljs.user=>

slipset 2017-03-28T07:30:54.807572Z

So of course, I’d like to try/catch this...

slipset 2017-03-28T07:31:37.815860Z

cljs.user=> (try (planck.repl/resolve "does-not-exist") (catch :default e (println "wat")))
Could not eval (var "does-not-exist")
Doesn't support namespace: does-not-exist
nil
cljs.user=>

slipset 2017-03-28T07:32:23.825089Z

reading through the code, I see that this happens because we end up in planck.repl/eval which has the following piece of code

slipset 2017-03-28T07:32:38.828091Z

(if error
           (handle-error error true)

slipset 2017-03-28T07:33:02.832664Z

which kind’a prints the error and retuns nil.

slipset 2017-03-28T07:33:38.839629Z

Which is not always what one would want.

mfikes 2017-03-28T11:13:27.816089Z

@slipset Good catch. https://github.com/mfikes/planck/issues/467

mfikes 2017-03-28T11:47:55.215674Z

Perhaps this is a case of functions assuming their arguments are correct (for perf reasons), and when not, undefined behavior occurs. (FWIW, Planck catches the issue if you instrument 'planck.core/resolve)

mfikes 2017-03-28T11:48:20.220642Z

(`'planck.repl/resolve` is actually a private var)

slipset 2017-03-28T19:51:13.942582Z

I'd be happy if Planck.core/resolve just threw an exception that I could catch.

mfikes 2017-03-28T19:52:59.980954Z

What is resolve supposed to do? I suppose if you try to resolve a symbol that doesn't exist, that kind of stuff is covered. But if you pass in a non-symbol, it is not clear to me that your program is correct.

slipset 2017-03-28T20:08:59.326922Z

I guess I'm good then, since the code from inf-clojure uses read-string.

slipset 2017-03-28T20:10:39.360931Z

(-> "foo" read-string resolve meta :arglist) or some such. On the phone...

slipset 2017-03-28T20:11:12.371959Z

Wrapped in a try/catch for good measure.