2008-07-08
| 00:00 | Chouser | but of course I can't actually do that in Clojure, so instead it produces a vector. |
| 00:00 | Chouser | like [[:tr ...] [:tr ...]] |
| 00:01 | Chouser | so 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:01 | arohner | right |
| 00:01 | Chouser | That seems clumsy, but I'm not sure I've seen an idea I prefer. |
| 00:02 | Chouser | I don't like the side-effect mechanism used by CL-WHO |
| 00:02 | arohner | I like the (:tr) syntax better, but I get the feeling that has evaluation implications I haven't thought of yet |
| 00:03 | Chouser | oh, really? I prefer [:tr], but I wouldn't put up a fuss either way. |
| 00:03 | Chouser | I 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:05 | arohner | yeah, but at least that has well understood consequences |
| 00:05 | arohner | btw, I'm a complete lisp noob, so don't take any of this as definitive :-) |
| 00:05 | arohner | my sole qualification is that I've read SICP |
| 00:06 | wybiral | SICP ftw! |
| 00:06 | Chouser | well, I read On Lisp, and never could get the hang on Common Lisp, so I'm not really one to talk. |
| 00:07 | arohner | and SICP doesn't give you good practice with macros |
| 00:07 | wybiral | But it's a great introduction to functional programming |
| 00:08 | arohner | the one thing I like about webjure's use of ` and ~@ is that it uses a clearly defined mechanism built into the language |
| 00:08 | arohner | that makes me feel more comfortable than a macro, which could be doing who knows what |
| 00:09 | Chouser | well, my example doesn't require a macro or ` ~ ~@ syntax. Just clumsy corner cases. :-) |
| 00:10 | Chouser | Ok, I'm off to bed. You folks have a nice whatever-you're-having! |
| 00:10 | arohner | later |
| 01:00 | Lau_of_DK | Top of the morning gents =) |
| 01:00 | arbscht | hiya |
| 01:13 | Lau_of_DK | arbscht are you like a 24 hour coding machine? :) |
| 01:14 | arbscht | 24 hour - yes. coding - I wish. :) |
| 01:14 | Lau_of_DK | I didn't look into that error msg last night, I got hooked on some XML - boy its difficult in Clojure compared to C# |
| 01:16 | albino | xml is difficult in all languages |
| 01:19 | Lau_of_DK | No its quite easy in C# actually |
| 01:19 | Lau_of_DK | very very easy |
| 01:19 | arbscht | Lau_of_DK: can you post a comparison somewhere? |
| 01:20 | albino | Is it a literal notation? Or do you just like their library interface? |
| 01:22 | Lau_of_DK | arbscht Im sorry, no, because I still dont have a working model in Clojure |
| 01:22 | arbscht | Lau_of_DK: I see |
| 01:23 | Lau_of_DK | But 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:23 | Lau_of_DK | This is intuitively easy I would say |
| 01:23 | Lau_of_DK | Then just XmlDoc.Save() and you're done |
| 01:27 | albino | almost xpath like |
| 01:27 | Lau_of_DK | its very xpath like |
| 01:28 | albino | still not easy IMO, but probably compared to other approaches |
| 01:28 | Lau_of_DK | its 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:28 | Lau_of_DK | What would be easier? |
| 01:31 | albino | not using xml in the first place :) |
| 01:32 | Lau_of_DK | let me rephrase: What approach to manipulting XML would be easier? |
| 01:41 | Lau_of_DK | yep, its a tough one - I cant think of a simpler way :) |
| 01:59 | Chouser | (zip/replace (first (xml-> xml-doc :nodes :MyNode down)) "New value") |
| 02:00 | Lau_of_DK | Certainly you jest young Chouser |
| 02:00 | Chouser | I do. But not about this. |
| 02:01 | Lau_of_DK | What is "down" ? |
| 02:01 | Chouser | that's using "xml->" from zip-filter in clojure-contrib, which was inspired by xpath |
| 02:01 | Chouser | down is from zip.clj, as is replace |
| 02:01 | Lau_of_DK | but what does it do ? |
| 02:02 | Chouser | it descends from MyNode to it's contents, since you don't want to replace MyNode itself, but rather whats inside. |
| 02:02 | Chouser | its |
| 02:02 | Lau_of_DK | Funny, I get an "unable to resolve symbol: down" |
| 02:02 | Chouser | try zip/down |
| 02:03 | Chouser | but unlike (I assume) the C# version, this is functional -- no side effects and therefore completely thread safe without locking. |
| 02:04 | Lau_of_DK | its destructuring right? |
| 02:04 | Chouser | also, 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:05 | Chouser | Lau_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:06 | Lau_of_DK | k |
| 02:06 | Chouser | BTW, I didn't mean to suggest my example is simpler than the C#. *maybe* similarly simple, but certainly less mature and less documented. |
| 02:07 | Chouser | Just demontrating that something of roughly the same complexity would be possible. eventually. |
| 02:08 | Lau_of_DK | But what would be wrong in stating that it was simpler? In a way, it actually is |
| 02:08 | Chouser | what's actually going on with the zip stuff is a bit tricky to get one's head around |
| 02:09 | Lau_of_DK | Very 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:09 | Chouser | ah, see ... zip is not an xml library. |
| 02:09 | Lau_of_DK | I 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:10 | Lau_of_DK | lol |
| 02:10 | Chouser | xml trees are one of the things zip can manipulate. |
| 02:10 | Lau_of_DK | Chouser. Would you at least consider writing Practical Concurrent Clojure ? |
| 02:11 | Chouser | Would you publish it? :-) |
| 02:12 | Lau_of_DK | On my very own website |
| 02:13 | Lau_of_DK | Joking aside, I think you have a natural ability to make things understandable, quickly. So you should consider putting it good use somewhere, somehow |
| 02:13 | Chouser | zip is a way to navigate and "modify" trees of data (such as XML) without side effects. |
| 02:13 | Lau_of_DK | (though not for my benefit, for you and your family) |
| 02:14 | Chouser | Lau_of_DK: why thank you. I think I would like, one day when I have been sufficiently educated, to teach. |
| 02:14 | Lau_of_DK | I would support - I might even sign up for a class |
| 02:14 | Lau_of_DK | +it |
| 02:18 | Chouser | I don't know where I'd find the time without taking it away from paying work. But thanks for the endorsement! :-) |
| 02:18 | Chouser | And now I'm really off to bed. |
| 02:19 | Lau_of_DK | Sleep tight, and thanks for your input |
| 04:14 | meredydd | Chouser: you here? |
| 04:50 | Lau_of_DK | Chouser went to sleep 2 - 3 hours ago |
| 04:50 | Lau_of_DK | meredydd |
| 04:50 | meredydd | bugger. |
| 04:50 | meredydd | Hm....does that make him an Ozzie? |
| 04:50 | meredydd | (well...antipodean, at any rate) |
| 04:58 | Lau_of_DK | I dont recognize those words |
| 05:25 | meredydd | Ozzie = Australian |
| 05:25 | meredydd | the Antipodes are those parts of the world roughly diametrically opposite to Britain :D |
| 05:25 | meredydd | Transaction question: |
| 05:25 | cgrand | where people walk on the head |
| 05:26 | meredydd | If 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:28 | cgrand | afaik that's how it works |
| 05:28 | meredydd | (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:30 | cgrand | I don't think that putting dosyncs in add and remove is sensible because then add or remove can be used alone |
| 08:06 | Lau_of_DK | Anybody here competent to answer an XML question? |
| 09:28 | Ycros | Lau_of_DK: never ask to ask, you won't get anywhere |
| 10:51 | cemerick | I 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:53 | Chouser | IPersistentCollection has an empty, and since you might choose to override that later, it's got a name imported into your gen-class namespace. |
| 11:13 | cemerick | Chouser: Thanks for that tip -- a couple of things just clicked into place in my head. :-) |
| 11:14 | cemerick | That seems like collisions like that will be a common thing. |
| 11:17 | cemerick | s/That/It |
| 11:27 | Chouser | yes. |
| 11:27 | Chouser | rhickey's mentioned a plan to help eliviate the issue |
| 11:46 | cemerick | Yeah, 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:47 | cemerick | Looks 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:53 | cemerick | Whoa, nevermind -- I was looking at a very old version of boot.clj. |
| 17:43 | dvl_ | 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:45 | kotarak | in general: (new java.net.Proxy <arguments> <go> <here>) (or shorter (java.net.Proxy. <arguments>)) |
| 17:55 | dvl_ | (new Proxy (. Proxy$Type HTTP) seems to cut it |
| 23:00 | arohner | has anyone played with java arrays in clojure? |
| 23:01 | arohner | (def my-file (new File "/Users/arohner/")) |
| 23:01 | arohner | (class (. my-file (listFiles))) |
| 23:01 | arohner | [Ljava.io.File;@6ce64e |
| 23:01 | arohner | does that output look right? |
| 23:07 | arohner | well, not right, but I expected something prettier |
| 23:07 | arohner | like java.io.File[] |