6 ms·
I'm a Python user and I love Clojure. I guess I missed the Go bus. But there's 2 things about it I'm not too fond of. One is due to it's declarative nature (wh
by john2x 12y ago
I'm a Python user and I love Clojure. I guess I missed the Go bus. But there's 2 things about it I'm not too fond of.
One is due to it's declarative nature (which I love), it's quite difficult to get up to speed with unfamiliar code.
The 2nd is due to it's JVM roots. Those stacktraces, man. And when it happens on an anonymous funtion in a not so documented library, ugh. It's like hitting a brick wall.
The first, I can deal with enough practice and Schema/core.typed. Is there any hope for the stacktraces to improve? How do other JVM based languages fare in this regard?
- calibraxis 12y agoOddly enough I never used this, but maybe named fns might help? (http://clojure.org/special_forms#Special%20Forms--%28fn%20name?%20%28[params*%20]%20exprs*%29+%29 http://clojure.org/special_forms#Special%20Forms--%28fn%20na...) (fn my-name [] (throw (Exception. "boom"))) (Sorry, I don't know Clojure internals well enough to have great answers to your explicit questions.) [Edited: thanks to jerf for pointing out the inconsistency in a term I used.]
- jerf 12y agoNamed... anonymous... functions? Wuzzah fuzzah?
- weavejester 12y agoThey allow you to use recursion without the need for a Y-combinator.
- larholm 12y agoJust like in Javascript.
- awj 12y agoYeah, that's a terminology issue. They mean lexically scoped named functions. Versus the default in Clojure of global or namespace scope.
- emidln 12y agoNamed anonymous functions are there to allow you to call the function recursively while inside it. i.e. (= ((fn factorial [x] (if (<= x 1) 1 (* x (factorial (dec x))))) 5) 120) Note, this isn't run under TCO (see loop/recur).
- ufo 12y agoAlso, in your example, the recursive call is not in tail position. You would first need to rewrite it to use an acumulator parameter.
- seacious 12y agoThere are people working on improving stack traces[1][2], but there is no standard solution yet. [1] https://github.com/AvisoNovate/pretty https://github.com/AvisoNovate/pretty [2] https://github.com/mmcgrana/clj-stacktrace https://github.com/mmcgrana/clj-stacktrace