#clojure log - May 16 2008

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

9:19 asbjxrn: Is it possible to have clojure print what it is that raises a NullPointerException when it happens?

11:52 rhickey: asbjxrn: what do you mean by what it is - something other than what's in the stack trace?

11:53 asbjxrn: Some additional information to what is in the trace, like which symbol was a nullpointer.

11:53 If that makes sense...

11:54 I'm not sure if it is possible as I guess this may happen in the jvm, and outside clojures control or something.

12:07 rhickey: right

12:19 asbjxrn: Hmm. Of course, it might not be a symbol that is null. : (somefunction (someotherfunction thatreturnsnull))

12:20 rhickey: I'm afraid the stack trace is all Clojure can do

12:21 asbjxrn: ok.

12:24 I 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:26 I'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:26 rhickey: In 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:27 asbjxrn: You were using emacs in the screencasts is that still the case?

12:29 rhickey: for 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:30 You can attach a debugger to the Clojure instance launched by emacs

16:31 jonathan___: Hey Rich, do I need to do anything special to deal with nested classes like DataLine.Info?

16:43 wabash: rhickey: Hey, Rich. I've got a question for you about tail recursion.

16:50 jonathan___: ok ansered: The real JVM name for java.nio.channels.FileChannel.MapMode is

16:50 java.nio.channels.FileChannel$MapMode - if you use that it will work.

16:50 Ditto any other nested classes.

16:50 Rich

17:18 rhickey: here

17:18 wabash: hi rhickey

17:19 rhickey: hi

17:20 wabash: I know Clojure can't do tail recursion optimization. It's because of the JVM, right?

17:20 rhickey: right

17:21 wabash: (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:21 rhickey: only Scheme guarantees this, and some implementations punt

17:21 wabash: punt?

17:22 rhickey: don't

17:23 wabash: I 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:24 rhickey: it clears the stack frame of the caller then jumps, so the call frames don't build up

17:26 wabash: jumps back to the beginning of the frame?

17:27 rhickey: no, 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:28 wabash: I see. So would bar use foo's old stack frame?

17:28 rhickey: no, it's gone

17:29 wabash: Is bar's frame in the same place that foo was?

17:30 rhickey: if 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:31 wabash: Got it.

17:31 And then, where do bar's args go?

17:32 rhickey: on 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:33 wabash: I 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:35 I probably asked too many questions....

23:36 Chouser: (-> (new URL urlstr) .openConnection .getContent InputStreamReader. BufferedReader.)

Logging service provided by n01se.net