#clojure log - Sep 22 2010

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

0:17 laurus: What is the best way to automatically wrap a block of Clojure code inside a function from the command line?

0:20 tomoj: what does that mean?

0:20 Raynes: wut

0:20 laurus: So what I want to do is this

0:20 I want to create a new cljr option

0:20 Say, cljr hello

0:20 So I can run "cljr hello filename.cljr"

0:21 Er, .clj

0:21 And it will take that .clj file and evaluate it, but inside another function

0:21 And return the result to that function for the final processing.

0:22 tomoj: just load the file?

0:22 laurus: tomoj, what do you mean? Heh

0:22 Raynes: load-file

0:22 laurus: Right, but how do I create that additional cljr command?

0:23 * Raynes looks at cljr's docs.

0:23 laurus: Raynes, the reason I phrased the question the way I did the first time was because I assumed it might be difficult to do that, and I could do it with one of the existing commands using some kind of tricky syntax :P

0:23 Such as passing the function itself in on the command line as an argument, and then utilizing it from within the program somehow.

0:23 * Raynes passes on the obligatory "I still say you should check out cake." speech and actually tries to help.

0:24 laurus: Hey, thanks ;)

0:24 I'm mainly using Incanter so I don't need a complicated system right now

0:24 Raynes: Hrm.

0:25 cljr doesn't appear to have any sort of extension mechanism.

0:25 laurus: Raynes, I know you can do this with leiningen. See here: http://github.com/markmfredrickson/changeling/blob/master/project.clj

0:25 Raynes: And cake. Very easily with cake, even.

0:25 laurus: He just defined a new function, and then one can run "cljr changeling"

0:25 * Raynes whistles

0:25 laurus: Hehe what does that whistling imply?

0:25 Raynes: It implies that I almost did what I said I wouldn't do. ;)

0:26 laurus: Well

0:26 Is it possible with cljr?

0:26 Raynes: You'd probably have to fork the repository and add it yourself. I'm pretty sure cljr isn't made to be extended like that.

0:27 laurus: Hmm, okay.

0:27 But cake is, huh?

0:27 ;)

0:27 Do I have to create a project with cake? I don't really need projects since everything I do is one giant project, so to speak

0:27 Raynes: cake has a thing called "the global project" and you can add tasks to that, so no.

0:27 laurus: Oh, neat

0:28 I'm just kind of annoyed by all of these various build systems

0:28 Raynes: It explains it in the README.

0:28 laurus: I'm sick of switching between them all the time as well :P

0:28 Raynes: Cake is fairly leiningen project compatible.

0:29 laurus: I also like how cljr is a jar

0:29 Raynes: Well, cake kind of is too.

0:29 laurus: Okay, here's what I'm really trying to do, at a high level

0:29 I'm close to being done with an alternative Clojure script for org-babel

0:29 Raynes: The Ruby stuff is just for bootstraping and launching

0:29 laurus: That doesn't require swank or SLIME

0:30 But I'm stuck at the final part, which is actually getting the return value from the Clojure code into the output buffer

0:30 So the way I decided to do that was wrap the Clojure code in a "print out" function

0:30 I.e., clojure.contrib.duck-streams/spit

0:30 But the trick is, how to wrap it.

0:30 Raynes: What version of Clojure are you using?

0:30 laurus: 1.2.0.

0:31 Raynes: spit is in clojure.java.io now.

0:31 laurus: Oh, cool, thanks for that tip :)

0:31 Raynes: Actually, it's in core.

0:31 * Raynes could have swore it was in clojure.java.io

0:31 laurus: So you would recommend switching the build system to one that is extensible.

0:32 Raynes: Well, you'd have to look at cake and Leiningen to decide for yourself, but I believe that most of what you can do with cljr, you can also do with cake.

0:32 Especially with the global project.

0:32 laurus: Okay, cool!

0:32 Raynes: It's worth checking out and seeing if it'll do, anyway.

0:33 laurus: Wait, one other question

0:33 Raynes: Cake isn't really a build system. It's just a REPL and package manager thingy.

0:33 laurus: Is there a way to pass in the function that I want to wrap the code in in the command line and then utilize it from within the program?

0:33 I'm not good enough at Clojure yet to figure that out myself

0:34 I don't even know if that's good practice, to turn a string into a function like that...

0:34 Raynes: (eval (read-string "(fn [x] (println x))"))

0:35 http://gist.github.com/591143

0:35 laurus: What exactly is read-string? I see the docs but I don't get it.

0:36 Raynes: It just reads an object from a string. In this case, it's reading a list.

0:36 scottj: ,(read-string "(+ 1 1)")

0:36 clojurebot: (+ 1 1)

0:36 laurus: So in other words, it turns a string into actual Clojure code.

0:36 Raynes: Pretty much.

0:36 laurus: The word "object" there kind of confused me. :P

0:36 scottj: into the actual datastructure

0:36 laurus: And then eval runs that code.

0:36 Raynes: -> (read-string "{:blah \"hai\"}")

0:36 sexpbot: ⟹ {:blah "hai"}

0:36 scottj: ,(first (read-string "(+ 1 1)"))

0:36 clojurebot: +

0:36 Raynes: -> (:blah (read-string "{:blah \"hai\"}"))

0:36 sexpbot: ⟹ "hai"

0:37 rickmode: Preconditions and postconditions do not work for protocol methods. Is this correct?

0:37 mabes: rickmode: I believe that is the case.. I haven't tried it though

0:37 laurus: What I was doing is this: (clojure.contrib.duck-streams/spit (first *command-line-args*) (list 1 2 3 4)) for example

0:37 Raynes: laurus: read-string reads in the list, and then eval evaluates it as code.

0:38 laurus: Since it's passing the output file as the first command line argument

0:38 So I would just run (eval (read-string thesecondargument) therestofthecode) :P

0:39 Er

0:39 Raynes: ((eval (read-string thesecondargument)) therestofthecode)

0:39 rickmode: wabes: I tried to use one, and it *looks* right, but doesn't have any effect, so was double checking. it makes sense though, since a method is different beast than a fn

0:39 laurus: But the problem is how does it know what the rest of the code is? :P

0:40 It's running that code itself, as a file

0:40 And this eval function is being passed to that file as an argument

0:40 Raynes: I'm not sure I understand what you're asking.

0:40 laurus: I'm sorry, it's really weird

0:40 Do you use Emacs by the way Raynes?

0:41 The command I have so far in ELisp is this: (cmd (concat "cljr run " (or cmdline "") in-file " " out-file)))

0:41 Raynes: The (eval (read-string ..)) if what read-string is reading is a function ("(fn ..)") then it will evaluate to a function which is then called on therestofthecode

0:41 And yeah, I use Emacs.

0:41 laurus: Right, I understand that

0:41 Raynes: is*

0:42 laurus: The question is how do I fit that into that ELisp line I just wrote there

0:42 Because it's running in-file, so out-file is the first argument to in-file

0:42 I think this may be impossible...

0:43 * Raynes is confused.

0:43 laurus: Do you see what the problem is? It's impossible to run that eval from outside the Clojure code since the Clojure code is already in a file

0:43 I think, at least.

0:44 I think I'd better just use one of the other build systems.

0:44 :P

0:44 Otherwise, in every code block, I'd have to insert that eval bit.

0:45 Raynes: I think I just misunderstood your question.

0:45 laurus: I think I asked it really badly

0:45 bhenry: how can i turn (map :weight answers) into a set

0:45 laurus: What you told me is what I asked for, I just didn't realize the major problem with the whole idea

0:45 Raynes: (into #{} (map :weight answers))

0:46 chouser: ,(set [1 2 3 4])

0:46 clojurebot: #{1 2 3 4}

0:46 Raynes: Or that.

0:46 laurus: But thanks Rayes, working through it like this with you made me realize it's impossible to do what I'm trying to do with cljr :P

0:46 So cake here I come!

0:46 bhenry: thanks guys

0:46 Raynes: chouser: I thought into was the primary way to get one collection out of another?

0:47 chouser: Raynes: yeah, it is. And nothing wrong with using it in this case.

0:47 Raynes: Yay!

0:47 chouser: but there are a couple fns just for building a collection from nothing: vec, set, list

0:48 Raynes: -> (list [1 2 3])

0:48 sexpbot: ⟹ ([1 2 3])

0:48 chouser: hm

0:48 right, not list. :-)

0:48 Raynes: Not quite.

0:48 :p

0:48 technomancy: man... it's so weird looking at leiningen and having other people apply pull requests for me.

0:48 love it

0:49 chouser: technomancy: watchout, man, that mass is critical!

0:49 laurus: Oops, "sudo aptitude install gem" just installed the "Graphics Environment for Multimedia" on Debian :P

0:50 TheBusby: the droids you are looking for are "rubygems"

0:50 laurus: TheBusby, just installed that, thanks ;)

0:50 That often happens on Debian, it's so amusing

0:51 technomancy: debian is trying to protect you from rubygems

0:51 Raynes: laurus: I did that exact same thing once.

0:51 TheBusby: I can imagine a context sensitive apt-get in the future, MS Bob's evil twin?

0:51 laurus: :D

0:52 bhenry: ,(apply list [1 2 3])

0:52 clojurebot: (1 2 3)

0:52 Raynes: -> (into '() [1 2 3])

0:52 sexpbot: ⟹ (3 2 1)

0:53 bhenry: -> (into () [1 2 3])

0:53 sexpbot: ⟹ (3 2 1)

0:53 laurus: I've never looked at ruby code before, interesting.

0:53 bhenry: don't need to quote empty list as it evals to itself

0:53 Raynes: I concede.

0:54 phobbs: ruby isn't that interesting imo... just clean

0:54 TheBusby: → (into () [1 2 3])

0:54 laurus: Raynes, how does one edit the global project.clj file? Does it exist as such?

0:54 Never mind, sorry.

0:54 ~/.cake/tasks.clj

0:54 clojurebot: I don't understand.

0:55 * laurus hits himself on the head for asking questions before reading the README.

0:55 Raynes: :p

0:55 laurus: I wonder if anyone would be interested in this alternative org babel clojure mode

0:56 It's really hacky and doesn't serve much purpose except to satisfy my own OCD-ness

0:59 Thanks for the help Raynes!

1:02 technomancy: would people like it if lein's test task took regex arguments to match against all test namespaces?

1:03 actually wait that's pretty lame compared to test classifiers. scratch that.

1:05 dysinger: so I don't see a solution for proxying a factory-method generated Javaland nugget

1:06 I will just have to wait methinks until proxy supports that

1:07 __ the person(s) that wrote cake realize that coffe-script build files are called cake also right ?

1:07 s/coffe-script/coffee-script

1:11 http://jashkenas.github.com/coffee-script/documentation/docs/cake.html

1:26 scottj: if cakephp wasn't good enough to dissuade I doubt that would be

1:27 when I read proxying a factory-method I totally thought of a starcraft rush

1:31 chouser: dysinger: ah, yeah it's not that kind of proxy

1:32 dysinger: you want like an instance delegator?

1:34 dysinger: y

1:34 chouser: y

1:35 I want proxy but with the ability to call a factory method instead of super constructor

1:40 chouser: hmmm

1:41 seems like it might be fun to build

1:42 the delegate isn't of a final class, is it?

1:53 dysinger: is it acceptable to reflect on every method being forwarded?

2:23 LauJensen: Good morning all

2:23 laurus: Good morning LauJensen :)

2:29 chouser: dysinger: not fun to write. NOT fun.

2:33 LauJensen: chouser: ?!

2:39 cgrand: writing is painful

2:42 zmila: long ago i was writing by pen. now only keyboard

2:44 chouser: dysinger: here's a start: http://gist.github.com/591243

2:44 but it's way past my bedtime, so I'm off...

2:53 phobbs: for some reason my slime repl doesn't load when I compile files or evaluate function definitions...

2:54 does anyone know what could cause this? How can I fix it?

3:47 fliebel: Can any Enlive expert in here enlighten me about doing a conditional prepend? I want to add a div wiht an id to a set of divs only if no such id is already there.

4:22 I wrote this to do the job: (defn containing [selector] (pred #(seq (select % selector))))

4:23 and then use this for prepending: [[:#foo (but (containing [:#bar]))]]

4:23 Or did I just duplicate Enlive behavior?

4:27 cgrand: fliebel: hi

4:27 so you html source is dynamic and you want to add a div if it's missing, right?

4:27 fliebel: yea

4:28 cgrand: I'm looking for something like the idempotent updates :P

4:29 cgrand: Kind of like with PUT and POST. If I run the template twice I want to end up appending only one element.

4:29 cgrand: did we already discuss it?

4:29 ah ok

4:30 "containing" already exists and is named "has"

4:30 fliebel: thanks

4:31 yay, works :)

4:31 cgrand: but no facility for idempotency

4:31 great!

4:32 fliebel: cgrand: the right hand side of a selector basiacally gets the selected nodes, right? So I could write and append-ur-update fn.

4:32 *or

4:34 LauJensen: fliebel: Im tied up with Christophe right now in a conf call, so we're coming and going :|

4:34 fliebel: haha, okay :)

5:09 Raynes: It's disappointing that out of the 23 channels I'm in over three networks, the only activity is in #haskell with the occasional brief burst of yawns in #perl6. :\

5:09 cemerick: Morning. :D

5:14 esj: hi everybody. I'll try contribute a yawn or *gasp* for you Raynes

5:17 cgrand: fliebel: yes you can write such a function

5:17 bobo_: anyone know a good way to convert pdf to .epub? calibre doesnt seem to handle joy of clojure any good and i want to read my book :-(

5:17 Raynes: bobo_: You mentioned something about Irclj a day or two ago. What was that? I kind of forgot. :\

5:18 bobo_: Raynes: to get the key for a channel

5:18 so i can add it as password for my log

5:18 Raynes: Oh yeah.

5:18 bobo_: didnt irssi connect me to #irclj? bah

5:19 Raynes: I'll write that down and see if I can get it done tomorrow.

5:19 bobo_: :-)

5:19 Raynes: Er, later today.

5:19 It's kind of already tomorrow. 4:16am

5:19 bobo_: im in your future, its 11 here

5:19 clojurebot: multimethods is what separates the boys from the men.

5:20 Raynes: I've been working on cake stuff lately.

5:20 cemerick: Raynes: morning :-)

5:20 Raynes: I think I've got like 5 pull requests that need attention in sexpbot.

5:20 * Raynes needs to catch up.

5:21 cemerick: Raynes: have you really been in irc starting at 1AM?

5:22 Raynes: I'm in IRC constantly. I'm on a bnc.

5:22 Unless you mean active.

5:22 fliebel: cgrand: I'm trying to do that now, but I'm struggling to understand Enlive in its full glory. Took me a while to realize whether a function is called, or actually returning the actual function.

5:22 Raynes: Then yes, I haven't been to sleep yet.

5:23 cemerick: almost a crazier schedule than mine :-)

5:23 * esj things sexpbot wrote Raynes...

5:23 Raynes: If you can call what I have a schedule.

5:24 It's a distinct possibility. But if sexpbot wrote me, than who wrote sexpbot?

5:25 esj: this is lisp: its metacircular :)

5:25 fliebel: I think sexpbot was actually written in Perl by some guy on a cloud.

5:26 Raynes: :)

5:30 cgrand: fliebel: (append-or-update ...) must return a function taking a node as its single node

5:33 esj: howdy cgrand

5:35 cgrand: hi esj!

5:40 fliebel: cgrand: I think I got it working :) I'll show you the result in a moment.

5:45 cgrand: http://github.com/pepijndevos/utterson/commit/4a01b10d279bbacb692899e7b2219ecd849d50c6

5:57 cgrand: fliebel: http://github.com/pepijndevos/utterson/commit/4a01b10d279bbacb692899e7b2219ecd849d50c6#commitcomment-152479

6:06 Raynes: ivey: Ping.

6:16 fliebel: cgrand: Thanks :)

6:28 cgrand: Which classloader is Enlive using to find templates?

6:29 neotyk: Hello

6:29 cgrand: Fingerzam: the same as clojure itself

6:29 LauJensen: Fingerzam ? :)

6:29 neotyk: do you know if there is somewhere a video of Rich talk @J1?

6:29 LauJensen: You mean fliebelzam right?

6:29 cgrand: fliebel: that's for you ^^ (damn autocompletion!)

6:30 fliebel: cgrand: My experience so far is that for some reason only clojure.lang.DynamicClassLoader is able to find the file I put on the classpath. So Enlive gives me a NullPointerException :(

6:30 cgrand: clojure.lang.DynamicClassLoader seems to be what the repl and everything loaded outside of ns declarations seem to use.

6:32 ,(.getClassLoader (class (fn [])))

6:32 clojurebot: #<DynamicClassLoader clojure.lang.DynamicClassLoader@352ebe>

6:33 fliebel: ,(.getClassLoader (class ""))

6:33 clojurebot: nil

6:33 fliebel: ,(.getClassLoader (class +))

6:33 clojurebot: java.security.AccessControlException: access denied (java.lang.RuntimePermission getClassLoader)

6:33 LauJensen: fliebel: enlive looks on the cp without any problems

6:34 fliebel: LauJensen: Not for me… at least not in my app, on the repl it works fine because the it's using the dynamic one

6:34 LauJensen: Oh you mean when AOTed?

6:34 fliebel: LauJensen: Yea...

6:36 So either I need to make AppClassLoader understand how to find my file, or I need to make Enlive use DynamicClassLoader.

6:38 This is where it all happens, right? http://github.com/cgrand/enlive/blob/master/src/net/cgrand/enlive_html.clj#L86

6:38 cgrand: fliebel: does (.getParent (.getClassLoader (class (fn [])))) and (.getParent (clojure.lang.RT/baseLoader)) return the same thing in your setup

6:39 fliebel: yes this precise line

6:39 LauJensen: Scala attempts to make Java simpler, here's a status report: http://i.imgur.com/QONqZ.gif

6:40 fliebel: cgrand: On the repl, yes… AOT… I'll see

6:42 AOT: No: #<DynamicClassLoader clojure.lang.DynamicClassLoader@d1a9f20> #<ExtClassLoader sun.misc.Launcher$ExtClassLoader@138d107f>

6:43 cgrand: And apparently ExtClassLoader can't find my files.

6:43 LauJensen: lol

6:46 cgrand: May I suggest you use (clojure.lang.DynamicClassLoader.) instead? Or will that cause havoc elsewhere?

6:46 I've been using it throughout my app without problems.

6:58 cgrand: fliebel: DynamicClassLoader default constructor?

6:59 fliebel: cgrand: I have no idea what I'm doing, I just know it works :)

7:00 cgrand: fliebel: can you try with (alter-var-root clojure.lang.RT/USE_CONTEXT_CLASSLOADER (constantly false)) at the top of your main ns?

7:01 fliebel: sure...

7:02 cgrand: or (alter-var-root *use-context-classloader* (constantly false)) ...

7:02 (same thing)

7:03 fliebel: cgrand: Are you sure? The second gives me a nullpointerexception during compiling.

7:04 the first did just the same as before.

7:05 cgrand: how are you deploying your app?

7:05 fliebel: cake uberjar

7:06 cgrand: so it's a standalone app?

7:06 fliebel: yea, with a separate directory outside the jar with my tamplates

7:06 btw, that code of yours still prints #<DynamicClassLoader clojure.lang.DynamicClassLoader@6908af2a> #<ExtClassLoader sun.misc.Launcher$ExtClassLoader@138d107f>

7:07 cgrand: (my fear with dynamicclassloader is to break things for people running in container -- eg tomcat)

7:08 fliebel: cgrand: I don't know how this stuff works, so I wouldn't be able to say anything useful about that.

7:09 cgrand: Would it be possible to get DynamicClassLoader Ruby-style? I mean, do a defmethod in my own code, or otherwise monkeypatching it.

7:09 LauJensen: fliebel: and you're absolutely sure that the resources are actually on the cp ?

7:09 fliebel: LauJensen: On the repl it works fine

7:10 LauJensen: fliebel: but the repl isn't initialized the same way as a standalone jar

7:10 clojurebot: whose job is<reply>that is xxpors job

7:11 fliebel: LauJensen: /My/ code is using DynamicClassLoader and is able to find the file, even in the jar. But as soon as I put the filename in deftemplate it gives me a NullPointerException.

7:12 LauJensen: fliebel: I guess you could manually try (-> (clojure.lang.RT/baseClassLoader) (.getResource filename)) or something like that. If that does give you a URI to the file, then Enlive is broken

7:17 cgrand: fliebel: or you can defmethod again (defmethod en/get-resource String ...) and it's *real* monkey patching so be cautious

7:17 fliebel: cgrand: Just did that, and it works :)

7:18 But… why aren't defmulti's immutable like the rest?

7:19 cgrand: if they were immutable how would you extend a defmulti?

7:19 fliebel: I don't know… just define them at once like you define a defn with multiple bodies.

7:20 cgrand: a mmethod (lie a protocol) is intended to be extended by others

7:20 fliebel: okay, I like it for now :)

7:22 LauJensen: cgrand: Can you add that to the docs for how to handle the general case of an AOT'ed Enlive app?

7:23 And Im just thinking. I remember doing an AOT'ed enlive app not too long ago, which worked without any problems....

7:23 cgrand: LauJensen: I'm going to investigate and solve the issue (write code or doc)

7:25 LauJensen: cgrand: Why did my app work if AOT is the cause?

7:28 cgrand: fliebel: can your provide me with the command line you are using to laucnh your app? thanks

7:29 fliebel: java -cp examples/testsite:utterson-0.1-standalone.jar utterson.main page index.md

7:31 but wait… there might be another problem… I hate those "helpful" error messages

7:44 cgrand: Guess what was causing an error… ((en/has selector) %)

8:17 cgrand: Oh man, this reminds me so much of the story of my father where they tried to fix some plumbing where the new part was the one that was broken. The NullPointerException wasn't in Enlive. This was entirely my fault, and at the same time entirely yours. You remember that comment on my commit? That suggesting you made throws an exception. The old line works just fine both with and without the custom class loader.

8:31 cgrand: fliebel: grmf :-(

8:32 fliebel: yea :(

8:33 LauJensen: Well, the important thing to remember is that I was right all along :)

9:02 zoldar: hello, I'm trying to wrap my head around clojure.zip. I have made a small function which is supposed to convert an input stree into form that can be evaluated by hiccup's "html". What am I missing here? http://pastebin.com/yKs6EiwX . Any help appreciated.

9:15 konr: I want to build an utility that lists and manages clojure jobs such as web crawling and expensive computations. Is there something like this already coded?

9:17 nlogax: i don't know, but feel free to use this name: cronj

9:17 the jobs could be called cronj obs

9:17 konr: These jobs would be clojure functions, wrapped with stuff like metadata, logging utilities and before-running and after-running functions, so it would be easy to create a coordinating job to, say, rip a website using four connections at any time

9:18 haha

9:18 I thought about juju, too, for Jobs Under JUJU's <something with U>

9:18 nlogax: Umbrella!

9:18 konr: great!

9:33 zoldar: ok I sorted it out, this one works http://pastebin.com/A3CahmRW

9:34 chouser: cemerick: would an external text file serve instead of an inline escape-free string? Why not?

9:35 cemerick: chouser: /facepalm

9:35 Because I shouldn't have to externalize strings just because they have backslashes in them.

9:36 chouser: I'm not arguing against the feature. I'm trying to anticipate anything rhickey might throw at me.

9:36 cemerick: Yeah, I know :-)

9:36 chouser: ok

9:36 cemerick: It seems like such an obvious *want*.

9:37 chouser: so ... what's wrong with externalizing the string? Is it small? Do you have lots of them?

9:37 cemerick: Of course, I think the same of string interpolation, and look where that led. :-/

9:38 chouser: """ is the most obvious contender, but I wish it were a 100% solution. ...but what if you want to stick some clojure or python code in your string, and *that* code has """ too?

9:38 cemerick: Yeah, I just wrote a few unit tests that deal with escaping of quotes in strings. It didn't take me long, but it took me a lot longer because I mistyped a \\\" sequence.

9:38 chouser: bleh

9:39 cemerick: Rich is *never* going to go for """

9:39 chouser: really?

9:39 that's ... unfortunate.

9:39 cemerick: I'd think not. Very syntaxy.

9:40 chouser: hm

9:40 cemerick: though, he did do the ^:private thing, or whatever that panned out to be.

9:41 #\" seems more appropriate, and fewer characters to boot.

9:41 Tools would just *love* that. :-P

9:42 chouser: I don't understand. What would terminate it?

9:45 cemerick: A proper unicode quotation mark ”

9:45 ;-)

9:46 I type here first, then think. #\" wouldn't work.

9:47 #|symbol with spaces| has been suggested before, and is found in other lisps. Perhaps #|"string data"|?

9:51 fliebel: Or how about $ as a macro for symbol? $"php and perl users are going to love this"

9:51 cemerick: $ will always remind me of my C-64.

9:51 chouser: fliebel: still need something other than " to terminate or we're no better off

9:51 "| is an interesting terminator

9:52 fliebel: so you could do $:keyword or even $@some IDeref

9:52 or $@#* to dereference a regex stored as * and turn it into a symbol.

9:52 cemerick: chouser: Which casts #|foo bar| as a very particular sort of unescaping, if one wants to draw that tenuous connection.

9:54 fliebel: People already kno $ for symbols, with #|ruby users| will think a block is coming :P

9:54 chouser: I didn;t follow the entire discussion, what's wrong with "?

9:55 cemerick: fliebel: we're trying to avoid stuff like

9:55 ,"\\\""

9:55 clojurebot: "\\\""

9:56 fliebel: cemerick: What, you mean for people wanting to have \" as a symbol?

9:56 cemerick: no, to avoid escaping \ and " entirely

9:57 Roughly equivalent to r"""string data""" in python, I'd say.

9:57 fliebel: okay, so what we need is arbitrary string terminators, like in PHP

9:58 or… why allow symbols with spaces and stuff in the first place?

9:59 cemerick: well, we weren't talking about symbols at all

9:59 fliebel: oh, just strings?

9:59 cemerick: but symbols with spaces in them are occasionally very handy

9:59 chouser: cemerick: that's some kind of ruby/python hybrid you've got there

9:59 cemerick: chouser: oh?

10:00 fliebel: chouser: Python has raw strings (as well?)

10:00 chouser: oh, you may be right.

10:00 cemerick: yeah: r"""hello\there""" => 'hello\\there'

10:00 * cemerick hasn't forgotten all of his python gyet

10:00 cemerick: s/gyet/yet

10:01 chouser: oh, ruby uses %r{...} for regex

10:01 cemerick: yikes

10:01 fliebel: But in Python you can only use """ als this kind of strings, so you're still screwed if you want a string containing """

10:01 cemerick: don't they have r/foo/ or something?

10:02 chouser: fliebel: right. a 95% solution

10:02 fliebel: In PHP you can use three of anything as a string terminator, only the syntax is ugly.

10:02 chouser: cemerick: yes, ruby does the perl thing of choose-your-own-terminator

10:02 which has a kind of elegence, but rhickey seems to dislike it

10:03 cemerick: I agree with him there. A high bar for tools.

10:03 chouser: nonsense, but whatever.

10:03 bobo_: probably a stupid question, but why not just a funktion for it?

10:03 fliebel: a high bar for newlings

10:03 cemerick: chouser: well, insofar as a lot of tools have quickie syntax frameworks that are driven by regexes....

10:04 chouser: I can understand disliking it, but I think the tool complaint is a fig leaf. or a red herring...

10:04 fliebel: bobo_: What would you put in the function?

10:04 bobo_: fliebel: i realised that pretty much as i pressed enter

10:04 chouser: cemerick: regexs have no problem with that kind of backreference

10:04 cemerick: chouser: depends on what regex engine you've got to work with?

10:04 fliebel: yea something like .{3}.*.{3)

10:05 chouser: cemerick: not really. what tool can't highlight ruby or perl?

10:05 fliebel: bobo_: You could just use str and put the quotes inbetween as a char maybe.

10:05 chouser: but that's fine. "I don't like it" or "seems wishy washy" is sufficient.

10:06 cemerick: chouser: I thought only vim could highlight perl? Everything else just crashes on my machine. :-)

10:06 chouser: heh

10:06 well, perl does have issues, but not usually around delimited quotes.

10:07 usually more around whether m/a is division or a regex.

10:08 fliebel: <crazy idea>What about prefixing strings with a regex to match their own delimiters</crazy idea> That is almost perl-style

10:08 chouser: anyway, I just added clojure and another language to a syntax highlighting too last week. configurable quotes would have been significantly less tricky than multi-line string literals were.

10:09 cemerick: fliebel: holy jeebus, you're nuts. :-)

10:09 chouser: fliebel: the primary obstacle we have to overcome is rhickey's general distain for all things stringy. Nice try though. :-)

10:10 disdain

10:10 cemerick: how about #name-of-fn-to-parse-following-string"foo"

10:10 Just get it over with, etc.

10:11 chouser: yeah! if we can slip reader macros in like that, I'd be very happy.

10:11 cemerick: s/parse/tokenize

10:12 chouser: but now we can talk about tooling issues.

10:12 ...no correct syntax highlighters unless they can eval clojure code.

10:13 cemerick: Surely there's a regex engine that can eval clojure code?

10:13 pfhhht.

10:13 * cemerick needs a drink.

10:15 _fogus_: cemerick: it's 5 o'clock somewhere

10:16 cemerick: _fogus_: noon would be sufficient per my handy Irish-influenced well-lubricated New England folk morals handbook. ;-)

10:16 bobo_: its almost 5 here... :-)

10:19 chouser: with #|"foo"| we could potentially allow for nesting: #|"list|of|"things"|here"|

10:20 _fogus_: The bar is sorely underused in PL syntax

10:24 cemerick: Assuming #|foo| eventually arrives for arbitrary symbols, I wonder if #|"foo"| is too similar, just in terms of legibility.

10:25 chouser: I don't think that would be a problem. The similarity makes a kind of semantic sense

10:25 and we already have very different meanings for the somewhat similar (), #(), {}, and #{}

10:25 cemerick: Exactly why I suggested it.

10:25 That's true

10:25 nm then

10:32 fliebel: I think arbitrary delimiters is the only way without just postponing the problem.

10:34 dpritchett: Is there any stated timeline for clojure-cljr development? I'm sure it's not a top priority with all the momentum behind the jvm and clojure-in-clojure efforts but i'm still curious

10:44 fliebel: Has anyone ever written a nio WatchService in Clojure?

10:46 chouser: fliebel: no, but before I knew about that I made a linux-specific lib to do something similar on top of jna

10:50 fliebel: chouser: So what is the way to go for Java 6?

10:50 chouser: oh, is WatchService not in 6?

10:50 fliebel: I think it's a nio.2 feature for 7

10:52 chouser: hm, indeed "Since 1.7"

10:52 fliebel: you don't want linux-specific? :-)

10:53 fliebel: chouser: Add at least Mac :P

10:53 I did find this: http://jnotify.sourceforge.net/

10:55 chouser: looks like this might be an option as well: http://jpathwatch.wordpress.com/

11:41 bhenry: can anyone take a look at this function? https://gist.github.com/91de400e806503b4ba3c select-ans and deselect-ans are just shortcuts to assoc calls. i feel like the select-answer function is longer than necessary.

11:42 fliebel: bhenry: Have you tried bending reduce to your will?

11:43 bhenry: fliebel: nope.

11:44 chouser: you want all the matching weights, right?

11:45 bhenry: i want to change the :selected attribute based on a matching weight. if for some reason a weight gets in the call with no answer having that weight, i want to return the original answer

11:46 return the original answer-set*

11:49 laurus: I have a Clojure program I'm running on the command line, passing in a filename as an argument. I'd like to dump out the return value of the program, as well as anything printed as side-effects, into that file. I have been using spit, but it doesn't work with writing the side effects to that file. How can I do this?

11:51 mrBliss: laurus: (binding [*out* (writer ...)] (println "bla"))

11:51 laurus: mrBliss, well I'd like to wrap the entire program in one function call

11:51 apgwoz: ,(let [aset [{:weight 1.1} {:weight 2.2}]] (or (first (keep-indexed #(= (:weight %) 1.1) aset]) aset))

11:51 clojurebot: Unmatched delimiter: ]

11:52 apgwoz: ,(let [aset [{:weight 1.1} {:weight 2.2}]] (or (first (keep-indexed #(= (:weight %) 1.1) aset)) aset))

11:52 clojurebot: java.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong number of args (2) passed to: sandbox$eval7455$fn

11:53 mrBliss: laurus: can't you just do (defn f-name [] (binding [..] -function-))?

11:53 apgwoz: bhenry: i'd have thought the above would work... but, apparently i'm being lame and doing something wrong

11:53 laurus: mrBliss, I'm a beginner at Clojure, hehe

11:53 So I don't actually know a lot of this

11:54 mrBliss: laurus: np! I wasn't sure if I understood your question :)

11:54 chouser: bhenry: since you want different behavior for the first element depending on values of later elements, something's going to have to scan the whole list before going through and mapping on each item.

11:54 laurus: Basically let's say I have two things: (println "Hello") and then on the next line, (list 1 2 3 4)

11:55 Those two lines of code comprise a .clj file

11:55 I want to be able to wrap that "program" in one function, that takes one argument, a filename

11:55 That filename is the file that the output will go to, both any printlns and the return values

11:55 So the question is, what does that function need to look like? :p

11:55 fliebel: laurus: Put the above binding with *out* in a fn that call load-file on the argmuent.

11:55 chouser: bhenry: (defn select-answer [a-set weight] (let [foundseq (map #(== (:weight %) weight) a-set)] (if (every? false? foundseq) a-set (map #(if %1 (select-ans %2) (deselect-ans %2)) foundseq a-set))))

11:56 bhenry: or: (defn select-answer [a-set weight] (if (not-any? #(== (:weight %) weight) a-set) a-set (map #(if (== (:weight %) weight) (select-ans %) (deselect-ans %)) a-set)))

11:56 mrBliss: laurus: put (list 1 2 3 4) in a println?

11:57 laurus: mrBliss, no

11:57 apgwoz: oh, i'm a moron. keep-indexed uses a function arity 2.

11:57 bhenry: chouser:

11:57 (defn select-answer2 [answers weight]

11:57 (let [new-answers (map #(if (= (:weight %) weight)

11:57 (select-ans %)

11:57 (deselect-ans %)) answers)]

11:57 (if (empty? (filter :selected new-answers))

11:57 answers

11:57 laurus: I want both the side effects and the return values to be "logged" to a file

11:57 bhenry: new-answers)))

11:58 laurus: fliebel, let me try that, thanks

11:58 mrBliss: laurus: this might do the trick (modify it a bit) (defmacro dbg [x] `(let [x# ~x] (println "dbg:" '~x "=" x#) x#))

11:59 chouser: bhenry: sure. btw, use == for numbers. and not-any? instead of empty? filter

12:00 laurus: fliebel, in that binding, what should "writer" be?

12:00 bhenry: yeah i liked your second answer. will == fail if i pass an int trying to match a float?

12:00 chouser ^

12:00 chouser: bhenry: no, but = will in Clojure 1.3

12:00 kevinclark: chouser: what's the difference between == and =?

12:00 object equality vs value equality?

12:01 chouser: == is for numbers, = is for other things

12:01 details beyond that depend on which version of Clojure you're talking about

12:02 mrBliss: laurus: (defmacro print-eval [x] `(let [x# ~x] (println '~x) x#))

12:02 laurus: (print-eval (list 1 2 3)) will print (list 1 2 3) and evaluate it

12:02 kevinclark: chouser: is it changing for 1.3? Any idea if the 1.2 semantics are stable?

12:02 (in this case)

12:02 fliebel: laurus: I think it's clojure.java.io/reader or something int that package.

12:03 laurus: mrBliss, ah, that's interesting

12:03 fliebel: *namespace

12:03 laurus: mrBliss, I think the first code you wrote is closest to what I need actually

12:03 (binding [*out* (writer ...)] ...

12:05 chouser: kevinclark: rhickey wrote it up somewhere, but I'm not sure where

12:06 kevinclark: chouser: ok, I'll google for it. thanks

12:07 chouser: https://www.assembla.com/wiki/show/b4-TTcvBSr3RAZeJe5aVNr/Enhanced_Primitive_Support

12:07 arohner: technomancy: re: the patch that uses wall-hack-method, is it ok to just copy the function into lein? Otherwise I'm basically just reimplementing wall-hack-method

12:07 chouser: arohner: that's in clojure.contrib.reflect

12:08 arohner: chouser: yes. I used it in a patch for lein, while lein dropped its dependency on contrib

12:08 chouser: ah

12:08 arohner: since they're both EPL...

12:08 technomancy: arohner: is it possible the bug you're working around has been fixed in a newer maven-ant-tasks?

12:08 kevinclark: chouser: oh, cool, thanks

12:09 arohner: technomancy: possibly. I thought you were stuck on that version because of some other bug?

12:09 chouser: kevinclark: I *think* the top one "equiv" is what's in master now

12:10 laurus: Is there a version of spit that appends to a file rather than overwriting it?

12:10 technomancy: arohner: someone gave me the impression the other one may have been fixed; can't remember the details =\ plus the guy doing debian packaging wanted to pull in a newer one, so I kind of want to revisit that

12:11 laurus: Ah, append-spit.

12:11 arohner: technomancy: I'll check out the source of the newest ant tasks, see if it's fixed there

12:12 laurus: Er, spit-append.

12:12 technomancy: arohner: that'd be grand; thanks

12:13 laurus: Er, what?

12:13 Does that function still exist?

12:13 arohner: technomancy: not fixed. Another hack is to call a public method that I know calls getContainer(), but that's...

12:15 mrBliss: laurus: it's still in clojure.contrib.io

12:16 laurus: Thanks :)

12:16 technomancy: arohner: what does the other method do? as long as it's well-explained in the comments we should be able to trace it down once we do upgrade in case the behavioru changes

12:17 arohner: the one I would call, getSupportedProtocols() just returns an array of strings of protocols the task knows how to download over

12:20 technomancy: sounds like the lesser of two evils

12:21 arohner: technomancy: ok

12:24 alexyk: dnolen: any luck with cake 0.4.16*?

12:24 ninjudd: cake install from today's pull of 0.4.16 created a file cake/0.4.16 instead of a directory, had to manually remove and repeat cake install to finish

12:24 (in maven repo)

12:25 dnolen: alexyk: nope, didn't have time to check it out yesterday, did you try 0.4.15?

12:25 alexyk: dnolen: I was asking ninjudd how can I fall back on the 0.4.15 jar I have in the maven repo...

12:29 laurus: I thought spit closed the file when it was done with it, but I'm getting "java.lang.Exception: Cannot change an open stream to append mode." when I try to run clojure.contrib.io/append-spit on the same file. Why?

12:31 mrBliss: laurus: when append-spit is in the scope of spit (handling the same file)

12:31 laurus: mrBliss, but I thought spit closed the file.

12:31 Also, it's in a completely separate function

12:32 mrBliss: after the ) matching (spit ...

12:32 laurus: mrBliss, I have: http://paste.lisp.org/submit

12:32 Er

12:32 :P

12:32 http://paste.lisp.org/display/114781

12:33 mrBliss: mmm, looks fine

12:34 laurus: Right, but I'm getting "java.lang.Exception: Cannot change an open stream to append mode."

12:34 Maybe a bug?

12:34 mrBliss: maybe you opened the file before (in the REPL) with a reader without closing it ?

12:35 laurus: No, even if I run it as a standalone file it happens.

12:37 mrBliss: laurus: I think with-out-str is the problem

12:38 when I execute your code and look in hello.txt, I only see "yo"

12:39 laurus: That's because the bug hits before it finishes, I think

12:39 Be right back, sorry!

12:39 arohner: technomancy: how do you attach a second pull request to an issue?

12:40 technomancy: http://github.com/arohner/leiningen/commit/b5ebd46ea1464841b1def4bea549a786940dcd86

12:46 mrBliss: laurus: I think it's a bug in append-spit http://clojure-log.n01se.net/date/2010-08-04.html#09:10

12:47 bhenry: laurus: with-out-str only returns results of print statements within. it's going to give "yo" to the spit call and that's it. (unrelated to the error message)

12:52 alexyk: with today's cake pull of 0.4.16, I get class not found on: org.apache.tools.ant.Project

12:52 anybody else? where does this live in? some ant version?

13:04 laurus: mrBliss, ah, thank you :)

13:06 mrBliss, I think I'll play around with that macro you pasted and try to use that: (defmacro print-eval [x] `(let [x# ~x] (println '~x) x#))

13:06 Thanks for the help!

13:06 mrBliss: np

13:20 ohpauleez: Does Bradford Cross hangout in here?

13:21 alexyk: dnolen: where does cake/*env* is set? it's nil which causes my errors

13:22 ninjudd: cake/*env* is nil in 0.4.16...

13:23 dnolen: alexyk: ah yes that got renamed.

13:37 jashmenn: sorry, noob question here, but is there a way to get the effect of (:require ... :as ...) with (:import) ?

13:38 e.g. :import a java class but alias it with :as

13:38 chouser: no, there's currently no way to alias a java class

13:38 though it's a frequently requested feature.

13:38 jashmenn: okay, np. just wanted to make sure i wasn't missing something obvious

13:38 thanks

13:39 chouser: I've been known to write macros to get around particularly long class names.

13:42 LauJensen: chouser has been known to write macros for most things actually :)

13:42 chouser: :-D

13:49 technomancy: I think I just saw an instance where a namespace showed up in a stack trace that hadn't been loaded yet.

13:53 ohpauleez: I think there may be a bug in repl-utils in 1.3

13:53 I haven't looked into too much, but show is throwing an exception regarding the lt stuff

13:53 (NoSuchMethod)

13:54 chouser: ohpauleez: I was seeing that before, but I think I fixed it. or something.

13:54 ohpauleez: chouser: Let me re pull my deps. I noticed it two days ago and made a note to look into it more

13:55 chouser: yeah, I pushed a commit on Thursday

13:55 ohpauleez: Awesome (I was secretly hoping I was going to get to write the simple patch:) )

14:10 jweiss: i know i saw docs somewhere on what legal names are for clojure identifiers

14:11 chouser: clojure.org/reader I think

14:12 jweiss: the rules for symbols?

14:12 chouser: yeah

14:12 jweiss: k thanks

14:22 alexyk: dnolen: I'm back... so you use cake/*env* everywhere! no surprise then it causes errors :)

14:23 dnolen: alexyk: well that's there in the official cake release, will change when they roll out the next version.

14:31 alexyk: dnolen: 0.4.16 is out

14:37 dnolen: alexyk: ahh, k, fixed on master

14:40 alexyk: dnolen: should I pull the master then as well?

14:41 dnolen: alexyk: aria42 merged master, and I think the likelihood of mcgrana taking our fairly major changes is slim, so we're on master now.

14:43 alexyk: dnolen: uff, finally works. You had me see the guts of your bundle now. :)

14:44 ^X is fun

14:44 dnolen: alexyk: good :) Maybe you'll start sending us patches :) Yeah the project needs a bit of cleanup now.

14:44 alexyk: yes.

14:45 alexyk: dnolen: I wonder what happens with franks42 etc. There should be a consensus... Let's create a google group?

14:45 fliebel: dnolen, alexyk: Is this about Ring, or some other project?

14:45 dnolen: alexyk: I think that's a good idea.

14:46 fliebel: SLIME-y TextMate bundle for Clojure

14:46 alexyk: fliebel: TextMate plugin with cake

14:46 rickmode: Is there any push to "normalize" the differences between the java interop kinda things and the lisp things? Example: use vs import; functions vs methods. I like the Lisp style more-so than the Java interop style. More importantly, I dislike the syntax differences.

14:46 fliebel: Ah, nice :)

14:47 alexyk: dnolen: textmate-clojure or clojure-textmate? That is the question :)

14:47 dnolen: alexyk: noooooooooooooooooooooo ... :)

14:47 alexyk: the deepest question of all double things...

14:47 kotarak: rickmode: syntax difference? (fn-with some args) (.method-with some args)?

14:47 technomancy: "Programming Clojure" or "Clojure Programming"?

14:47 "Programming Scala" or "Programming Scala" or "Programming in Scala"?

14:47 alexyk: technomancy: this is religious

14:48 "In Clojure we Program"

14:48 technomancy: alexyk: I was refering to book titles actually

14:48 rickmode: kotarak: more like (defn foo "comment" [x y] {:pre [test]} ...) vs within a defrecord / deftype (foo [this x y] ...)

14:48 alexyk: technomancy: I understand

14:49 technomancy: so words should be used which don't allow reshuffling, like "the joy of clojure" or "on clojure"

14:49 kotarak: rickmode: nobody forces you to write inline methods. You can write them as normal functions and extend the protocol to the type with extend.

14:50 ninjudd: technomancy: i prefer programming books that don't have the word Programming in the title

14:50 alexyk: dnolen: textmate-clojure seems right, like your project suggests, since TextMate is primary here

14:50 ninjudd: we fixed TM-cake. cake/*env* was to blame

14:51 ninjudd: why, oh why did you rename *env* to *shell-env*?

14:51 rickmode: kotarak: I haven't explored that. I have a sneaking suspicion my current use of protocols and defrecord isn't ideal anyway as I get over my OO-hangover

14:51 ninjudd: ah yes. dnolen: did lancepantz warn you about that?

14:51 dnolen: ninjudd: yes, but been a bit too busy to act on it sooner.

14:51 * alexyk sends the bills to ninjudd and dnolen

14:52 alexyk: N hours at M $$/hour...

14:52 ninjudd: alexyk: lancepantz is the one who made the change. send the bill to him

14:52 alexyk: ok

14:53 kotarak: rickmode: shameless self promotion: http://bit.ly/c7R5pJ This might help. Although the colorscheme seems to be the most interesting aspect..

14:53 ninjudd: alexyk: sorry about that. did you post a trace yesterday?

14:53 alexyk: unix is always ENV, WTF is *shell-env*? it's $ENV etc everywhere

14:53 kotarak: rickmode: it explains the trade-offs for inline vs. extend

14:53 alexyk: ninjudd: it was hard to catch from TextMate's guts

14:54 but, I saw the beauty of dnolen's bundle, implemented itself in Ruby stubs and Clojure innards, like cake itself

14:54 rickmode: kotarak: cool. so far I've been trying to grok protocols and datatypes reading "Joy of Clojure".

14:54 ninjudd: ah kotarak, that's your blog. your entries on gen-class and proxy were very useful to me!

14:54 kotarak: ninjudd: you are welcome

14:55 ninjudd: and the color scheme is nice too ;-)

14:55 kotarak: rickmode: joy of clojure is not necessaritly an introductory text as far as I understoof

14:55 dnolen: alexky: that's the nice thing about the Clojure bundle, nearly 100% clojure. No reason not to contribute.

14:56 dsop: is there a recording of ricks talk at javaone?

14:57 rickmode: koyarak: no... I read "programmign clojure" and most of "practical common lisp" before it

14:58 and "the little schemer"

14:58 I've done OO programing for most of the last 20 years... I'm trying to rewire my brain ;)

14:58 kotarak: rickmode: yeah. That's a task. :)

15:02 rickmode: kotarak: i'm getting there.... though, as I said, I seem to be falling into the trap of using defprotocol and defrecord as a flat inheritance mechanism. I suspect this will eventually become a clojure anti-pattern

15:09 amalloy: dsop: wasn't the clojure talk at javaone cancelled?

15:10 dsop: I just saw a tweet that he presented clojure

15:14 _fogus_: kotarak: No love for Common Lisp?

15:15 kotarak: _fogus_: not really. I fail to appreciate it's beauty.

15:15 _fogus_: kotarak: Anything in particular?

15:16 kotarak: For example this Lisp-2 stuff. I prefer Scheme and Clojure in this respect.

15:17 technomancy: I always have to laugh at the alphabet-soup function naming.

15:17 cemerick: AND-ALL-CAPS

15:17 technomancy: get the feeling it was optimized for Wheel of Fortune.

15:18 kotarak: Ah yes. This ALL-CAPS stuff is ridiculuous. lower-case is much better to read. And names like car, cdr and cadadadadr... pfff

15:18 duncanm: la la la

15:18 kotarak: I like Clojure's attitude to break with the "tradition".

15:19 _fogus_: CL has first and rest also. In fact, I think they are the more accurate than car/cdr

15:19 cemerick: the declare, proclaim, and declaim stuff was mind-boggling as well.

15:20 bhenry: easiest way to get a one in ten probability of truthy in a random value. go!

15:20 duncanm: i'm trying to come up with a nice expression to count the number of items (in some range) from a matrix that looks like ([a b c ...] ...)

15:21 so i'd end up with something like {:one-to-five 5 :six-to-ten 0 }

15:21 chouser: ,(zero (rand-int 10))

15:21 clojurebot: java.lang.Exception: Unable to resolve symbol: zero in this context

15:22 chouser: ,(zero? (rand-int 10))

15:22 clojurebot: false

15:22 _fogus_: I think much of what people dislike about CL has more to do with reading poorly written code

15:23 cemerick: all caps?

15:23 bhenry: oh chouser you always come up with something better.

15:23 cemerick: _fogus_: yeah, what about it?

15:23 kotarak: _fogus_: maybe (do you consider On Lisp badly written code?). Maybe also the difference in atmosphere in c.l.l and g.g.c.

15:24 chouser: bhenry: you want something better than that?

15:24 cemerick: AFAIRemember, only lispworks has a case-sensitive mode, and it's semi-broken (or had some niggling issue the last time I looked at it)

15:24 _fogus_: kotarak: I would say On Lisp is not representative of Common Lisp style at all

15:25 bhenry: chouser no, yours was way better than mine. as usual

15:25 chouser: bhenry: heh, oh I see. sorry.

15:25 cemerick: how about...

15:25 ,(< (rand) 0.1)

15:25 clojurebot: false

15:25 bhenry: pretty good.

15:26 cemerick: not as good for reading, though :-)

15:26 _fogus_: cemerick: I can't speak for LispWorks, but AFAIK no CL implementation requires all caps. They do tend to print at the REPL in all caps, but that is representational only.

15:26 bhenry: that's what i was thinking.

15:28 _fogus_: kotarak: I will not say that Common Lisp is perfect, but much of the "ugliness" derives from a culture of creating control structures that are easy for macro writers to reason about rather than end users.

15:29 kotarak: _fogus_: you don't have to defend CL. It's not in the dock.

15:29 _fogus_: dock?

15:30 chouser: on trial?

15:30 kotarak: according to dict.leo.org this means "Anklagebank".

15:30 chouser: right

15:31 cemerick: kotarak: "on the docket", I think you're looking for :-)

15:31 kotarak: _fogus_: I don't appreciate its beauty. But I also don't appreciate the beauty of van Gogh's paintings.

15:31 _fogus_: kotarak: Fair enough.

15:31 kotarak: _fogus_: the world won't stiop turning.

15:31 _fogus_: well that a relief

15:31 cemerick: _fogus_: I guess I've forgotten what my specific beef was. I was doing a pile of XML the last time I was futzing with CL, and I suspect that tag names were being upcased or something.... *shrug*

15:33 kotarak: cemerick: will have a look at nREPL

15:34 cemerick: kotarak: many thanks. I hope it'll be helpful. I've yet to add good launching mechanisms, but that's up next.

15:35 amalloy: ,(count (filter (apply hash-set (range 1 5)) (range 1 10)))

15:35 clojurebot: 4

15:35 amalloy: duncanm: ^^

15:42 _schulte_: hi, I often find myself using (apply hash-map (apply concat (map...))) to convert the resutls of a map to a hash, is there a better(idiomatic) way?

15:43 chouser: ,(apply hash-map (apply concat (map identity [[1 2] [3 4] [5 6]])))

15:43 clojurebot: {1 2, 3 4, 5 6}

15:43 chouser: ,(into {} [[1 2] [3 4] [5 6]])

15:43 clojurebot: {1 2, 3 4, 5 6}

15:43 mrBliss: mapcat is shorter than (apply concat (map ..

15:43 _schulte_: thanks I'll look into `into'

15:44 andyfingerhut: Basic question here. I know how to get the latest clojure and clojure-contrib from github. I can build clojure. For clojure-contrib, the readme file says to use 'mvn install' to build it. When I do that, it seems to pull down and use clojure-1.2.0 to do that compilation. How can I build clojure-contrib using the latest clojure compiler?

15:46 LauJensen: cemerick: ^^ your monster is acting up again

15:47 cemerick: LauJensen: heh, nREPL isn't a monster yet :-)

15:48 LauJensen: cemerick: nREPL? I meant Maven of course

15:48 cemerick: I don't think I mentioned maven at all?

15:48 * _fogus_ is feeling argumentative today

15:49 amalloy: _fogus_: i think trailing parens should go on their own lines

15:49 cemerick: _fogus_: you can blame it on my earlier pissyness :-P

15:49 _fogus_: amalloy: not about *that* topic however. ;-)

15:49 ohpauleez: hahaha

15:50 _fogus_: cemerick: first drink is on me then. that should soften me up a bit. :p

15:50 ohpauleez: I like when these conversations happen in this channel

15:50 LauJensen: cemerick: andyfingerhut has tried building contrib with maven, that naturally fails, thus Im directing your attention to it since all problems related to Maven are you doing, right?

15:50 ohpauleez: it cracks me up every time

15:50 can we start talking about AwesomeWM again and window managers in general?

15:51 cemerick: LauJensen: if it makes you feel better, then yes, you can blame all maven problems everywhere on me

15:51 LauJensen: ohpauleez: Naah, its time for another round of Emacs vs Vi

15:51 ohpauleez: LauJensen: You're on

15:51 cemerick: _fogus_: kamaikazes all around, then.

15:51 amalloy: LauJensen: you use an editor? i write my clojure with cat from the command line

15:51 LauJensen: Hmm. I wonder how we ever got the Germans to stop thinking they won the war, maybe we can use the same strategy on Vim users

15:51 andyfingerhut: Oh, the build seemed to succeed. No error messages, at least. I want to do some performance testing with the latest Clojure, and want to ensure I'm using it to compile contrib. Maybe it is and it just isn't obvious.

15:52 ohpauleez: let me tell you all the things I can do in Vim and why I like them, and you can tell me the exact thing in emacs, that requires a long keystroke sequence

15:52 duncanm: what's the idiomatic way to get a seq of 10 random numbers?

15:52 AWizzArd: duncanm: repeatedly and #(rand-int 700)

15:52 duncanm: i thought i'd be using 'repeatedly'

15:52 and

15:52 oh

15:52 ohpauleez: duncanm: usually take and repeatedly

15:52 AWizzArd: ,(repeatedly 4 #(rand-int 77))

15:52 clojurebot: (36 36 37 32)

15:53 ohpauleez: wow, I never knew that

15:53 amalloy: clojurebot: that's not very random-looking. trying to fool us humans?

15:53 clojurebot: Excuse me?

15:53 AWizzArd: ohpauleez: repeatedly originally did not take an "n"-argument.

15:53 ohpauleez: ahhh

15:53 ok

15:54 _fogus_: chouser: BTW, did you ever settle on a replacement WM?

15:54 chouser: no, still using ion.

15:54 discovered awesome wm is ... not.

15:54 _fogus_: chouser: it does look pretty sweet (ion)

15:55 ohpauleez: chouser: You're breaking my heart man

15:55 What didn't you like about awesome

15:55 (I came from ion, still really like, use awesome more)

15:55 chouser: tabs

15:55 tabs tabs tabs tabs

15:57 ohpauleez: as in you didn't like the tabs in awesome?

15:58 chouser: ohpauleez: the didn't seem to exist except in an unmaintained plugin

15:58 they

15:58 did I miss them somehow?

15:59 ohpauleez: I use tabs just fine. They were default in my awesome. hmm

15:59 But no bother, ion rocks pretty hard too

16:00 chouser: hm. Well, maybe I'll try again later. :-)

16:01 amalloy: duncanm: http://pastie.org/1175275 if you're still looking for ideas about counting stuff

16:06 andyfingerhut: If you build latest clojure-contrib 1.3.x, and use the latest clojure 1.3 to compile it, what commands do you use?

16:08 chouser: andyfingerhut: I thought I did that last time I built contrib, but looking at the readme again I may have built contrib using clojure 1.2. :-/

16:10 andyfingerhut: Ah, I think I found the answer: http://groups.google.com/group/clojure/browse_thread/thread/2df8cfecb2d30fa9/eeb23dcff39eb316?lnk=gst&q=build+contrib+latest+clojure#eeb23dcff39eb316

16:29 svs`: hello, while using congomongo, if I say (fetch :stops :as :json), the resulting JSON will not parse. With (fetch-one :stops :as :json), there are no problems. Could someone please let me know what i'm doing wrong?

16:32 dpritchett: i'm guessing fetch returns an entire sequence rather than a single element of it

16:37 svs`: yes it does....though why would the :as :json bit create syntactically incorrect JSON?

16:37 ohpauleez: svs`: is the fetch lazy?

16:37 svs`: the JSON returned is { "_id" : { "$oid" : "4c9a18fc92427c5b337f2e07"} , "lng" : "73.84325695064035" , "lat" : "18.51638658242021" , "name" : "Deccan"}{ "_id" : { "$oid" : "4c9a298d92427c5b347f2e07"} , "lng" : "73.85279273999913" , "lat" : "18.512751236261558" , "name" : "Shanipar"}

16:37 ohpauleez: ie: can it not decode the response because it doesn't have the full response?

16:38 svs`: it's returning both items, but will not parse. I tried the ruby json parser and got the same results

16:40 dpritchett: it looks like it just concatenates the results of all fetch-ones with no delimited character.

16:41 this part is the end of the first and beginning of the second, yes? : "Deccan"}{ "_id" : {

16:41 duncanm: how do i write a comparator for ranges represented by [lower-bound upper-bound] ?

16:42 svs`: i get it ... it should be "[{ <first record>},{<second-record>}]"....i can fix that...cheers

16:45 dpritchett: are you talking about something like this duncanm ? "The java.util.Comparator interface can be used to create objects to pass to sort methods or sorting data structures. A Comparator must define a compare function which takes two Objects and returns a -1, 0, or 1"

16:45 kotarak: #(< lower-bound % upper-bound)

16:48 bobo_: hm, with enlive templating, how can i create <tr><td>... for each entry in a map? http://gist.github.com/592526 that just gives me <td>..</td> for each row.

16:53 amalloy: duncanm: i posted a pastie link above, but the general idea is (into #{} (range lower upper))

16:53 assuming you only want to compare integers, anyway, which was the impression i got

17:04 rickmode: when generating the new state of a defrecord object, is it more idiomatic and/or fast to instantiate a new record in the next state, or to use assoc?

17:04 AWizzArd: rickmode: assoc

17:06 chouser: AWizzArd: really? why?

17:07 AWizzArd: code documentation

17:07 rickmode: AWizzArd: Either way is very readable

17:11 AWizzArd: chouser: (assoc rec :foo a) vs (MyRec. :x (:x rec) :foo a) ... new record can be more verbose as here when the assoc doesn't modify :x. So I'm just wondering what assoc does with a defrecord under the covers.

17:11 kotarak: rickmode: records are used like maps. Hence to update a record field one uses (assoc r :field value)

17:11 rickmode: + assoc is more robust against future changes of the fields of the record

17:12 rickmode: + you can assoc "fields" which are actually not contained in the record

17:12 rickmode: kotarak: it must be instantiating a new record under the covers. Hopefully things are as efficient as persistent maps under the covers

17:13 kotarak: rickmode: believe: they are. Otherwise they wouldn't have made their way into clojure.

17:14 chouser: (assoc my-rec :a 1 :b 2) will create intermediate ephemeral garbage than a single ctor call wouldn't

17:14 that

17:16 amalloy: kotarak: i think chouser must be right here: assoc can't be as efficient as Record. for multiple fields

17:17 kotarak: amalloy: And it is more fragile. There is always a trade-off

17:17 chouser: which doesn't mean you shouldn't use it. I imagine an overwhelming majority of the time that extra garbage won't matter.

17:17 kotarak: speed is overrated

17:17 chouser: exactly. Just as one should not be afraid of extend

17:18 amalloy: i like to use assoc when i'm changing fewer than half of the fields, and Record. when i'm modifying most of them. though i probably should define a (make-record [{:keys}]) function and use that instead of raw Record.

17:18 chouser: it's just not obvious to me that the purpose and meaning of (assoc x :a b) is *always* clearer than (MyThing. b)

17:18 rickmode: chouser: well wait, what about the persistent nature? not knowing the implementation, I would expect a defrecord to work like a map with regard to persistence... and this would argue using assoc is more memory efficient despite ephemeral garbabe

17:19 kotarak: I think assoc is for modifying an existing record, while Record. should be used to create a new one.

17:19 chouser: hash-maps don't share structure below 32 elements

17:19 records never share structure

17:20 records never share structure on declared keys

17:20 hash-maps support transients

17:20 assoc doesn't use transient support

17:20 rickmode: sure the semantics are more clear using assoc vs. construction. However many datastructure example create new objects *and* maps as they enter a new state

17:20 chouser: ah now this is more clear

17:21 so favor assoc vs. construction with an eye to readability... but consider construction if testing reveals a performance issue

17:21 chouser: in all, performance should generally be a very late concern. My dubious tone toward AWizzArd's statement was not because of performance.

17:21 AWizzArd: Then again, transient maps are interesting for cases when one wants to add lots of entries, while records will typically have just a few fields.

17:35 lpetit: Hi, just wanted to let you know that a new release of ccw is available

17:36 worthy bug fix release, + (now working) automatic installation of labrepl project ! (it even auto loads a browser in Eclipse at the end of the installation ! )

17:43 Of course I don't expect you to bang your head on your ceiling due to this announcement ;-)

17:51 defn: i thought "rickmode" might be rhickey's alter-ego

17:52 rickmode: heh - no ... just another software hack

17:52 defn: a more "chill" version of rich, no code to think about: "rick mode"

17:54 duck1123: It made me think of a minor mode that changes buffers to read never gonna give you up

17:56 it's too bad you can't embed youtube videos inside emacs yet.

17:57 stain_: http://clojure.org/search/view/tutorial :-(

17:58 rickmode: duck1123: ack... I picked the moniker before rick astley stole my name

17:59 stain_: instead the getting_started page immediately says how you can deug using JSwat. Not quite the smooth tutorial ride I was hoping for..

17:59 debug

18:02 dakrone: stain_: were you looking for debugging tutorials, or just general clojure tutorials?

18:13 jfields: is there a fn or some java that will give me a list of all files in a dir and all subdirs?

18:13 mrBliss: jfields: file-seq

18:14 jfields: mrBliss, awesome. thanks

18:15 arohner: are there any known bugs in require? I'm seeing a behavior where if a require blows up because of an exception, re-requiring the file doesn't attempt to reload the file that threw

18:19 ohpauleez: I wanted to run an idea by the channel... I've been playing around with distributed message and job queues in clojure, and started writing something similar to a remote namespacer

18:19 would anyone ever find interest in an ns like macro for doing xmlrpc in clojure?

18:23 konr: If I have a structure set with (def foo (ref [{:meta {:foo 'bar}}, {:meta {:baka 'waka}}])), how can I alter one of the inner hashmaps to, say, [{:meta {:foo bar :bak wak}} {:meta {:baka waka}}]?

18:24 mrBliss: ,(doc update-in)

18:24 clojurebot: "([m [k & ks] f & args]); 'Updates' a value in a nested associative structure, where ks is a sequence of keys and f is a function that will take the old value and any supplied args and return the new value, and returns a new nested structure. If any levels do not exist, hash-maps will be created."

18:25 ohpauleez: konr, you can use assoc-in

18:25 or update-in

18:25 mrBliss: that's the one I meant :)

18:26 arohner: ohpauleez: you mean magically exposing clojure fns in a file/ns over xmlrpc?

18:26 ohpauleez: yes

18:26 introducing an :expose

18:26 arohner: ohpauleez: I don't need that in my current projects, but I would have loved it in some of my previous ones

18:26 ohpauleez: and :remote-use :remote-require

18:27 arohner: I wrote a half-assed version of that in ruby a couple of years ago

18:28 ohpauleez: cool, thanks for the feedback arohner

18:30 arohner: oh that's cool. I hung emacs by trying to connect via slime

18:30 ah, hit C-g enough, and the problem goes away

18:31 konr: hmmm, how about when I have only the reference to part of the structure I want to change? Like to {:meta {:foo bar}} on [{:meta ...} {:meta ...} ...] - Do I need to keep track of where I am?

18:32 lpetit: konr: sure

18:32 konr: since you do not change a structure in place, but create a new value from an old one

18:45 ,(update-in [{:meta {:foo 'bar}} {:meta {:baka 'waka}}] [0 :meta] assoc :bak 'wak)

18:45 clojurebot: [{:meta {:bak wak, :foo bar}} {:meta {:baka waka}}]

18:45 lpetit: konr: ^^^

18:46 konr: lpetit: thanks :) I wasn't aware I could reference the elements of a vector using the position!

18:47 lpetit: yes, their index is their key when vectors are seen as "associable/dictionaries"

19:04 cmd_: exit

19:04 exit

19:04 exit

19:04 quit

19:04 quit

19:04 exit

19:04 arohner: also, the ns already refers to exception is broken. If I ns foo :uses ns bar, and then I (require 'foo :reload), I get an unconditional exception

19:04 even though the var that's being stomped on is "the same"

Logging service provided by n01se.net