#clojure log - Sep 03 2010

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

0:27 Bahman: Hi all!

1:05 blais: Q: Is is possible to redefine the dispatch-fn of a multimethod in a running environment?

1:05 i.e., I use Emacs, I eval gradually. I want to change the dispatch function of a multimethod. Doesn't seem to work.

1:05 Any idea?

1:06 kumarshantanu: hi, can anybody point me to a code sample that uses flash messages in ring/compojure?

1:08 wwmorgan: blais: the defmethod behavior was changed with 1.2. It now has defonce semantics

1:08 *defmulti

1:08 Raynes: blais: In Clojure 1.2, defmulti got defonce semantics, meaning it'll only be eval'd once. You can probably ns-unmap it and re-eval it though.

1:09 (doc ns-unmap)

1:09 clojurebot: "([ns sym]); Removes the mappings for the symbol from the namespace."

1:09 wwmorgan: apparently, (def foo nil) will also work

1:09 Raynes: Or that.

1:10 scottj: kumarshantanu: I don't think there are any.

1:11 kumarshantanu: scottj: I am looking to use flash messages (now added in ring), but not sure what's the syntax etc

1:11 scottj: so any doc link may also be useful

1:15 scottj: kumarshantanu: I think you'll have to either write an email to ring mailing list asking for an example or figure it out from the code.

1:30 blais: Raynes: thx man.

1:31 wwmorgan: thx.

1:33 kumarshantanu: scottj: thanks, I am experimenting with the flash middleware

1:37 scottj: kumarshantanu: if you come up with a simple example please post it

1:37 kumarshantanu: scottj: sure

2:04 luc4s: Hi. I'm learning Clojure and have a little problem.

2:04 How can I transform this: ("1" "2" "3") ("a" "b" "c") into this: (["1" "a"] ["2" "b"] ["3" "c"])

2:05 wwmorgan: ,(map vector '("1" "2" "3") '("a" "b" "c"))

2:05 clojurebot: (["1" "a"] ["2" "b"] ["3" "c"])

2:06 luc4s: :wwmorgan thanks a lot. I was like a couple of hours struggling with that and interleave and etc.

2:08 wwmorgan: ,(partition 2 (interleave '("1" "2" "3") '("a" "b" "c"))) ;-) is another way to do it, if you don't need vectors

2:08 clojurebot: (("1" "a") ("2" "b") ("3" "c"))

2:09 luc4s: oh, no. I need the vectors for a func I made already hehe

2:10 thanks again. Clojure is a fantastic language, but a little hard for a imperative c++ programmer like myself

2:37 kumarshantanu: scottj: got the flash thing working, but it's a bit involved

3:19 LauJensen: Is there a cake option for adding arbitrary options to the jvm at compile time?

3:20 .cake/config => project.java_opts = ...

3:20 scottj: kumarshantanu: sweet, have a basic example you can gist or something?

3:21 noidi: LauJensen, did that work?

3:21 LauJensen: testing now

3:21 kumarshantanu: scottj: I will...I am re-factoring few things -- will post a gist

3:21 scottj: kumarshantanu: or a summary? you return a map with a :flash key and a redirect status/url and then on the redirect url you pull out the flash?

3:21 LauJensen: yes it did noidi

3:21 scottj: kumarshantanu: cool

3:22 noidi: I've never used cake, but just looking at the source, setting CAKE_JAVA_OPTS might work http://github.com/ninjudd/cake/blob/master/bin/cake

3:22 Cake looks interesting, I should really give it a try some day

3:23 LauJensen: agreed :)

3:23 octe: how do i require multiple things in an ns-declaration? i tried this: http://pastebin.com/xKqwACtC but it's not correct..

3:24 noidi: once I get over this damn flu... I'd be at work now if I had the energy to write Clojure code :P

3:24 bartj: I think it is not possible to import all the classes in a package like in Java, is this correct ?

3:24 kumarshantanu: scottj: essentially, [1] you wrap the handler -- (wrap-session (wrap-flash handler)) [2] use the wrapped handler in ring-jetty-adapter [3] retrieve flash using {flash :flash} on the route definition and [4] to emit flash messages you simply assoc the body map with :flash as key and whatever as value

3:24 bartj: for eg: import org.apache.http.* would translate to:

3:25 (:import org.apache.http *) ?

3:26 LauJensen: correct, its not possible

3:39 kumarshantanu: scottj: I created a gist -- http://gist.github.com/563552

3:40 scottj: kumarshantanu: cool, you don't need var and future on run-jetty

3:40 oh nevermind forget that

3:42 kumarshantanu: scottj: i copy-pasted from my Eclipse IDE -- I use future and defonce for interactive web development

3:43 scottj: I was confusing var/future for :join? false/future

4:02 LauJensen: Has anyone here had trouble compiling a project which imports JFreeChart ?

4:08 springify: Hello everybody. I'm trying to use leiningen 1.3.0 as dependency in a project.clj, but there doesn't seem to be a copy of it on clojars. Does anybody know of a repository that I could use, or do I have to compile and install locally?

4:12 kumarshantanu: springify: you might as well raise a ticket on Leiningen -- asking to push to Clojars

4:14 springify: kumarshantanu: True, just wanted to know whether I missed something.

4:17 Done: http://github.com/technomancy/leiningen/issues#issue/106

4:18 kumarshantanu: springify: just noticed the issue - it says "Release leiningen 1.5"

4:18 springify: Heh, no, just edited. Hit the return key accidentally.

4:18 kumarshantanu: springify: the next planned release is 1.3.1 as far I know

4:19 springify: kumarshantanu: There doesn't seem to be anything beyond 1.1.0 on clojars at the moment, so 1.3.0 would be quite a step forward.

4:21 kumarshantanu: springify: Lein on Clojars may be useful for writing plugins I guess -- is that the purpose if I may ask?

4:23 springify: kumarshantanu: I'm maintaining a branch of lein-cuke, (cuke4duke with leiningen), which depends on leiningen, yes.

4:27 kumarshantanu: springify: this is cool (googled them), thanks for sharing the details

4:30 springify: kumarshantanu: You're welcome. I can only claim credits for providing the project.clj and a single fix, tho :)

4:31 kumarshantanu: **time for lunch...ciao

4:31 yayitswei: quick question: what's the equivalent of clojure.set/select for lists? for example I want to write (select #(> % 2) '(1 2 3 4))

4:32 ;; => (3 4)

4:33 LauJensen: filter comes to mind

4:33 Raynes: -> (filter #(> % 2) '(1 2 3 4))

4:33 sexpbot: => (3 4)

4:33 yayitswei: ah, that's exactly what i was looking for

4:34 LauJensen: -> (remove #(< % 2) '(1 2 3 4))

4:34 sexpbot: => (2 3 4)

4:34 yayitswei: or remove too.. thanks guys

4:34 LauJensen: np

4:35 ordnungswidrig: LauJensen: I will not higlight you, as cuke was mostly a drop-in. :-)

4:35 LauJensen: cuke-de-duke? :)

4:36 ordnungswidrig: cuke-de-cake, actually :)

4:36 LauJensen: Its amazing how poor security webmail clients have. Sometimes when I get referrers in my stats, I can see how has sent somebody an email about one of my blogposts

4:36 ordnungswidrig: LauJensen: I noticed that too.

4:36 LauJensen: You've been checking my referrers?

4:38 ordnungswidrig: LauJensen: I used the referrer from one of my blog posts to login into your webmail and to gain access to your blog to check your referrers :)

4:38 LauJensen: thats an awesome feat, especially considering I dont have a webmail :)

4:38 ordnungswidrig: *doh*

4:42 esj: <greetings>All<Special Greeting>LauJensen</Special Greeting></greetings>

4:42 :P

4:42 LauJensen: Greetings and salutations esj! :) Whats the the XML, you started greeting people in Maven? :)

4:43 esj: correct in one :)

4:43 of course, in future, I just need to go $mvn greet

4:43 and I'm done :)

4:44 LauJensen: Well - Its not a real Maven vs Sane Tools smackdown before we have a blogpost :) I'll cook something up

4:45 esj: lol

4:49 LauJensen: I cant decide "Wasting your life like a pro - Maven" or "Wasting your customers money - Maven", which is better?

4:49 I mean, they're both terrible accurate...

4:53 bobo_: i think the first one

4:53 not everyone has customers

4:53 and sometimes, its the customers choice

4:58 LauJensen: Exactly what I thought :)

4:59 Or maybe its because Maven is just too foreign to real programmers, maybe I should write a tutorial instead "Set up Maven in just 42 weeks"

4:59 ok enough, we have to stop before cemerick wakes up :)

5:00 bobo_: well, i have an ant build for the project i am working on now... maybe i shouldnt yell at maven

5:01 esj: Its the best thing I've used, super potent and easy, but as discussed, I haven't checked out cake yet.

5:01 lancepantz_: member:LauJensen: justin mentioned that you were thinking about writing a post on cake?

5:02 esj: and if I can goad Lau into doing my research for me, so much the better ;P

5:02 LauJensen: lancepantz_: Thats right

5:02 lancepantz_: awesome

5:02 i'm working on the task system ATM

5:03 LauJensen: awesome begets awesome, now the pressures on me to write a good post :)

5:03 lancepantz_: we whiteboarded some really cool stuff today, i

5:03 'm excited ot get it in

5:03 LauJensen: details details! :)

5:04 lancepantz_: adding a deffile macro that's similar to deftask

5:04 *defile

5:04 LauJensen: deffile is very differnt from defile

5:04 lancepantz_: takes in a string thats the name of the file you want build

5:04 bartj: er, how would one go about translating this Java stmt to Clojure ?

5:04 lancepantz_: hehe, i like defile :)

5:04 bartj: org.apache.http.client.HttpClient client = new DefaultHttpClient();

5:04 LauJensen: lancepantz_: I dont, keep it clean

5:04 esj: lol

5:04 LauJensen: (let [client (DefaultHttpClient.)]

5:05 bartj: LauJensen, no that doesn't work - I tried that

5:05 lancepantz_: in the spirit of defn instead of deffn then :)

5:05 LauJensen: bartj: thats the translation though, so something else is wrong

5:05 (let [client ^org.apache.http.client.HttpClient (DefaultHttpClient.)] ... ?

5:06 lancepantz_: the defile dependences are a set of files that are the source files for the file being generated

5:06 and the macro compares the timestamps to see if it need to be ran

5:06 so something like

5:07 (defile "pom.xml" #{"project.clj"} (prxml [pomstuff]))

5:08 then the task will only generate a new pom when either it doesn't already exist, or pom.xml is older than project.clj

5:08 it's going to clean the code up quite a bit

5:08 LauJensen: nice

5:09 lancepantz_: (defile "lib/*.class" #{src/**/*.clj} (compile blah blah..))

5:10 (defile "lib/*.class" #{"src/**/*.clj"} (compile blah blah..)) actually

5:10 LauJensen: So this goes into the optimization category

5:10 Im excited to see how much mileage you'll get out of Ivy

5:11 lancepantz_: yeah, i think we're vectoring in on the feature set we want for 1.0

5:11 me too, ivy looks great

5:11 ordnungswidrig: does cake only work on files as a resource? or can the artefacts that came out of a build step other things as well?

5:11 lancepantz_: there was a guy working on a patch for it, but i think he's gotten busy

5:11 LauJensen: Just make sure you weed out the bugs before 1.0 comes - I'm posting one today, if I didn't already

5:12 Raynes: lancepantz_: I found a bugzors.

5:12 lancepantz_: ordnungswidrig: you mean build things other than files?

5:13 ordnungswidrig: lancepantz_: yes

5:13 lancepantz_: example?

5:13 clojurebot: examples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples

5:13 lancepantz_: Raynes: is it with the jvm restarting?

5:13 Raynes: lancepantz_: Nosir.

5:13 lancepantz_: sup?

5:13 ordnungswidrig: simple example: data into database

5:13 Raynes: lancepantz_: 'open' times out way, way too quickly in the download function.

5:14 lancepantz: On a slow connection, there is absolutely no chance of it completing.

5:14 Oh a really, *really* slow connection, anyway.

5:14 ;)

5:14 lancepantz_: ordnungswidrig: ahh, well yeah, anything you can do in clojure you can do in a cake function

5:14 ordnungswidrig: more abstract example: a build tool is basically a set of functions wired together with memoization (ideally). Some work on files and file stamps like make. Some work on abstractly defined dependencies like ant.

5:15 LauJensen: ordnungswidrig: I have a build now, which when you run uberjar, pulls down a database spec, compiles an embedded database and includes it in the jar for sweet sweet deployment :)

5:15 lancepantz_: Raynes: ah, i believe it, get up with ninjudd tomorrow, he's been working on all that stuff

5:15 Raynes: lancepantz_: I think the timeout is like 1 minute. Ruby 1.9 apparently has a :read_timeout parameter that can be passed to open, but I don't think there is a way to handle that without hopping over to net/http in Ruby 1.8.

5:15 ordnungswidrig: LauJensen: in cake?

5:15 LauJensen: ordnungswidrig: Yes

5:15 Raynes: lancepantz_: Will do. Just waiting on him. :D

5:15 LauJensen: Raynes: Just post an issue on Github, these guys work FAST :)

5:15 ordnungswidrig: LauJensen: would this be possible in leiningen?

5:16 Raynes: I'll be up for a while. If I can't talk to ninjudd before I go to sleep, I'll make an issue.

5:16 LauJensen: ordnungswidrig: Yea I think so, but not as elegantly - I've overriden the compile task

5:16 or, extended it actually

5:16 lancepantz_: ordnungswidrig: yeah, you are describing dependency based programming, which was our whole goal for the project

5:16 all the other stuff was just afterthoughts :)

5:18 ordnungswidrig: cool. I once did a prototype for a java build tool (which used ant internally for jump start). It could either build a jar if needed (e.g. to build a .war) or it skipped automatically the jar part if only the compiled classes were needed.

5:18 lancepantz_: right, exactly

5:19 adben: morning *

5:19 lancepantz_: we're setting up an engineering blog and i'm going to write up a really detailed post explaining the need for it

5:21 yayitswei: another question for you guys.. why doesn't -> work with anonymous functions? for example, (-> 1 #(+ % 2 3))

5:21 i would expect => 6

5:23 lancepantz_: ,(-> 1 (partial + 2 3))

5:23 clojurebot: #<core$partial$fn__3678 clojure.core$partial$fn__3678@60bb22>

5:25 lancepantz_: yayitswei: i would expect that as well

5:25 tomoj: ,(read-string "#(+ % 2 3)")

5:25 clojurebot: (fn* [p1__4395#] (+ p1__4395# 2 3))

5:26 tomoj: ,(macroexpand-1 '(-> 1 #(+ % 2 3)))

5:26 clojurebot: (fn* 1 [p1__4396#] (+ p1__4396# 2 3))

5:27 yayitswei: hmm. or a better question: what's the idomatic way to rewrite that?

5:28 let's say, (-> 1 #(+ % 2 3) println)

5:28 tomoj: (println (+ 1 2 3)) ?

5:28 noidi: yayitswei, you'll have to write it as (#(...))

5:28 yayitswei: ,(println (#(+ % 2 3) 1))

5:28 clojurebot: 6

5:29 Raynes: ->(-> 1 (#(+ % 2 3)))

5:29 sexpbot: => 6

5:29 yayitswei: ooh

5:30 (-> (-> 1 #(+ % 2 3) ) println)

5:30 ,(-> (-> 1 #(+ % 2 3) ) println)

5:30 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.ISeq

5:30 noidi: ,(macroexpand '#(println %))

5:30 clojurebot: (fn* [p1__4407#] (println p1__4407#))

5:31 noidi: so the #() expands to the list above

5:31 and -> will stick the result of the previous expression as the second item in that list

5:31 ,(macroexpand '(-> 123 #(println %)))

5:31 clojurebot: (fn* 123 [p1__4410#] (println p1__4410#))

5:31 noidi: which does not make any sense

5:31 so you'll get an error

5:32 ,(macroexpand '(-> 123 (#(println %))))

5:32 clojurebot: ((fn* [p1__4413#] (println p1__4413#)) 123)

5:32 noidi: but that works, because the first item in the list is a function, and the second is its argument

5:33 yayitswei: what does fn* mean?

5:35 Raynes: (doc fn*)

5:35 clojurebot: Gabh mo leithscéal?

5:35 yayitswei: ohhh but i get your meaning

5:35 so i should write it as ,(-> 1 (+ 2 3) println)

5:35 ,(-> 1 (+ 2 3) println)

5:35 clojurebot: 6

5:37 LauJensen: ,(-> 1 (+ 2 3))

5:37 clojurebot: 6

5:37 LauJensen: Isnt that good enough? :)

5:38 Oh I see I missed a larger discussion :|

5:39 noidi: I don't really understand the opposition to adding a variant of -> that places the threaded value at a marked position

5:39 LauJensen: noidi: -> ->> is all you need IMO

5:39 yayitswei: yep! thanks guys. I didn't fully understand what -> did

5:39 LauJensen: yayitswei: You got it now?

5:39 yayitswei: yeah

5:40 funny because you can't google ->

5:40 noidi: ,(doc ->)

5:40 clojurebot: "([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."

5:40 yayitswei: ahh

5:40 LauJensen: yayitswei: Yea, thats how we get so many members in #clojure

5:40 noidi: yayitswei, when you are not sure what a macro does, macroexpand and macroexpand-1 are your friends

5:41 tomoj: noidi: "rich said no" isn't enough for you? :P

5:41 yayitswei: haha cool, will try that next time

5:42 noidi: tomoj, heh, well, that's a good reason I guess :)

5:43 ordnungswidrig: not be able to google for "->" and so on is a problem for haskell and scala, too.

5:43 but the haskell guys have solved the problem

5:44 yayitswei: ordnungswidrig: how did they solve it?

5:47 ordnungswidrig: yayitswei: they have hoogle and hayoo

5:47 yayitswei: Hoogle is a Haskell API search engine, which allows you to search many standard Haskell libraries by either function name, or by approximate type signature.



5:48 yayitswei: member:ordnungswidrig: nice, looking at it now

5:48 noidi: ,(find-doc "Thread")

5:48 clojurebot: ------------------------- hiredman.schedule/task-runner nil ScheduledThreadPoolExecutor for scheduling repeated/delayed tasks ------------------------- clojure.core/-> ([x] [x form] [x form & more]) Macro Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc.

5:49 yayitswei: we have our trusty clojurebot

5:50 ordnungswidrig: the power of the type system is apparent when you search for a function with a signature, say (a -> b -> b) -> b -> [a] -> b) and you get foldr as a result

5:51 LauJensen: I keep getting referers from here https://secure.wikimedia.org/wikipedia/en/wiki/Main_Page , can anybody work out why?

5:52 ordnungswidrig: LauJensen: maybe real path is cut because it is a secured connection?

5:52 LauJensen: maybe

5:53 ordnungswidrig: Or somebody playing a joke on your logfile?

5:53 LauJensen: Not possible

5:53 Unless you mean, by way of referrer spam

5:57 ordnungswidrig: Not possible? I can do a curl -H'Referer: https://secure....' https://secure.wikimedia.org/wikipedia/en/wiki/Main_Page can't I?

6:01 Raynes: ordnungswidrig: Once clojuredocs has an API, we'll have that as well.

6:01 I mean, we have it now, but once we have an API, it can be integrated with the bots.

6:03 LauJensen: ordnungswidrig: Yes, thats referrer spam

6:03 (ps: if you dont highlight me, chances are I wont look)

6:05 ordnungswidrig: LauJensen: ok, I think some day, we can manage on a proper mutual highlighting policy :)

6:09 can I search for a ns where a symbol / function is defined?

6:25 LauJensen: M-. fn

6:25 @ ordnungswidrig

8:14 arnorhs: whazzup

8:14 Are there any stable zero mq bindings for clojure? You just use the java ones right?

8:14 Do you think they can be set up using lein ?

8:16 dnolen: arrnorhs: yeah use the zeromq java bindings. you'll probably want to use native-deps for that.

8:19 mrBliss: is there a reason for the absence of (copy ^URL *) in the io libraries?

8:19 stuartsierra: mrBliss: nobody wrote it

8:20 mrBliss: I have written the 3 needed methods if you want them (thanks goes to LauJensen)

8:20 stuartsierra: cool, post to the mailing list and we'll take a look

8:20 mrBliss: alright

8:21 clojure or clojure-dev?

8:22 stuartsierra: mrBliss: clojure

8:32 mrBliss: could it be that ^Writer on this line should be changed to ^File? http://github.com/clojure/clojure-contrib/blob/b6c6f0fa165975c416c7d135d1a844353527493b/src/main/clojure/clojure/contrib/io.clj#L468

8:33 stuartsierra: clojure.contrib.io is slated for removal anyway

8:35 mrBliss: copy's also deprecated I see, so should I continue?

8:35 stuartsierra: all that has moved to clojure.java.io

8:35 Further development will continue there.

8:35 mrBliss: ok I see

8:37 same remark as before: shouldn't the ^Writer on this line be changed into ^File? http://github.com/clojure/clojure/blob/3a3374f714e5a755b7de2a761f37696f07a74e80/src/clj/clojure/java/io.clj#L365

8:38 stuartsierra: yes, although it doesn't actually matter

8:42 Licenser: greetings my lispy friendsw

8:42 is guthub acting odd for someone else? I have mails that there should be something in my fork thingy but it says everything up to date o.O

8:51 kumarshantanu: can anybody help me understand how to express (if cond step1 else-step-2-and-step3)

8:51 mrBliss: (if cond step1 (do step2 step3))

8:51 kumarshantanu: step2 and step3 are independent

8:51 mrBliss: will (do ...) return the value that step3 returns?

8:51 mrBliss: correct

9:06 stuartsierra: post sent

9:28 bartj: , (doc do)

9:28 clojurebot: It's greek to me.

9:29 bartj: the error - " Unable to resolve classname" occurs because the class was not imported ?

9:30 chouser: probably

9:30 bartj: chouser, what could be the other reasons ?

9:32 if I have the following line in Java: org.apache.http.client.HttpClient client = new DefaultHttpClient();

9:33 the DefaultHttpClient is present in org.apache.http.client

9:33 I am sorry, DefaultHttpClient is present in org.apache.http.impl.client

9:34 and HttpClient is present in org.apache.http.client

9:34 so, while importing the java classes, I have something like:

9:34 (:import [org.apache.http.client.HttpClient] [org.apache.http.impl.client.DefaultHttpClient])

9:35 still, I get a Unable to resolve classname error

9:35 can someone please point what I am doing wrong ?

9:35 mrBliss: try (:import [org.apache.http.client. HttpClient]

9:35 [org.apache.http.impl.client DefaultHttpClient])

9:35 note the spaces

9:35 (remove that trailing dot from client.)

9:36 raek: does that work with the vectors?

9:36 mrBliss: yes

9:36 [package.subpackage Class]

9:36 stuartsierra: vectors should be lists there

9:36 raek: parantheses are the most commonly used for prefix lists

9:36 bartj: LauJensen, told me that they were one and the same!

9:36 stuartsierra: That's an implementation detail.

9:36 It just happens to work.

9:37 raek: (ns foo.bar (:import org.apache.http.client.HttpClient org.apache.http.impl.client.DefaultHttpClient))

9:37 (ns foo.bar (:import (org.apache.http.client HttpClient) (org.apache.http.impl.client DefaultHttpClient)))

9:38 so, using 1-vectors happens to be the same as the infamous empty-prefix-list

9:38 bartj: raek: I am assuming your last import is the correct one ?

9:38 raek: yes

9:39 it is the way I have learned that it should be done

9:39 (please correct me, someone, if I have learned the wrong thing)

9:39 bartj: ok, I now get an error that makes sense!

9:40 raek: anyway, (:import [org.apache.http.client.HttpClient]) is treated like (:import (org.apache.http.client.HttpClient))

9:40 chouser: stuartsierra: why are parens preferred?

9:40 raek: that is, import *nothing* from the "org.apache.http.client.HttpClient" package

9:40 stuartsierra: chouser: 'Cause that's what the docs say, dammit!

9:40 bartj: raek, org.apache.http.client.HttpClient is not the same as org.apache.http.client HttpClient !

9:40 raek, why so ?

9:41 chouser: stuartsierra: hm. good point.

9:41 raek: no

9:41 foo.bar.A is the same as (foo.bar A)

9:41 foo.bar.A foo.bar.B is the same as (foo.bar A B)

9:41 bartj: ok, then the only change that I did was to convert [] to ()

9:42 raek: you need to either drop the parens or replace the last period with a space

9:43 bartj: I did both

9:43 raek: (:import (foo.bar)) means "for all elements of the emply list, import them from the foo.bar package"

9:43 bartj: and thinks seem to work fine

9:44 raek: ok, great!

9:44 what does your :import look like now?

9:45 bartj: (:import (foo1 bar1) (foo2 bar2))

9:46 I previously had:

9:46 (:import [foo1.bar1] [foo2.bar2])

9:48 I wonder why that is wrong!

9:48 raek: the previous?

9:48 bartj: yes, my last statement

9:49 raek: because of how it's implemented, it gets treaded as (:import (foo1.bar1) (foo2.bar2)) would have

9:50 since you should only use vectors when passing options, iirc

9:50 do you understand how (:import (foo1.bar1) (foo2.bar2)) is interpreted?

9:50 bartj: no

9:52 raek: but you understand how (foo.bar X Y Z) would be interpreted, right?

9:52 bartj: can you please explain

9:52 yes, import the classes X Y Z of package foo.bar

9:53 raek: now, imagine that you import *no* classes from package foo.bar... how would that be written?

9:53 bartj: (:import (foo.bar '()))

9:54 raek: (foo.bar X Y) = two classes, (foo.bar X) = one class, (foo.bar) = zero classes

9:54 bartj: ok

9:54 raek: your example has an empty list where the first class should go

9:54 bartj: yes, right - just (foo.bar)

9:54 raek: exactly

9:54 bartj: I think I was trying to be a bit clever - unnecessarily

9:55 raek: it's too bad that it doesn't signal any error when you do that

9:55 since I don't think *anyone* wants to import zero number of classes

9:55 bartj: ok

9:56 so (:import (foo1.bar1) (foo2.bar2))

9:56 actually don't make sense

9:56 because you don't specify any classes for the packages ?

9:56 chouser: it really ought to print a warning

9:56 bartj: am I correct ?

9:57 I am sorry, I gotta run

9:58 raek, thanks a lot

10:26 hugod: is there any way (defn f [a b c :as argv] ..) could work?

10:26 chouser: (defn f [ & [a b c :as argv]] ...)

10:29 hugod: how about (defn f [a b & c :as argv] ..)

10:30 chouser: the parameter lists given to fn's are not destructuring. Instead you can provide multiple arg lists, one of which may use &

10:31 :as is a destructuring feature

10:31 so in your example, if you want argv to be all args and c to be a seq starting with the third arg, you still need to use destructuring on the entire arg list

10:31 hugod: destructuring works well with map arguments :)

10:32 chouser: (defn f [ & [a b & c :as argv]] ...)

10:32 hugod: but as you say (defn f [& [a b & c :as argv]] (println argv)) works

10:32 thanks

10:40 stuartsierra: hello, contrib committers

10:40 ?

10:42 * chouser averts his eyes

10:43 * stuartsierra stares at chouser

10:43 chouser: uh.. um... ahem, yes?

10:43 stuartsierra: I'm working on a versioning / release policy for the modularized contrib

10:44 with the goal to get people committing again

10:44 chouser: hm.

10:44 stuartsierra: Trying to figure out how to handle dependencies.

10:44 chouser: policies will increase motivation?

10:44 stuartsierra: Well, I want to make it easier to release a module with a stable version number.

10:44 chouser: ok, I can see the benefit there.

10:45 stuartsierra: So that modules can improve independently from the monolithic clojure-contrib

10:45 But that raises questions, such as...

10:45 Which version of Clojure (core) should modules depend on?

10:46 Maven supports inclusive/exclusive ranges such as "[1.0.0,2.0.0)" meaning any version >= 1.0.0 but less than 2.0.0

10:49 Right now, all sub-modules inherit the Clojure dependency (pegged at 1.2.0) from a "parent" module.

10:50 chouser: can that be tweaked per-module?

10:50 stuartsierra: yes

10:50 chouser: sounds good.

10:50 stuartsierra: So I think the default should be something fairly broad, like "[1.0.0,2.0.0)", which individual modules can override.

10:51 fliebel: hey

10:51 stuartsierra: The only problem is AOT-compilation (dun dun DAAAH).

10:51 chouser: heh

10:51 raek: what happens if the dependencies of a project depends on different clojure versions, btw?

10:51 chouser: seriously. that was perfect.

10:51 stuartsierra: :)

10:52 clojure-maven-plugin permits you to declare in the POM which namespaces will be AOT-compiled. This will default to none in the parent module, overridden on a per-module basis.


10:52 As we know, AOT-compilation is indiscriminately transitive.

10:53 For example, AOT-compiling clojure.contrib.condition.Condition (for gen-class purposes) also AOT-compiles clojure.contrib.seq.

10:53 abedra: stuartsierra: and indiscriminately awesome

10:54 chouser: is that behavior not yet slated to be changed?

10:54 stuartsierra: Those AOT-compiled functions may be binary-incompatible with any Clojure version other than the one they were compiled with.

10:54 chouser: not yet, despite many requests

10:56 chouser: is there not buy-in on the idea of intransitive compilation, or is it just a issue of correct implementation?

10:56 stuartsierra: the latter, I think

10:57 * stuartsierra digs through assembla

10:57 chouser: cemerick: c'mon, man, write a better patch!

10:57 :-)

10:58 cemerick: ha

10:58 chouser: outside of far more significant refactoring (e.g. eliminating the distinction between eval and compile entirely), I'm not sure how it could be simplified.

10:58 But then, rhickey has shown me up before. :-)

10:58 stuartsierra: https://www.assembla.com/spaces/clojure/tickets/322-enhance-aot-compilation-process-to-emit-classfiles-only-for-explicitly-specified-namespaces

10:59 Stu Halloway has moved this to Release.Next, meaning 1.3.0 probably.

10:59 chouser: perhaps it should be committed to master soon so people can start experiencing the pain, if any.

11:00 stuartsierra: Now, there are very few contrib modules that still require AOT-compilation.

11:00 cemerick: I'd forgotten the specifics of Stu's comment -- sounds like there's no specific issues with the patch, just touched too many things too close to release-time.

11:00 stuartsierra: So my plan would be to release those with clojure.version set to 1.2.0 exactly.

11:01 cemerick: yes that sounds right

11:01 chouser: could an individual module specifically prevent itself from being AOT compiled?

11:02 I guess that might bug people building their own apps based on contrib.

11:03 stuartsierra: chouser: I don't think there's any way to do that

11:03 cemerick: There's always banging away at *compile-path* as desired, before and after the entirety of the ns....

11:03 * cemerick runs, ducks

11:03 chouser: cemerick: that's roughly what I was thinking.

11:04 stuartsierra: Yeah, there's even an option in clojure-maven-plugin to do that.

11:04 But I really don't want to go there.

11:04 cemerick: a lib should never be able to *prevent* itself from being AOT-compiled.

11:04 You never know what people downstream will need to do.

11:04 Besides, AOT is orthogonal to code, and belongs in the build config (whatever form that may take).

11:06 stuartsierra: So if I can clean up the deprecations, I will try to release clojure-contrib 1.3.0 later today.

11:06 From that point, each module can follow its own release / versioning path.

11:07 We'll just have to figure out how to get the "release" artifacts deployed on build.clojure.org.

11:07 chouser: will there still be whole-contrib releases?

11:07 cemerick: ...and chaos will rule the land.. ;-)

11:07 stuartsierra: cemerick: you got that right

11:08 There will still be versioned releases of org.clojure.contrib:complete, which will have transitive dependencies on all other modules.

11:08 Using the latest released version of each module.

11:08 cemerick: I presume chouser is talking about an aggregate *shrug*

11:09 stuartsierra: You can already get an aggregated JAR from the "complete" module.

11:09 Aggregated ZIP releases are on my TODO list as well.

11:09 cemerick: oh, oh -- I figured that was just a shell to point @ the transitive deps.

11:10 stuartsierra: cemerick: it is, but it has a Maven assembly configuration to produce a contrib uberjar.

11:10 Although this is not deployed as an artifact on build.clojure.org

11:10 cemerick: Oh how I dislike that term...

11:11 stuartsierra: Nevertheless, in Maven or Leiningen, depending on org.clojure.contrib:complete will give you all of contrib

11:11 cemerick: me too, but I have fun saying it in a faux-German accent.

11:16 ordnungswidrig: I'm looking for an easy way to "join" map, say {:a 1 :b 2} to "a=1;b=2"

11:17 fliebel: ordnungswidrig: With that specific syntax?

11:17 cemerick: stuartsierra: Every time I read "uber" written by a programmer, I'm going to tweet something using the phrase "hipster-geek", which generally seems to annoy those that use "uber" most often.

11:17 ordnungswidrig: fliebel: , instead of ;

11:17 fliebel: ordnungswidrig: I'll try to cook something up...

11:23 ,(reduce #(str %1 (name (first %2)) "=" (last %2) ", ") "" {:a 1 :b 2})

11:23 clojurebot: "a=1, b=2, "

11:23 stuartsierra: fliebel: that's less efficient that using a StringBuilder

11:24 fliebel: stuartsierra: Enlighten us :)

11:24 ordnungswidrig: stuartsierra: what would be acomplished how?

11:24 chouser: (symbol (apply str (mapcat #(cons "\n" (next (map {\0 \ \1 \#} (Long/toBinaryString %)))) [185 13235209671M 25939708511M 1654794401M 12429901063M 131081 65539])))

11:25 oh wait, that's something else

11:25 mrBliss: ,(require '[clojure.string :as s])

11:25 clojurebot: nil

11:25 mrBliss: ,(s/join ", " (map #(str (first %) "=" (second %)) {:a 1, :b 2}))

11:25 clojurebot: ":a=1, :b=2"

11:25 stuartsierra: (let [sb (StringBuilder.)] (doseq [[k v]] (.append sb (str k)) (.append sb "=") (.append sb (str v))) (str sb))

11:26 Strings make me go all imperative for some reason.

11:26 ordnungswidrig: stuartsierra: where comes the map in?

11:26 stuartsierra: oops

11:26 (doseq [[k v] the-map] ...)

11:26 and I bet I missed a paren or six

11:26 chouser: ,(apply str (butlast (mapcat (fn [[k v]] [(name k) \= v \,]) {:a 1 :b 2})))

11:26 clojurebot: "a=1,b=2"

11:27 mrBliss: ,(s/join "," (map #(str (name (first %)) "=" (second %)) {:a 1, :b 2}))

11:27 clojurebot: "a=1,b=2"

11:27 fliebel: chouser: Thanks, a new function was learnt :)

11:28 ordnungswidrig: thanks all

11:28 I throw in a (-> % first name) to get rid of the :

11:30 chouser: fliebel: probably should be drop-last instead

11:30 ordnungswidrig: What is "Unsupported binding form: ..."

11:30 chouser: in fact, it should be. please pretend I never mentioned butlast

11:31 fliebel: chouser: What's the difference? they both seem to produce the desired result.

11:33 chouser: butlast is eager but returns a seq. odd beast.

11:33 fliebel: chouser: So the only difference is that drop-last is lazy?

11:33 arkh: why doesn't this return anything? (for [x (repeatedly rand)] (prn x))

11:34 chouser: drop-last returns a normal lazy seq, plus can take a numeric arg and has a beautifully clever definition.

11:35 arkh: 'for' is lazy, so 'prn' won't be called unless you force the sequence.

11:35 arkh: you could try replacing 'for' with 'doseq', but that'll never end.

11:35 fliebel: ,(take 3 (for [x (repeatedly rand)] (prn x)))

11:35 clojurebot: (nil nil nil)

11:36 stuartsierra: ,(take 3 (for [x (repeatedly rand)] x)

11:36 clojurebot: EOF while reading

11:36 stuartsierra: ,(take 3 (for [x (repeatedly rand)] x))

11:36 clojurebot: (0.7727220105041916 0.9438459028734485 0.38389401142129465)

11:36 arkh: that makes sense - thank you

11:38 fliebel: Would it be appropriate to use a markov chain to make a rock paper scissors game?

11:41 thunk: That's a psychology question :)

11:42 fliebel: thunk…. you're probably right. But it's going to be in Clojure :D *cheap excuse*

11:43 It's going to be fun to make anyway, so I'll just do it. The other option is some more complex patter matcher.

11:45 arkh: it's supposed to be a random process, but if the state that follows is dependent on the current state, you have a 50/50 of what to go with. So there's only three pairs of 50/50 that can come about, right?

11:47 well ... assuming the state that follows is one that must win or tie. Nvm ... I don't know what I'm talking about. :)

11:47 fliebel: me neither

11:48 arkh: the idea is that humans are not proper random number generators, and so are predictable

11:50 arkh: So I hope that if I measure the probability of certain actions following on the previous action… for example, if I choose stone last time, there is maybe 45% change I'll choose stone again

11:50 I'm about to find out if it works

11:52 arkh: fliebel: given a finite number of choices and sufficient data, do you hope to predict human behavior in other settings, too, or is this just an exercise? :)

11:53 fliebel: arkh: I was just thinking about this game, but the experience might come in handy later on…

11:54 arkh: Might be fun to predict other things thoug, but I don't think markov is the golden standard for predicting human.

11:58 grc: Is it possible to get hold of the body of a function from its symbol?

11:59 I've got as far as getting the function object but don't know how it is structured

11:59 chouser: grc: sort of. see the 'source' macro or source-fn

11:59 grc: chouser: thanks I'll go and have a play

12:02 chouser: fn's don't store their source, but vars that point to fns have enough metadata that, if the .clj file is on the classpath, you can go find the source.

12:06 technomancy: fns can store their source

12:06 with special sauce

12:06 http://github.com/Seajure/serializable-fn

12:07 chouser: that doesn't handle closures, does it?

12:09 stuartsierra: Nothing handles closures.

12:10 "You wan't closure? You can't handle this closure."

12:10 technomancy: chouser: depends on what you close over

12:10 pheuter: I'm having trouble running the jar file created with leiningen

12:11 technomancy: it's not smart enough to drop it silently if you close over something unseriablizable; it just freaks out

12:11 pheuter: Failed to load Main-Class

12:11 fliebel: What is the Clojure equivalent of a switch statement? Multimethod?

12:11 stuartsierra: fliebel: "case" in 1.23

12:11 1.2

12:11 technomancy: or rather, something un-pr-str-able

12:12 grc: chouser: What I'm trying to do is ascertain whether or not a function is pure by checking it and its callees for impurity

12:12 fliebel: technomancy: What is un-pr-str-able?

12:12 stuartsierra: grc: I think that's called the Halting Problem

12:12 technomancy: fliebel: Java objects which pr-str is inable to print correctly

12:16 grc: stuartsierra: I'm looking a trying to implement a run time assertion check comparable to JML and want to prevent :pre, :post from calling (potentially) side effect prone functions.

12:16 Whether or not teh function is *actually* called I can live with

12:16 stuartsierra: :pre/:post should never have side-effects

12:17 never ever

12:18 grc: agreed, but that's enforced only by good behaviour

12:18 slyrus: there go the debugging printlns in the :pre/:post methods

12:18 _fogus_: should never != cannot

12:18 grc: stuartsierra: Also there's some stuff in JML where side effects are allowed, as long as they're limited to the Runtime Assertion Checking plane

12:19 stuartsierra: _fogus_: true, but if they are, you're screwed anyway

12:19 _fogus_: stuartsierra: not unless you never violate your constraints. ;-)

12:19 or are you referring to a deeper psychological screwed?

12:20 stuartsierra: Screwed psychologically and metaphysically

12:22 _fogus_: you can add ethically to that list also

12:22 arkh: If I call lazy-seq on a some Java that returns a string, will the lazy-seq grow and retain everything over which it's 'iterated'? I need a way to make a collection/sequence that doesn't grow forever.

12:22 chouser: ponders being metaphysically screwed.

12:22 /me, that is.

12:23 arkh: no, lazy-seq just creates one step

12:23 don't see how it'd be useful to call it on a string

12:23 arkh: chouser: oh, cool

12:23 it returns a different string each time

12:24 it's some networking stuff I want to hand to seque

12:24 chouser: probably calling seq would be sufficient.

12:24 arkh: I need multiple threads, though, too ;)

12:25 chouser: still don't see what lazy-seq buys you there

12:25 but it's lunchtime, so I'm off...

12:25 arkh: doh

12:26 stuartsierra: OK, pushed Ben's #93 patches to master.

12:26 arkh: seque requires a "(presumably lazy) seq" and my multiple calls to some java need to become that. I thought lazy-seq (or something else) would be one way to provide that to seque

12:26 _fogus_: even a chouser must eat!

12:26 stuartsierra: This removes namespaces deprecated in 1.2.0

12:26 We'll see if the Hudson build passes.

12:35 Woohoo! Pass!

12:44 cemerick: The joys and sorrows of a build jockey. :-D

12:45 raek: arkh: maybe you could do something like this: http://github.com/raek/stream-seq/blob/master/src/se/raek/stream_seq.clj#L30

12:45 arkh: just replace take! with your java call

12:46 only as much of a lazy sequence you keep a reference to will be retained

12:48 stuartsierra: Now I just need to figure out how to deal with *releases* of individual modules.

12:49 That is, how to handle the case when module X wants to make a stable release while all other modules are on SNAPSHOT versions.

12:52 Now pushing patches to inhibit AOT compilation except where necessary.

12:53 cemerick: ....and build times everywhere else go up... :-)

12:53 raek: I should really complete the patch and tests for the c.c.json eof bug...

12:53 * cemerick checks his watch vis á vis #322 again

12:55 stuartsierra: raek: I fixed that, by the way, just haven't pushed to master yet

12:55 raek: I have a fix too, just some tests left

12:57 stuartsierra: Damn, build #188 failed because of clojure.contrib.logging

12:58 raek: stuartsierra: do you have it committed anywhere where I can look at it?

12:58 stuartsierra: raek: on Assembla

12:59 raek: oh. right.

13:02 looks good

13:28 joshua-choi: Can defrecord take a doc-string at all?

13:30 spewn: joshua-choi: No. Something about metadata being lost on Java objects.

13:30 joshua-choi: spewn: Unfortunate. Thanks for the answer.

13:36 chouser: you can put doc strings on record instances

13:36 not sure that that's useful. :-P

13:37 joshua-choi: Well, doc-strings are usually in vars' metadata anyway, right?

13:37 chouser: yeah

13:38 joshua-choi: I guess that defrecord creates a Java class rather than a var...

13:38 chouser: defrecord doesn't create a var, hense the problem

13:38 right

13:38 joshua-choi: ..and that's why.

13:38 It's still unfortunate.

13:38 chouser: and for some reason Class doesn't implement clojure.lang.IMeta

13:38 joshua-choi: Ha

13:39 _fogus_: (extend-type java.lang Class IMeta ...)

13:39 :p

13:40 technomancy: (extend-type java.util.regex.Pattern IFn) ;; <= if only =\

13:40 chouser: (extend-protocol PMeta Class ...)

13:41 but there'd still be no storage for the metadata

13:41 arkh: raek: thanks, I'm looking at that now

13:42 jneira: hi people

13:42 _fogus_: (extend Fogus IAwesomeness {:haikeeba (fn [_] ...))

13:42 chouser: Just read http://dreamsongs.com/ObjectsHaveNotFailedNarr.html -- interesting to hear a Guy like Steele defend objects in the face of functional programming.

13:42 jneira: (defprotocol DontWorks (for [me]))

13:42 :-(

13:43 * _fogus_ Is sad that the IAwesomeness code is poorly formed

13:43 jneira: i suppose defprotocol in 1.2.0 works for everyone else ...

13:44 .(+ 1 2 3)

13:44 jum i have to enter in irc a little bit more

13:46 , (+ 1 2 3)

13:46 clojurebot: 6

13:56 luc4s: Hi. Why do I get NullPointerException when println something and then flush? Like when I try: ((println "any")(flush))

13:57 chouser: try (do (println "any") (flush))

13:57 raek: luc4s: if you want to "do" multiple things as one expression, you have to use "do"

13:57 chouser: luc4s: those outer parens mean Clojure will try to use the return value of (println "any") as a function

13:57 but (println "any") returns nil, and calling nil as a function is a NullPointerException

13:58 luc4s: oh, I understand. I thought they where like ; and enter hehe

13:58 kumarshantanu: is a CCW user around? need to pointer on namespaces with dash character

13:58 luc4s: :chouser :raek Thanks!

13:59 raek: jneira: what error do you get?

13:59 kumarshantanu: s/to/some/

13:59 sexpbot: <kumarshantanu> is a CCW user around? need some pointer on namespaces with dash character

13:59 raek: in clojure in general, dashes in namespace names corresponds to hyphens in file names

14:00 kumarshantanu: raek: did you mean underscore in file names?

14:00 raek: eh. yes.

14:01 jneira: jum my silly fault, better i dont say nothing :-/

14:02 thanks raek

14:02 raek: kumarshantanu: but since you knew that, I guess that wasn't the problem anyway ;-)

14:02 kumarshantanu: raek: thanks, it's working in CCW now

14:03 raek: is it idiomatic in Clojure to create namespaces with a dash? I have noticed some libs that use

14:04 raek: dashes to separate words is the ideomatic way (except for generated class names, protocols, records and types)

14:05 it is what clojure.core uses, anyway...

14:06 * arkh thinks raek is awesome

14:06 arkh: I finally half understand lazy-seq

14:07 someday I'll bother to learn macro syntax and then I'll understand the other half

14:11 mcav: I had a stray (set! *warn-on-reflection* true) in a source file, and it interfered with running the app on Jetty; is it true that warn-on-reflection should always be set through the REPL and not in source files?

14:13 fliebel: What is the best way to increment one value in a nested map? Example {:increment {:this 1}} The best thing I can come up with is a lot of assoc.

14:13 mcav: fliebel: assoc-in?

14:14 dnolen_: ,(update-in {:foo {:bar 0}} [:foo :bar] inc)

14:14 clojurebot: {:foo {:bar 1}}

14:14 fliebel: dnolen: That looks more like it :)

14:15 chouser: ,(update-in nil [:foo :bar] nil?)

14:15 clojurebot: {:foo {:bar true}}

14:16 technomancy: mcav: you can set :warn-on-reflection true in project.clj so it will just work at dev-time if you're using leiningen

14:17 mcav: yeah, i'm using lein and turned that on afterward

14:18 raek: arkh: have you tried this: http://gist.github.com/480608

14:18 it can be quite useful when learning when lazy sequences are realized

14:19 arkh: I'm awesome? thank!

14:20 ssideris: raek: again, very good example

14:20 arkh: raek: crazy - that's neat

14:27 _fogus_: Is there a better way to test private vars than this kind of nonsense: (def nsm (ns-map (find-ns 'me.fogus.unifycle))) ,,, (def garner-unifiers (nsm 'garner-unifiers)) ,,, (deftest ... (is (= {} (garner-unifiers ...))))

14:28 chouser: (is (= {} (#'garner-unifiers ...))) should work

14:28 @#'foo for non-function values

14:28 mrBliss: How do I hint something of the following type:

14:29 ,(class (.getParameterTypes (first (.getDeclaredConstructors Integer))))

14:29 clojurebot: [Ljava.lang.Class;

14:29 mrBliss: adding ^"[Ljava.lang.Class" in front of it didn't work

14:29 chouser: mrBliss: keep the ;

14:29 mrBliss: gives a ClassNotFoundException [Ljava/lang/Class..

14:30 I'll tryit

14:31 I think it works (not so clear because of other warnings in the same method)

14:31 thanks

14:32 raek: the "L" and "[...;" notation of the JVM is not very aestethic...

14:33 *"L...;" and "["

14:33 chouser: no

14:35 _fogus_: chouser: no go

14:36 oh wait, it needs ns qualification

14:36 chouser: sorry, try fully-qualifiying the ... yeah

14:36 cgrand's answer was right the first time: http://clojure-log.n01se.net/date/2009-02-06.html#10:49

14:36 _fogus_: that's the ticket. thanks

14:37 fliebel: yay, my first version of markov rock paper scissors works! It's not very advanced though.

14:37 _fogus_: how the heck did you find that? you have some incredible search-fu

14:38 chouser: _fogus_: I grepped for @#'

14:38 I knew the answer -- was just looking for the date/time

14:46 mrBliss: Is it possible that type hints are lost in with-open?

14:51 chouser: ,(binding [*print-meta* true] (prn (macroexpand '(with-open [f1 ^File f2]))))

14:51 clojurebot: (let* [f1 ^File f2] (try (clojure.core/with-open []) (finally (. f1 clojure.core/close))))

14:51 chouser: looks ok there

15:00 mrBliss: thanks chouser

15:01 found my problem, I had a File in with-open, but File hasn't got a .close method

15:01 chouser: ah

15:01 and my use of ^File didn't exactly help in that regard. :-P sorry

15:17 rhickey: clojure-conj registration is now open! http://groups.google.com/group/clojure/browse_frm/thread/210ac9303d7ccec1

15:17 chouser: woo!

15:19 wwmorgan: damn. My sister's wedding is that weekend

15:20 She's going to be so disappointed ;-)

15:21 chouser: heh

15:21 danlarkin: I love fogus' picture

15:22 cemerick: Very exciting.

15:22 Great price point, hope there's a big venue :-)

15:23 mrBliss: are the talks gonna be filmed and put online?

15:26 lancepantz: they should be

15:28 raek: is rhickey's talk on pods from emerging langs available somewhere, btw?

15:29 cemerick: rhickey: might want to get someone to redirect http://first.clojure-conj.org/ to the main site

15:29 wooby: cemerick: working on it

15:42 mabes: ,(str #"foo\.bar")

15:42 clojurebot: "foo\\.bar"

15:42 mabes: Is there a way I can get "foo\.bar"? So, the non-escaped version?

15:43 chouser: that is unescaped. the string only has one backslash, it's just that when printed it needs to show you two.

15:45 mabes: chouser: my use case isn't for printing but for sending it back in an API.. i.e. this field failed to match this regexp

15:46 chouser: and when I send back the str version the response has the two slashes in it.. what am I missing?

15:46 chouser: I'm not sure.

15:46 ,(println #"foo\.bar")

15:46 clojurebot: #"foo\.bar"

15:46 chouser: ,(println (.pattern #"foo\.bar"))

15:46 clojurebot: foo\.bar

15:47 mabes: ,(prn-str #"foo\.bar")

15:47 clojurebot: "#\"foo\\.bar\"\n"

15:47 chouser: ,(count (str #"foo\.bar"))

15:47 clojurebot: 8

15:50 pdk: ,(* 6 1024)

15:50 clojurebot: 6144

15:50 pdk: show of hands

15:50 how much swap space would you give to a system youre setting up with 4gb ram

15:51 ,(* 8 1024)

15:51 clojurebot: 8192

15:52 pdk: ,(* 30 1024)

15:52 clojurebot: 30720

15:52 pdk: ,(* 35 1024)

15:52 clojurebot: 35840

15:53 ssideris: i know it's not a plausible situation, but how would you write this more elegantly?

15:53 ,(update-in {} [:a :b :c] #(do '(%) 4))

15:53 clojurebot: {:a {:b {:c 4}}}

15:55 wwmorgan: ,(assoc-in {} [:a :b :c] 4) ; ssideris: like this?

15:55 clojurebot: {:a {:b {:c 4}}}

15:56 ssideris: haha ok, I think I took the fact that you needed a function at face value

15:56 thanks

15:57 Chousuke: ssideris: out of curiosity, why did you put the '(%) in the function?

15:57 just #(do 4) would've been enough.

15:57 wwmorgan: Chousuke: My guess it to make it unary?

15:58 Chousuke: ah. right.

15:58 of course.

15:58 wwmorgan: pretty creative, actually

15:58 ssideris: Chousuke: yeah it is called with one argument

15:58 Chousuke: (constantly 4), then :)

15:58 ssideris: wwmorgan: the awkward creativity of a newbie

15:59 Chousuke: In cases like that I'd just use fn directly and not the shortcut form

15:59 stuartsierra: Clojure-Conj!

15:59 Chousuke: so you can write (fn [_] ...)

15:59 ssideris: is _ the convention for unused arguments?

15:59 Chousuke: yeah

16:00 ssideris: ok

16:00 Chousuke: though you can name the arguments too if you want to.

16:00 stuartsierra: Clojure-Conj! Clojure-Conj!

16:00 ssideris: clojure-conj would be nice, but it's a bit too far for me :-)

16:00 Chousuke: _ is just often used if neither the name or the argument matter.

16:01 stuartsierra: http://clojure-conj.org/

16:01 kumarshantanu: Chousuke: In my case _ led to non-evaluation of an expression

16:02 Chousuke: kumarshantanu: hm? how did that happen?

16:02 kumarshantanu: (defonce _ (nomnomnom)) ;; doesn't evaluate

16:03 Chousuke: kumarshantanu: Hm, I see no reason why that shouldn't evaluate but it's not a good idea anyway

16:04 wwmorgan: kumarshantanu: I think that's the defonce, and not the _. I got similar behavior until I remembered to ns-map '_ from *ns*

16:04 kumarshantanu: Chousuke: I needed a defonce to do interactive web development using Eclipse/CCW and Ring/Compojure

16:04 Chousuke: _ is a valid symbol in clojure so technically you can define a var called _ if you want to.

16:04 kumarshantanu: Chousuke: defonce was supposed to start Jetty inside a future

16:05 Chousuke: but that's not a good idea because _ is used as the "not-used" name by pretty much everything :P

16:05 kumarshantanu: Chousuke: strangely, Jetty doesn't start when I put a _, but does when I put any other name

16:06 Chousuke: I was trying _ because I didn't need to refer the value of future

16:07 Chousuke: I see.

16:07 I have no idea why jetty would break because of something like that though.

16:08 kumarshantanu: Chousuke: maybe it's not jetty....perhaps CCW or Clojure's reload-feature, I am not sure

16:08 s/reload/load-reload/

16:08 sexpbot: <kumarshantanu> Chousuke: maybe it's not jetty....perhaps CCW or Clojure's load-reload-feature, I am not sure

16:26 arohner: is there a java compiler library somewhere that could be used from a clojure repl?

16:26 I really want slime to be able to eval Java classes

16:27 kumarshantanu: arohner: ASM or CGLIB?

16:27 arohner: kumarshantanu: I don't understand

16:28 stuartsierra: arohner: there are Java "interpreters"

16:28 kumarshantanu: arohner: ASM -- http://asm.ow2.org/ and CGLIB -- http://cglib.sourceforge.net/

16:28 arohner: kumarshantanu: thanks

16:28 so javac doesn't have a Java API?

16:29 ooh, http://download.oracle.com/javase/6/docs/api/javax/tools/JavaCompiler.html

16:29 kumarshantanu: arohner: I think you can use the Groovy's eval which can accept Java code mostly as it is

16:40 lancepantz: arohner: there is an ant task for javac, which does have a java api

16:58 fliebel: Does anyone want to try and beat my Clojure Markov Rock Paper Scissors bot?

16:59 http://gist.github.com/564552

17:04 dysinger: fliebel: my draw is (chuck-norris) your bot just lost

17:05 fliebel: dysinger: What do you mean by the whole part before the last paren?

17:07 Psygology is complicated...

17:09 I'm going to switch to a better system tomorrow *yawn*

17:11 dysinger: Do you have a strategy or pattern you use? Do you base your next step on your own previous actions, or on the opponents action? I guess it's both...

17:32 replaca: Is there a way to make a java List<String> from clojure? (So I can pass it to ProcessBuilder.)

17:33 kumarshantanu: replaca: pass this -- '("string1" "string2" "string3")

17:34 replaca: directly to ProcessBuilder?

17:34 kumarshantanu: replaca: java's generics have type erasure, so at runtime it's just List, not List<String>

17:34 replaca: yes

17:34 replaca: ahh, thx, I'll give it a try

17:37 raek: ,(map #(instance? java.util.List %) [(list 1 2 3) [1 2 3]])

17:37 clojurebot: (true true)

17:41 replaca: kumarshantanu: works like a charm! thanks

17:42 kumarshantanu: replaca: clojure is a better language to write Java code too :-)

17:44 replaca: kumarshantanu: for me it's the best language to write any code. Today I'm using it to write a development dashboard (showing perforce and bugzilla activity is a convenient web interface)

17:45 *is => in

17:46 kumarshantanu: replaca: cool, what libraries are you using? just curious

18:10 mvid: im trying to set up the compojure hello world, but when i run lein repl src/project/core.clj i get a "wrong number of arguments to repl task" error

18:11 lancepantz: mvid: just lein repl

18:11 mvid: then what?

18:11 that doesn't run jetty

18:12 raek: mvid: I think you need to update leiningen

18:12 arbscht: require your ns

18:12 raek: the script argument was added pretty recently

18:12 lein repl

18:12 (require 'project.core)

18:13 mvid: im using lein v 1.3

18:14 is that too old?

18:14 raek that worked

18:15 arbscht: 1.3 is fine. I don't think lein supports that argument anymore, if it ever did

18:15 mvid: cool

18:15 thanks

18:15 technomancy: it never supported arguments on purpose; it just accepted them because it used to be based on clojure.main.

18:16 but if you set an ns as your :main in project.clj it will requrie and in-ns it

18:20 Raynes: chouser: In a little while, I'll post to my group thread with some profiler data before and after a couple of :reloads. I'm considering checking out yourkit. I may just suck at profiling, but jvisualvm's data is kind of greek to me. :p

18:23 chouser: yourkit does a somewhat better job of making the data make sense, but it's still a bit befuddling to me

18:28 replaca: kumarshantanu: sorry, I wandered off

18:29 kumarshantanu: replaca: np

18:29 replaca: kumarshantanu: for bugzilla I'm using the apache xmlrpc lib and for perforce I'm just grinding on shell output

18:30 kumarshantanu: replaca: what's for the web handling? ring/compojure/enlive? or something else?

18:30 replaca: on the other side, I was thinking I was going to use compojure (cause I already have code), but I may look around for something else and for formatting, I love enlive

18:30 kumarshantanu: okay

18:31 replaca: Clojure really shines in this "gluing a whole bunch of stuff together" area

18:31 technomancy: you could use coldfusion

18:31 it's an option these days

18:32 replaca: technomancy: are you being sarcastic? That's not allowed on this list

18:32 technomancy: sorry, I forgot my unicode irony mark

18:32 replaca: :)

18:32 technomancy:

18:33 replaca: Yeah, I didn't understand if his objection to enlive was just in not understanding its mechanism or because he really preferred the jsp/erb way of doing things

18:35 mvid: does anyone have a favorite compojure authentication library?

18:37 tomoj: is there more than one choice?

18:37 mvid: is there any choice?

18:41 tomoj: could've sworn I saw something on planet clojure recently

18:41 lancepantz: i think it was the guy that does sandbar talking about it

18:41 brenton somebody

18:42 tomoj: aha http://github.com/brentonashworth/sandbar

18:42 yeah

18:42 mvid: don't take that as a recommendation

18:43 lancepantz: http://formpluslogic.blogspot.com/2010/08/securing-clojure-web-applications-with.html

18:46 tomoj: hurray fnparse activity

20:08 DanielGlauser: Let's say I'd like to mutate a map within the confines of a ref, I'd like to change a value for a couple of the keys. Would I create a new map with the changed values or is there a way to set a value in the map?

20:12 kumarshantanu: hi, can anybody let me know how can I (1) extract a value from request map *AND* (2) get route variable...with a route in Compojure?

20:12 Licenser: DanielGlauser: you can't change values in the map, they are imutable that is the whole point

20:13 kumarshantanu: (GET "/foo/:id" {params :params} [id] (whatever...))

20:14 Licenser: kumarshantanu: sorry I don't know compojure

20:15 DanielGlauser: Licenser: So if I had a map with 20,000 values in it, there's no way to mutate it even if I'm within the confines of a transaction (doseq ...)

20:16 technomancy: DanielGlauser: you want to call alter with assoc

20:17 Licenser: yes so it won't mutate the map in the end it's still a new map

20:17 (unless it are transients but I think that goes too far)

20:18 DanielGlauser: technomancy: Thanks! I've spent so much time studying the immutable stuff when it came time to mutate something I didn't know how to do it.

20:18 technomancy: well... you're still not mutating a data structure

20:18 DanielGlauser: Licenser: I'm okay with it being a new map, I just didn't want to have to iterate through the entire map to construct a new one

20:19 Licenser: ah okay then I missunderstood you sorry :)

20:20 DanielGlauser: technomancy: Yeah, I get that part, thanks! Wrote code to iterate through the map and figured there was a better way. Thanks guys.

20:21 Licenser: wow I really wasn't helpful o.O sorry DanielGlauser :)

20:26 jneira: i think if i continue twetting translations from raw to monadic computations my popularity is going to go down...

21:44 zztr: ,(deftype Mytype [a b] Object (toString [this] (str a b)))

21:44 clojurebot: sandbox.Mytype

21:44 zztr: ,(def mt (Mytype :y :z))

21:44 clojurebot: DENIED

21:45 zztr: ,(Mytype :y :z)

21:45 clojurebot: java.lang.Exception: Expecting var, but Mytype is mapped to class sandbox.Mytype

21:45 zztr: I can't find an example of how to do this correctly

21:49 ,(Mytype. :y :z)

21:49 clojurebot: #<Mytype :y:z>

21:50 zztr: sigh

22:29 dnolen: zztr: http://github.com/ztellman/cantor/blob/master/src/cantor/vector.clj#L358

23:02 qbg: Finally found a use for promise/deliver

23:02 I use it once in my parallel mapreduce function

Logging service provided by n01se.net