#clojure logs

2008-03-10

09:25ChouserI looked briefly at getting the Arity exception to include the name of the function being called. Looks tricky.
09:26ChouserIt 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?
09:27Chouser...which sounds a bit messy.
09:31rhickeywould 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)
09:31Chouserright. Is that too ugly a solution to consider?
09:32rhickeynot all fns are named, fns with same name can exist in multiple namespaces
09:32rhickeynot impossible
09:33Chouseryeah, it wouldn't be any kind of "canonical" name. Just a potentially helpful string for use in debugging.
09:33Chousermaybe nobody else has as much trouble debugging such exceptions as I do. :-)
09:35rhickeyI'll think about it
09:36ChouserIf you'd be willing to accept such a solution but don't find it urgent, I could try writing a patch.
09:37rhickeydon't even think about a patch - this needs:
09:37rhickeya change to core base classes AFn and RestFn
09:37rhickeycode gen support
09:39Chouserhm. ok. I guess I'll go back to trying to get jswat to work for me instead.
09:39rhickeyif you get this error, a good hint will be just down the stack trace - the line where the call was made
09:40Chouseryeah, I'm looking at the line, and still don't know what I'm doing wrong.
09:40Chousercons with 2 args, assoc with 3, another assoc with 3. *shrug*
09:41ChouserIs the line named in the stack trace where the ( was found, or the )?
09:42rhickey(
09:42ChouserIf it's the (, then the only thing on that line is (cons obj oldobjs) ...in which case I must be missing something.
09:43rhickeyare you in a macro?
09:43ChouserAh! good question ... sync and defn
09:44rhickeyline numbers and macros are not behaving well at present
09:44rhickeywhich is a problem given fn/let/loop are now macros
09:44Chouser:-)
09:45ChouserHm, I get some kind of internal name for the function in the stack trace. I wonder if I can use that...
09:45Chouserat clojure.fn__1198$fn__1199.invoke
09:46rhickeyI was just looking at why those internal names aren't better - they used to be
09:46rhickeyfor other than truly anonymous fns, after ns. should be the function name
09:47rhickeyin your case, given ns is clojure, the line # probably corresponds to boot.clj
09:48Chouserat clojure.fn__1198$fn__1199.invoke(scratch09.clj:96)
09:49Chouserthat seems to be about right. (prn)'s before that line print, but those after it do not.
09:49Chouseroh!
09:49Chouserok, now I feel silly
09:50Chouser"set" used to be for mutating refs, right?
09:50rhickeyright, now use ref-set
09:50Chouserand there's my problem. :-)
09:51rhickeysorry about that, only doc is in SVN commit comments right now
09:51Chouserso it was the line number of the )
09:51Chouserno need to apologize.
09:51ChouserI wouldn't have read the docs yet anyway. This was old code I had just pasted in.
09:52Chouserin fact (doc set) was my first break. :-)
10:12rhickeyok - fixed fn name propagation, so e.g. instead of: clojure.fn__1198 you'll get: cljfn.clojure.set__546
10:12rhickeyshould greatly aid debugging
10:18Chouserah, nice! thanks.
10:19Chouseractually, I get: at cljfn.cljfn.clojure.db_set__1177$fn__1178.invoke(scratch09.clj:95)
10:20rhickeydb-set?
10:20Chouserdb-set is the name of my function that includes line 95
10:21rhickeythe double cljfn is wrong - will fix
10:21rhickeydid you define db-set in the clojure namespace?
10:21Chouser(defn db-set [...] (sync nil ... (set db ...)))
10:22Chouserhm. 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:23rhickeywith no in-ns in the file?
10:27rhickeydouble cljfn prefix fixed, prefix ns is now clojure.fns.
10:30Chousernope, no in-ns in the file. Should I do something like: (in-ns 'user) (clojure/refer 'clojure) at the top?
10:31rhickeyyou should put it in some ns unless it is a real one-off
10:31rhickeyI just wanted to understand the name you posted
10:32Chouserright. ok, now I'm getting: at clojure.fns.user.db_set__1177$fn__1178.invoke(scratch09.clj:98)
10:32rhickeygood
10:33ChouserI guess that helps confirm that problem is indeed at line 98 inside my db-set function.
10:33rhickeyis it/
10:33rhickey?
10:33Chouseryes
10:33rhickeyall is well then
10:33Chouserbut the problem is calling set with 2 params when it wants just 1.
10:34Chouserline 98 has a call to cons and the close-paren for set
10:35rhickeythat's as good as it gets for now
10:35Chouserok. thanks!
15:19ChouserCool, I get to use set/intersection.
15:19rhickeydoes it work?
15:22Chouserof course
16:14middaychi folks
17:32jgracinhi middayc!