#clojure logs

2008-07-08

00:00Chouserbut of course I can't actually do that in Clojure, so instead it produces a vector.
00:00Chouserlike [[:tr ...] [:tr ...]]
00:01Chouserso now a vector in this structure can mean two things -- either an element (if it beings with a keyword like :tr) or an anonymous group of elements that need to be spliced in.
00:01arohnerright
00:01ChouserThat seems clumsy, but I'm not sure I've seen an idea I prefer.
00:02ChouserI don't like the side-effect mechanism used by CL-WHO
00:02arohnerI like the (:tr) syntax better, but I get the feeling that has evaluation implications I haven't thought of yet
00:03Chouseroh, really? I prefer [:tr], but I wouldn't put up a fuss either way.
00:03ChouserI think the templating in webjure used `() all over specifically so it could use ~@ to splice in multiple results. ...but I'm not sure, and the results aren't exactly pretty.
00:05arohneryeah, but at least that has well understood consequences
00:05arohnerbtw, I'm a complete lisp noob, so don't take any of this as definitive :-)
00:05arohnermy sole qualification is that I've read SICP
00:06wybiralSICP ftw!
00:06Chouserwell, I read On Lisp, and never could get the hang on Common Lisp, so I'm not really one to talk.
00:07arohnerand SICP doesn't give you good practice with macros
00:07wybiralBut it's a great introduction to functional programming
00:08arohnerthe one thing I like about webjure's use of ` and ~@ is that it uses a clearly defined mechanism built into the language
00:08arohnerthat makes me feel more comfortable than a macro, which could be doing who knows what
00:09Chouserwell, my example doesn't require a macro or ` ~ ~@ syntax. Just clumsy corner cases. :-)
00:10ChouserOk, I'm off to bed. You folks have a nice whatever-you're-having!
00:10arohnerlater
01:00Lau_of_DKTop of the morning gents =)
01:00arbschthiya
01:13Lau_of_DKarbscht are you like a 24 hour coding machine? :)
01:14arbscht24 hour - yes. coding - I wish. :)
01:14Lau_of_DKI didn't look into that error msg last night, I got hooked on some XML - boy its difficult in Clojure compared to C#
01:16albinoxml is difficult in all languages
01:19Lau_of_DKNo its quite easy in C# actually
01:19Lau_of_DKvery very easy
01:19arbschtLau_of_DK: can you post a comparison somewhere?
01:20albinoIs it a literal notation? Or do you just like their library interface?
01:22Lau_of_DKarbscht Im sorry, no, because I still dont have a working model in Clojure
01:22arbschtLau_of_DK: I see
01:23Lau_of_DKBut in C# if you want to dig down and alter 1 node, you do it like this XmlDoc.getNodes("/root/nodes").getSingleNode("MyNode") = "New value";
01:23Lau_of_DKThis is intuitively easy I would say
01:23Lau_of_DKThen just XmlDoc.Save() and you're done
01:27albinoalmost xpath like
01:27Lau_of_DKits very xpath like
01:28albinostill not easy IMO, but probably compared to other approaches
01:28Lau_of_DKits simplified a bit, because after you get the singlenode object, you can modified .InnerXML, .outXML, .Attributes and so on. Here C#'s object structure is fantastic actually
01:28Lau_of_DKWhat would be easier?
01:31albinonot using xml in the first place :)
01:32Lau_of_DKlet me rephrase: What approach to manipulting XML would be easier?
01:41Lau_of_DKyep, its a tough one - I cant think of a simpler way :)
01:59Chouser(zip/replace (first (xml-> xml-doc :nodes :MyNode down)) "New value")
02:00Lau_of_DKCertainly you jest young Chouser
02:00ChouserI do. But not about this.
02:01Lau_of_DKWhat is "down" ?
02:01Chouserthat's using "xml->" from zip-filter in clojure-contrib, which was inspired by xpath
02:01Chouserdown is from zip.clj, as is replace
02:01Lau_of_DKbut what does it do ?
02:02Chouserit descends from MyNode to it's contents, since you don't want to replace MyNode itself, but rather whats inside.
02:02Chouserits
02:02Lau_of_DKFunny, I get an "unable to resolve symbol: down"
02:02Chousertry zip/down
02:03Chouserbut unlike (I assume) the C# version, this is functional -- no side effects and therefore completely thread safe without locking.
02:04Lau_of_DKits destructuring right?
02:04Chouseralso, with the lazy-xml stuff I still haven't quite checked in yet, I believe it would be lazy -- essentially nothing after the first MyNode element would have even needed to be parsed yet.
02:05ChouserLau_of_DK: not really, at least not the kind of destructuring that's listed as a Clojure feature. That's for setting of locals (let, defn, for, etc.) which I'm not doing in that example.
02:06Lau_of_DKk
02:06ChouserBTW, I didn't mean to suggest my example is simpler than the C#. *maybe* similarly simple, but certainly less mature and less documented.
02:07ChouserJust demontrating that something of roughly the same complexity would be possible. eventually.
02:08Lau_of_DKBut what would be wrong in stating that it was simpler? In a way, it actually is
02:08Chouserwhat's actually going on with the zip stuff is a bit tricky to get one's head around
02:09Lau_of_DKVery much - Also because I didn't first understand that Zip was an XML library, I thought it was a helper to zip keys/values in tree structs
02:09Chouserah, see ... zip is not an xml library.
02:09Lau_of_DKI think that its hard to follow a certain trend/theme when reading through the clojure source files, which combined with my recent switch to clojure, is not making it very easy
02:10Lau_of_DKlol
02:10Chouserxml trees are one of the things zip can manipulate.
02:10Lau_of_DKChouser. Would you at least consider writing Practical Concurrent Clojure ?
02:11ChouserWould you publish it? :-)
02:12Lau_of_DKOn my very own website
02:13Lau_of_DKJoking aside, I think you have a natural ability to make things understandable, quickly. So you should consider putting it good use somewhere, somehow
02:13Chouserzip is a way to navigate and "modify" trees of data (such as XML) without side effects.
02:13Lau_of_DK(though not for my benefit, for you and your family)
02:14ChouserLau_of_DK: why thank you. I think I would like, one day when I have been sufficiently educated, to teach.
02:14Lau_of_DKI would support - I might even sign up for a class
02:14Lau_of_DK+it
02:18ChouserI don't know where I'd find the time without taking it away from paying work. But thanks for the endorsement! :-)
02:18ChouserAnd now I'm really off to bed.
02:19Lau_of_DKSleep tight, and thanks for your input
04:14meredyddChouser: you here?
04:50Lau_of_DKChouser went to sleep 2 - 3 hours ago
04:50Lau_of_DKmeredydd
04:50meredyddbugger.
04:50meredyddHm....does that make him an Ozzie?
04:50meredydd(well...antipodean, at any rate)
04:58Lau_of_DKI dont recognize those words
05:25meredyddOzzie = Australian
05:25meredyddthe Antipodes are those parts of the world roughly diametrically opposite to Britain :D
05:25meredyddTransaction question:
05:25cgrandwhere people walk on the head
05:26meredyddIf I make a call in a (dosync), and inside that call is another (dosync), am I right in thinking that the whole thing is one transaction that either happens or doesn't?
05:28cgrandafaik that's how it works
05:28meredydd(This seems to be the sensible way to do it, as it neatly solves the proverbial bank-account problem: say I have the fun 'add' = #(dosync (alter bank-balance (+ %)), and 'remove' = #(dosync (alter bank-balance (- %)), a transfer function that goes #(dosync (add 5) (remove 5)) should Do The Right Thing)
05:30cgrandI don't think that putting dosyncs in add and remove is sensible because then add or remove can be used alone
08:06Lau_of_DKAnybody here competent to answer an XML question?
09:28YcrosLau_of_DK: never ask to ask, you won't get anywhere
10:51cemerickI have an interface that extends IPersistentCollection, and a gen-class spec for an implementation of that interface. However, when I import the gen-class class, I get "java.lang.IllegalStateException: empty already refers to: #'com.foo.Bar/empty in namespace: com.foo.Bar". I know I don't have any definitions of empty in com.foo.Bar, and removing the :implements option from the gen-class spec eliminates this error. Any thoughts?
10:53ChouserIPersistentCollection has an empty, and since you might choose to override that later, it's got a name imported into your gen-class namespace.
11:13cemerickChouser: Thanks for that tip -- a couple of things just clicked into place in my head. :-)
11:14cemerickThat seems like collisions like that will be a common thing.
11:17cemericks/That/It
11:27Chouseryes.
11:27Chouserrhickey's mentioned a plan to help eliviate the issue
11:46cemerickYeah, I know he's been thinking/working on gen-class revamp. I just didn't fully understand what was going on until just a little while ago. :-)
11:47cemerickLooks like there's no prn-str (or similar) that will readably print an object and return the result as a string (rather than dumping it to stdout).
11:53cemerickWhoa, nevermind -- I was looking at a very old version of boot.clj.
17:43dvl_hi. how do i use http://java.sun.com/j2se/1.5.0/docs/api/java/net/Proxy.Type.html from clojure (to instantiate a java.net.Proxy object ...)?
17:45kotarakin general: (new java.net.Proxy <arguments> <go> <here>) (or shorter (java.net.Proxy. <arguments>))
17:55dvl_(new Proxy (. Proxy$Type HTTP) seems to cut it
23:00arohnerhas anyone played with java arrays in clojure?
23:01arohner (def my-file (new File "/Users/arohner/"))
23:01arohner(class (. my-file (listFiles)))
23:01arohner[Ljava.io.File;@6ce64e
23:01arohnerdoes that output look right?
23:07arohnerwell, not right, but I expected something prettier
23:07arohnerlike java.io.File[]