#clojure logs

2008-07-16

09:06rhickeyAnyone XMPP savvy?
09:39Chouseryou might need an xml parser that doesn't strip whitespace
09:39rhickeyChouser: ?
09:42Chouserxml.clj trims whitespace around text regardless of whether it's meaningful or not.
09:45rhickeyChouser: what's an example?
09:50Chouser(xml/parse (org.xml.sax.InputSource. (java.io.StringReader. "<a><b>1</b> <c>2</c></a>")))
09:50ChouserThat loses the space between 1 and 2
09:51Chouseremit then inserts newlines where they don't belong.
09:52ChouserThere may be many XML formats where that doesn't matter, but there certainly are some where that'll break things, xhtml being one of them.
09:52Chouserand xhtml can be used in xmpp
09:53rhickeywould you want a flag toggling the ws dumping?
09:53rhickeybecause otherwise in those other format you get a lot of useless child elements
09:53Chouserthat's what I've got in my (still unreleased) lazy-xml lib
09:54rhickeyemit is a toss off, admittedly
09:54Chouserbut I think a "better" solution is to use a mechanism for interacting with the parsed tree that makes it easy to ignore whitespace you don't care about
09:55Chousersame for xml comments. It's nice to leave those things in there if your going to modify something a little and write it back out.
09:55Chouseryeah, I added a :pad option to my emit in case you want the newlines.
09:56rhickeyin any case, I don't expect to be using xml.clj for XMPP, as it's streamed
09:57Chouserhm, good point.
09:57rhickeymight try the smack lib first: http://www.igniterealtime.org/projects/smack/index.jsp
09:57rhickeyI'm thinking about xmpp for distributed Clojure
09:58Chouseroh, of course you don't want to deal with the xml directly. what was I thinking. :-)
09:59Chouserwell, for what it's worth we actually used xmpp for inter-app communication at work.
09:59Chouserwe got it working, but ended up ditching it in favor of our own custom XML protocol over TCP.
10:00Chouserxmpp had a lot of features we didn't care about, but that the servers tried hard to support. We ended up with hard-to-debug events where the server appeared to be at fault, but it was hard to be sure.
10:01ChouserWe were happy to remove our depenence on a Jabber server.
10:05ChouserBut who knows what we may have been doing wrong. YMMV
10:10meredyddIs there an Official Answer to what (alter) returns?
10:11meredyddRight now, it returns the new value
10:12meredyddas does (ref-set) and (commute) - but the docs don't say anything official, and I'm leery of building on undocumented functionality :)
10:15meredyddChouser: yeah...that was my (admittedly arms-length) impression of using XMPP for IPC.
10:15rhickeyChouser: thanks for the info on your experience, that's why I asked, but I don't want to build from nothing. Other option is JXTA, but far fewer usingthat
10:15meredyddThat said, I've just spent a happy week rolling my own IPC system for this product in Clojure, supporting exactly what I want and nothing more.
10:16Chouserit's a pity because it seems like it'd be nice: xml, highly available servers, etc.
10:17Chouserwe also considered UPnP, but that never got past the design stage
10:18rhickeyI really like extending the chat metaphor to applications, including group messages, pub/sub, presence etc
10:19Chouseryep. I think we used direct messaging and pub/sub. Not sure if we used presence or not, and I don't think we used group messaging.
10:20rhickeyas you said, xmpp has more than is needed, but rebuilding 1/3 of xmpp is still a big job
10:20ChouserI didn't implement any of this, but I seem to remember pub/sub being poorly supported or somehow causing us trouble.
10:20ChouserI wonder if you built your own server (or at least had more complete control or command of it) if that would make the difference.
10:21rhickeyI like the availability of openfire and smack from the same source, both Java. I would hope for good client/server compatibility there
10:21ChouserWe're C++ shop using a Java-based server -- it a mysterious black box to us.
10:22rhickeymeredydd: yes, they return the new value
10:22meredyddrhickey: cool, thanks. Could I request a doc-patch to make that explicit?
10:29rhickeymeredydd: docs fixed but svn won't let me check in - aargh
10:29meredyddrhickey: Eh-oh. Server problem, or SVN internal error?
10:30Chouserhm, when SVN at sourceforge was failing the other day, I couldn't even do a fetch, but it worked for me just now.
10:31meredyddChouser: Where's work, by the way?
10:31Chouserhttp://www.fourddev.com/
10:32Chouserwebsite's pretty sparse and out of date, but there ya go. ;-)
10:34rhickeyChouser: 403 Forbidden on checkin
10:35Chouserrhickey: :-( sorry.
10:39rhickeyChouser: what jabber server(s) were you using?
10:45ChouserI belive we used wildfire
10:48Chouseroh, didn't notice you were gone. I believe we used wildfire
10:49rhickeyChouser: and for a client lib?
10:50Chouserhttp://delta.affinix.com/iris/
10:52rhickeyChouser: in spite of your experience I think I'll continue to explore xmpp - how long ago did you try it?
10:56Chouserlooks like we gave up on jabber in January of 2007
10:56ChouserI hope it works better for you. :-)
10:56rhickeyme too!
11:00Chouserit looks like we used "rosters" and "presence" earlier, and switched to "pubsub" and "status" later. I don't really know what those mean.
11:01ChouserI seem to recall the main issue being flakey presence. In our application, we really couldn't have users "disappearing" if they weren't actually disconnected, but we chased just such problems a lot.
11:14cemerickopen Q: since clojure has its own very expressive structured data format (sexprs/vectors/maps), why use an XML wire protocol? Or would XMPP only be an envelope for readable clojure?
11:15rhickeycemerick: the latter, message bodies would be readable Clojure
11:17Chouserrhickey: looked at lazy-seq closing at all yet?
11:27rhickeyChouser: I planted it in my head before ECOOP, but it really poses profound philosophical problems...
11:27rhickeyclose being inherently not functional
11:27Chouserhm, yep, good point.
11:28ChouserI don't have a great need for it, but you mentioned you might look at it after ECOOP, so I thought I'd ask.
11:28rhickeyI have on my agenda making lazy-cons a special op, because it is so heavily used
11:28rhickeydoing so will allow me to make it one alloc instead of three
11:29Chouserok
11:29rhickeyand at that time I might extend the interface to include close, but haven't worked out sound semantics
11:30rhickeye.g. what if you've aliased a closeable seq and one consumer closes it before the other is done?
11:30Chouseryeah, it really messes with the value semantics of seqs, doesn't it.
11:30rhickeyright
11:34rhickeypotentially at least, but I'm still thinking about it. In some ways, someone calling close simply makes as much of the seq as anyone has read its effective length. As long as everyone sees the same elements it might not matter. But the threading aspects are tricky too
11:38Chouserhm. And the use case is so that func x can return a line-seq to func y which can then close any underlying file that might or might not be there?
11:39rhickeyChouser: that's one, but the general problem is one of non-memory resources associated with a seq source - files, threads etc
11:39rhickeyneed to be released when no one cares about the seq anymore
11:41Chouserright, but specifically where the resource is created by the seq-creator, not passed in?
11:41Chouseror do I still have that wrong?
11:42rhickeydoesn't really matter, as soon as you pass off the seq
11:42rhickeyto some code that doesn't know about the resource
11:42Chouseryeah, ok.
14:33jgrantdoes clojure support something like common lisps keyword args ?
14:34rsynnottyou could probably use a hash and destructure in the function declaration
14:36Chouser_jgrant: no direct support, but it's not uncommon to say something like:
14:37Chouser(defn foo [a b & opts] (let [opthash (apply hash-map opts)] ...))
14:38Chouseror with destructuring like rsynnott suggested:
14:38jgrantthx
14:39Chouser(defn foo [a b & opts] (let [{:keys [c d e]} (apply hash-map opts)] ...))
14:39Chousereither of those could be called like: (foo 1 2 :d 5)
15:26rapidoanyone seen http://will.thimbleby.net/misc/ ?
15:27rapidomaps instead of lists as the primitive structure
15:27rapido(for code and data)
15:27albinoI looked at it yesterday, but didn't glean much
15:27rsynnott"simplicity of the syntax and design of LISP... and a syntax similar to that of Smalltalk"
15:27rsynnottweird
15:28rapidoit's interesting as an idea
15:28rapidoand it is immutable to the core
15:29rapidoit seems that more and more (research) languages and frameworks are leaning towards immutability
15:31rapidoand we also won't need no stinking loops (www.nsl.com)
15:31albinowhat's the perceived benefit of a map instead of a list as the default structure?
15:32rapidounification of concepts?
15:32rapidoalthough i think a multi-map is even more general
15:32albinohuh, he's listing xml as one of the benefits
15:34rapidoxml is not fundamental. but key/value pairs are
15:35albino"or example maps can easily represent lists but not vice versa." <- is that really true?
15:35albinoIt isn't easy to go from (1 "a" 2 "b") to a map of 1->"a", 2->"b" ?
15:36rapidoalbino: not so. a list can encode a map. but a map *implementation* is more efficient for key/value lookup
15:36rapidowe agree
15:36rapidoin my language enchilada, everything is a list ... but ....
15:37albinorapido: I was gonna ask you what you were implementing your language in these days, but for some reason I couldn't remember the name
15:37rapidoi flag every (sub) list if its sorted (ascending)
15:37rapidoif its sorted, its considered a multi-map
15:38albinowhy call it multi-map instead of sorted-map ?
15:38rapidocertain operations perform faster (sorting, lookup, etc) when a list is sorted
15:38rapidomulti-map allows multiple keys
15:39rapidoso (1 "a" 1 "b" 2 "c" 3 "d" ) is allowed
15:39albinoso non-unique keys then
15:39rapidoyep
15:40albinoso when you do a get on 1 do you get ("a" "b") ?
15:40rapidoyep
15:41rapidoit's very regular
15:41rapidoin enchilada, every 'key' and 'value' is an expression
15:41albinothere needs to be a #exotic-langs or something where all these cool language creators hang out and piss each other off
15:41rapidolol
16:13ericthorsenrhickey: question on the debug extensions namespace and pathing... given a clojure namespace 'org.me.package in source file stuff.clj, would the resulting file path be org/me/package/stuff.clj ... assuming you moved to the java package/path style for namepaces?
16:16rhickey_ericthorsen: I was just thinking about that. If the ns is org.me.package then the file should be package.clj in org/me
16:17ericthorsenrhickey: so the compiler will ignore the physical file name (if it does not match)?
16:17rhickey_but then a fn foo defined therein will be of class org.me.package.foo, so there's a mismatch with Java's class->file relationship
16:19ericthorsenrhickey: but there is no file package in that case. It would be looking for org/me/package/foo.class yes?
16:19rhickey_ericthorsen: there are 2 aspects - the source and source path in the debug info and the classnames of the generated fns
16:19ericthorsenunderstood
16:20rhickey_so the source and source path would always be based on the file/dirs
16:22rhickey_so maybe it would be as you said org/my/namespace/whatever.clj
16:23rhickey_so saying org.my.namespace.foo was in whatever.clj would match up classpath-wise
16:23rhickey_hmm, but not good for the folks doing the require stuff...
16:26rhickey_although leaving the namespace as a dir would allow for multiple files defining a ns, maybe some load order issues
16:33rhickey_any lib/require authors/users want to chime in?
18:07meredyddArgh. Another compiler bug.
18:10meredyddOoh, wow. I can only assume this to be a reader bug.
18:10meredydd(It really doesn't help that the reader exceptions give you no hints as to what file it's reading when it encounters its errors)
18:12Chousermeredydd: but maybe you can give us a hint? :-)
18:13meredyddHa. Nope, not a reader bug, just a spectacularly unhelpful error message.
18:13meredyddWhich reminds me - the next time rhickey can bear to see my face without running away, I want to ask him about the general state of backtraces in Clojure
18:17ChouserI have found the stack trace dumps to be rather opaque, but with a bit of practice I'm getting better at picking out the useful info from among the noise.
18:18Lau_of_DKIt takes a little practice - but I dont see why Clojure it self could provide that useful information ?
18:18meredyddChouser: I agree, and the same thing's happening to me.
18:18Lau_of_DKFind a bug in Clojure takes 50x the time it would do in Vs2005
18:18meredyddBut so much of the time, the info Just Isn't There
18:18Chouserclojure's not generating the stack trace, the JVM is.
18:18meredyddor, worse, it's in about four levels of "Caused By:"
18:18meredyddwhich is monstrously unhelpful, because you have to do the picking-through-the-noise bit four times
18:18Lau_of_DKChouser: ,then forget the stack trace, there's probably a better way to go about it
18:19Chousermeredydd: well that's not really worse is it. having the information buried is better than not having it.
18:19meredyddTrue. Invert that "so much of the time" and "worse" :P
18:19Chouser;-) sorry to pedantic
18:20meredydd...well, given the context, that missing verb is too tempting to pass up :^D
18:20ChouserI wonder if one could write an out try/catch block that then picked through the stack information for you to highlight the most useful bits
18:20Chousers/out/outer/
18:20meredyddNot really helpful if you do run-time introspection of exceptions
18:20Chouserit's not? why not?
18:21meredyddOh, just that you'd need to do your try/catch magic for *every* try/catch expression
18:22Chouseryou can't pick through the whole trace from an outer catch?
18:22meredyddI suppose my stack-trace-munging code could have a good go at it...
18:22meredyddChouser: Most of the time, it doesn't make it to an outer catch
18:22Chouseroh, in your code base that may be. :-)
18:23meredyddBut, as I say, I funnel most of it through a single piece of code that pretties it up to send somewhere else, so I guess I could do it there
18:23Chouserwell the rest of us want to use it too, such as at a repl
18:23meredydduh-huh. Probably put it together as a library function of some sort
18:24meredyddgive it an exception, and it'll give you a "clojure native" backtrace.
18:24Chouseryeah, something like that
18:24meredyddTo a first approximation, I guess you could just "grep -v clojure.lang"
18:24Chouseryep. i tend to look first for .clj files
18:25Chouseryou'd also want to try to detect "compile time" exceptions an display them differently
18:25meredyddAh...again, my own biases - this is an app with large hunks of Java code, so it's likely the call stack will be weaving in and out between the two languages
18:26Chouserhm. I suspect this would be the problem in general -- what each of us considers "important" varies by just enough.
18:26meredyddChouser: Hmm...aren't they all subclasses of CompilerException?
18:26Chouserfor example, I would imagine Rich generally wants to soo the clojure.lang items. :-)
18:27Chousermeredydd: nope, not when macros are involved
18:27meredyddOh, joy.
18:27Chouser(defmacro foo [] `(nil))
18:27Chouser(foo)
18:27meredyddI'd imagine Rich (or anyone else hacking core) to be a very marginal case, though.
18:28Chouserjava.lang.NullPointerException, but it's at compile time so the stack trace doesn't really go through any .clj code
18:28meredyddFor comparison, it's not as though ordinary Java backtraces go through interesting bits of the JVM just in case there's a core dev watching :P
18:28Chouserhmm
18:29meredyddChouser: Hmm...you could probably detect that case.
18:29meredydd"if there's no Clojure code in here, treat it like an ordinary Java backtrace"
18:32Chouseractually, you may be right. it says NullPointerException at the top, but it may actually be a CompilerException. I'm not quite sure.
18:33meredydd...and when even you're still not quite sure, that's a strong indication that the error message system is, ahem, insufficiently clear :)
18:40meredyddIn any case, if you're interested, the compiler bug has just vanished into the ether.
18:40meredyddMaybe might have been a downstream product of the reader bug, which at a certain point was claiming to successfully read an ill-formed file, and perhaps there was some data-structure brokenness that propagated to the compiler
18:41meredyddUnfortunately, I didn't think to save it, so I can't reproduce :S
18:42Chouserah, well. you didn't happen to be doing any regex stuff, were you?
18:43meredyddno, why?
18:44Chousersomething like #"\w+" will kill your reader quick
18:45Chouser...although my test of it just now had more robust results than when I've tried in the past.
21:31koneillmorning all ... it's there a log for this c
21:31koneillhannel ? ... sorry about the line break
21:32arbschthttp://clojure-log.n01se.net/date/
21:32koneillthanks