#clojure logs

2008-05-17

09:19asbjxrnIs it possible to have clojure print what it is that raises a NullPointerException when it happens?
11:52rhickeyasbjxrn: what do you mean by what it is - something other than what's in the stack trace?
11:53asbjxrnSome additional information to what is in the trace, like which symbol was a nullpointer.
11:53asbjxrnIf that makes sense...
11:54asbjxrnI'm not sure if it is possible as I guess this may happen in the jvm, and outside clojures control or something.
12:07rhickeyright
12:19asbjxrnHmm. Of course, it might not be a symbol that is null. : (somefunction (someotherfunction thatreturnsnull))
12:20rhickeyI'm afraid the stack trace is all Clojure can do
12:21asbjxrnok.
12:24asbjxrnI must say that the (lispworks/slime) debugger is something I miss when playing with clojure. Being able to go in and inspect the values etc. at the time of the error is nice.
12:26asbjxrnI'm just using the clojure-mode in emacs. Do you know if eclipse/enclojure/swank is able to do some more inspector-like things when an error occurs?
12:26rhickeyIn a native Java debugger that supports Clojure, you have call frames, local variables etc. It is unlikely that any emacs variant will ever do as well for Clojure
12:27asbjxrnYou were using emacs in the screencasts is that still the case?
12:29rhickeyfor editing, but have no expectations of debugging there. Java bytecode debugging is the only way you are going to see Java calls on the stack etc, and unlike most Lisps, Clojure doesn't otherwise instrument its code or have hooks, as they are not needed since it supports the standard bytecode debug API.
12:30rhickeyYou can attach a debugger to the Clojure instance launched by emacs
16:31jonathan___Hey Rich, do I need to do anything special to deal with nested classes like DataLine.Info?
16:43wabashrhickey: Hey, Rich. I've got a question for you about tail recursion.
16:50jonathan___ok ansered: The real JVM name for java.nio.channels.FileChannel.MapMode is
16:50jonathan___java.nio.channels.FileChannel$MapMode - if you use that it will work.
16:50jonathan___Ditto any other nested classes.
16:50jonathan___Rich
17:18rhickeyhere
17:18wabashhi rhickey
17:19rhickeyhi
17:20wabashI know Clojure can't do tail recursion optimization. It's because of the JVM, right?
17:20rhickeyright
17:21wabash(I'm still a newbie)... In CL or Scheme interpreters, the interpreter sees that the function does a tail call and then does this optimization automatically, correct?
17:21rhickeyonly Scheme guarantees this, and some implementations punt
17:21wabashpunt?
17:22rhickeydon't
17:23wabashI see. In an optimization, does the interpreter basically go into a loop, keeping the code in the same place in memory, never push on the stack, and simply update the arguments as if they were variables?
17:24rhickeyit clears the stack frame of the caller then jumps, so the call frames don't build up
17:26wabashjumps back to the beginning of the frame?
17:27rhickeyno, the next call. TCO means when foo calls bar in tail position, bar's return value is foo's return value and foo's stack frame is no longer needed, so it is cleared before calling bar
17:28wabashI see. So would bar use foo's old stack frame?
17:28rhickeyno, it's gone
17:29wabashIs bar's frame in the same place that foo was?
17:30rhickeyif foo had arguments they were put on the stack. Rather than putting bar's arguments on top of foo's, foo's are cleared off first, since they will no longer be needed during or after the call to bar
17:31wabashGot it.
17:31wabashAnd then, where do bar's args go?
17:32rhickeyon the stack - it's just like normal calling. But if bar were to tail-call baz, it would clear its args off first, so there is no accumulation on the stack
17:33wabashI see. So the callers of TCO functions are just cleared from the stack, and the called just go on the stack as normal -- except the callers are not there.
17:35wabashI probably asked too many questions....
23:36Chouser(-> (new URL urlstr) .openConnection .getContent InputStreamReader. BufferedReader.)