I've implemented a modification to the repl that hides stack traces from its output while allowing easy access to the most recent stack trace if it's desired. The idea is borrowed from other repls (Scheme48 and Gambit). Tokens that begin with a comma are treated as commands directly to the repl. The set of commands is extensible if we come up with more useful ones over time.
Here's an example:
Clojure user=> ,? Comma Commands ,s Show the most recent exception's stack trace ,r Show the most recent object returned by read ,e Show the most recent object returned by eval ,h Show this help ,? Show this help user=> (conj '(1 2 3) [4 5 6]) ([4 5 6] 1 2 3) user=> ,r (conj (quote (1 2 3)) [4 5 6]) user=> ,e ([4 5 6] 1 2 3) user=> ,s no exceptions yet! user=> (/ 1 0) java.lang.ArithmeticException: Divide by zero user=> ,s java.lang.ArithmeticException: Divide by zero at clojure.lang.Numbers.divide(Numbers.java:142) at user.eval__2288.invoke(Unknown Source) at clojure.lang.Compiler.eval(Compiler.java:3850) at clojure.lang.Repl.main(Repl.java:95) user=>
I've enclosed a patch to Repl.java. Comments and suggestions are welcome.
--Steve
|
comma-commands.patch
Description: Binary data