Fork me on GitHub
#clojure
<
2021-09-03
>
markgdawson06:09:38

Is there a way to get clojure to print more of the stack when the REPL fails to startup? I'm getting "... 38 more" just before the interesting bit! Can I print out the whole thing somehow?

markgdawson06:09:49

I've actually figured out my the problem now. As usual, as soon as I have up and asked about it I spotted it. But still would be useful/ interesting to know for future. 🙂

noisesmith18:09:03

when a repl fails startup, that is almost always because your tools told the repl to pre-load a namespace that was broken

noisesmith18:09:41

if you still have a repl prompt after the error you can use (require 'my.ns :reload-all) to get the error again, and *e will hold the detailed error object

noisesmith18:09:24

you can then edit your code, and repeatedly require / reload the apropriate namespaces until everything loads correctly, without restarting the repl itself

noisesmith18:09:45

as a last resort (eg. if you can't even get a repl prompt) you can start clojure.main , the -main in that ns gives you a very bare bones clojure repl that you can do your require / reload in until things are fixed (you might not even be able to use arrow keys to edit though...)

hiredman06:09:14

https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#printStackTrace-- discusses the "... 38 more" kind of thing, which is feature of printStactrace, so other mechanisms of viewing the stacktrace won't have it. But the elided lines are only removed because they are dupes

markgdawson06:09:14

Thanks @hiredman. That looks useful!!

didibus23:09:46

Why is (first v) slower than (nth v 0) on vectors? Is it doing more dynamic type dispatching? Or does it have some redundant function calls?

didibus23:09:13

Or is it just the conversion to seq that slows it down?

Alex Miller (Clojure team)23:09:40

first is a seq op so you have to get a seq view of the vector

clojure-spin 4
didibus23:09:17

Makes sense, so its the cost of creating the seq object over the vector. Thanks