#clojure log - Mar 10 2008

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

9:25 Chouser: I looked briefly at getting the Arity exception to include the name of the function being called. Looks tricky.

9:26 It looks like functions don't know their own names? So I suppose that would have to change -- the name as given by defn or the option name param to fn would have to be copied into the function object itself?

9:27 ...which sounds a bit messy.

9:31 rhickey: would really have to be passed to the fn's base class - most are derived from AFn and it is AFn that actually throws the exception (i.e. the AFn version of every overload of invoke() throws so that every fn doesn't have to)

9:31 Chouser: right. Is that too ugly a solution to consider?

9:32 rhickey: not all fns are named, fns with same name can exist in multiple namespaces

9:32 not impossible

9:33 Chouser: yeah, it wouldn't be any kind of "canonical" name. Just a potentially helpful string for use in debugging.

9:33 maybe nobody else has as much trouble debugging such exceptions as I do. :-)

9:35 rhickey: I'll think about it

9:36 Chouser: If you'd be willing to accept such a solution but don't find it urgent, I could try writing a patch.

9:37 rhickey: don't even think about a patch - this needs:

9:37 a change to core base classes AFn and RestFn

9:37 code gen support

9:39 Chouser: hm. ok. I guess I'll go back to trying to get jswat to work for me instead.

9:39 rhickey: if you get this error, a good hint will be just down the stack trace - the line where the call was made

9:40 Chouser: yeah, I'm looking at the line, and still don't know what I'm doing wrong.

9:40 cons with 2 args, assoc with 3, another assoc with 3. *shrug*

9:41 Is the line named in the stack trace where the ( was found, or the )?

9:42 rhickey: (

9:42 Chouser: If it's the (, then the only thing on that line is (cons obj oldobjs) ...in which case I must be missing something.

9:43 rhickey: are you in a macro?

9:43 Chouser: Ah! good question ... sync and defn

9:44 rhickey: line numbers and macros are not behaving well at present

9:44 which is a problem given fn/let/loop are now macros

9:44 Chouser: :-)

9:45 Hm, I get some kind of internal name for the function in the stack trace. I wonder if I can use that...

9:45 at clojure.fn__1198$fn__1199.invoke

9:46 rhickey: I was just looking at why those internal names aren't better - they used to be

9:46 for other than truly anonymous fns, after ns. should be the function name

9:47 in your case, given ns is clojure, the line # probably corresponds to boot.clj

9:48 Chouser: at clojure.fn__1198$fn__1199.invoke(scratch09.clj:96)

9:49 that seems to be about right. (prn)'s before that line print, but those after it do not.

9:49 oh!

9:49 ok, now I feel silly

9:50 "set" used to be for mutating refs, right?

9:50 rhickey: right, now use ref-set

9:50 Chouser: and there's my problem. :-)

9:51 rhickey: sorry about that, only doc is in SVN commit comments right now

9:51 Chouser: so it was the line number of the )

9:51 no need to apologize.

9:51 I wouldn't have read the docs yet anyway. This was old code I had just pasted in.

9:52 in fact (doc set) was my first break. :-)

10:12 rhickey: ok - fixed fn name propagation, so e.g. instead of: clojure.fn__1198 you'll get: cljfn.clojure.set__546

10:12 should greatly aid debugging

10:18 Chouser: ah, nice! thanks.

10:19 actually, I get: at cljfn.cljfn.clojure.db_set__1177$fn__1178.invoke(scratch09.clj:95)

10:20 rhickey: db-set?

10:20 Chouser: db-set is the name of my function that includes line 95

10:21 rhickey: the double cljfn is wrong - will fix

10:21 did you define db-set in the clojure namespace?

10:21 Chouser: (defn db-set [...] (sync nil ... (set db ...)))

10:22 hm. apparently. I just define it in scratch09.clj, and run it like this: java -cp ~/build/clojure/clojure.jar clojure.lang.Repl scratch09.clj

10:23 rhickey: with no in-ns in the file?

10:27 double cljfn prefix fixed, prefix ns is now clojure.fns.

10:30 Chouser: nope, no in-ns in the file. Should I do something like: (in-ns 'user) (clojure/refer 'clojure) at the top?

10:31 rhickey: you should put it in some ns unless it is a real one-off

10:31 I just wanted to understand the name you posted

10:32 Chouser: right. ok, now I'm getting: at clojure.fns.user.db_set__1177$fn__1178.invoke(scratch09.clj:98)

10:32 rhickey: good

10:33 Chouser: I guess that helps confirm that problem is indeed at line 98 inside my db-set function.

10:33 rhickey: is it/

10:33 ?

10:33 Chouser: yes

10:33 rhickey: all is well then

10:33 Chouser: but the problem is calling set with 2 params when it wants just 1.

10:34 line 98 has a call to cons and the close-paren for set

10:35 rhickey: that's as good as it gets for now

10:35 Chouser: ok. thanks!

15:19 Cool, I get to use set/intersection.

15:19 rhickey: does it work?

15:22 Chouser: of course

16:14 middayc: hi folks

17:32 jgracin: hi middayc!

Logging service provided by n01se.net