Hacker News new | past | comments | ask | show | jobs | submit login

Clojure spits out Java stack trace if you make syntax error. It's equivalent of Python barfing segfault when you put tab in the wrong place.



This doesn't happen with the normal REPL (or invoking with clj -X) after a couple of first examples that came to mind:

  user=> (defn foo [[a b] (+ a b))
  Syntax error reading source at (REPL:14:26).
  Unmatched delimiter: )
  user=> (defn foo [a b] a/b)
  Syntax error compiling at (REPL:1:1).
  No such namespace: a
  user=>
It will give you a stack trace of the compiler when asked following a syntax error though, with a disclaimer not to confuse it with your own code:

  user=> (pst)
  Note: The following stack trace applies to the reader or   compiler, your code was not executed.
  CompilerException Syntax error compiling at (1:1). #:clojure.error{:phase :compile-syntax-check, :line 1, :column 1, :source "NO_SOURCE_PATH"}
 clojure.lang.Compiler.analyze (Compiler.java:6808)
 clojure.lang.Compiler.analyze (Compiler.java:6745)
  [...]
Possibly you were using tooling that always tried to present the stack trace without discerning between kinds of evaluation errors?


That does look considerably better than what I used to see.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: