#clojure logs

2010-09-03

00:27BahmanHi all!
01:05blaisQ: Is is possible to redefine the dispatch-fn of a multimethod in a running environment?
01:05blaisi.e., I use Emacs, I eval gradually. I want to change the dispatch function of a multimethod. Doesn't seem to work.
01:05blaisAny idea?
01:06kumarshantanuhi, can anybody point me to a code sample that uses flash messages in ring/compojure?
01:08wwmorganblais: the defmethod behavior was changed with 1.2. It now has defonce semantics
01:08wwmorgan*defmulti
01:08Raynesblais: 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.
01:09Raynes(doc ns-unmap)
01:09clojurebot"([ns sym]); Removes the mappings for the symbol from the namespace."
01:09wwmorganapparently, (def foo nil) will also work
01:09RaynesOr that.
01:10scottjkumarshantanu: I don't think there are any.
01:11kumarshantanuscottj: I am looking to use flash messages (now added in ring), but not sure what's the syntax etc
01:11kumarshantanuscottj: so any doc link may also be useful
01:15scottjkumarshantanu: 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.
01:30blaisRaynes: thx man.
01:31blaiswwmorgan: thx.
01:33kumarshantanuscottj: thanks, I am experimenting with the flash middleware
01:37scottjkumarshantanu: if you come up with a simple example please post it
01:37kumarshantanuscottj: sure
02:04luc4sHi. I'm learning Clojure and have a little problem.
02:04luc4sHow can I transform this: ("1" "2" "3") ("a" "b" "c") into this: (["1" "a"] ["2" "b"] ["3" "c"])
02:05wwmorgan,(map vector '("1" "2" "3") '("a" "b" "c"))
02:05clojurebot(["1" "a"] ["2" "b"] ["3" "c"])
02:06luc4s:wwmorgan thanks a lot. I was like a couple of hours struggling with that and interleave and etc.
02:08wwmorgan,(partition 2 (interleave '("1" "2" "3") '("a" "b" "c"))) ;-) is another way to do it, if you don't need vectors
02:08clojurebot(("1" "a") ("2" "b") ("3" "c"))
02:09luc4soh, no. I need the vectors for a func I made already hehe
02:10luc4sthanks again. Clojure is a fantastic language, but a little hard for a imperative c++ programmer like myself
02:37kumarshantanuscottj: got the flash thing working, but it's a bit involved
03:19LauJensenIs there a cake option for adding arbitrary options to the jvm at compile time?
03:20LauJensen.cake/config => project.java_opts = ...
03:20scottjkumarshantanu: sweet, have a basic example you can gist or something?
03:21noidiLauJensen, did that work?
03:21LauJensentesting now
03:21kumarshantanuscottj: I will...I am re-factoring few things -- will post a gist
03:21scottjkumarshantanu: 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?
03:21LauJensenyes it did noidi
03:21scottjkumarshantanu: cool
03:22noidiI'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
03:22noidiCake looks interesting, I should really give it a try some day
03:23LauJensenagreed :)
03:23octehow do i require multiple things in an ns-declaration? i tried this: http://pastebin.com/xKqwACtC but it's not correct..
03:24noidionce I get over this damn flu... I'd be at work now if I had the energy to write Clojure code :P
03:24bartjI think it is not possible to import all the classes in a package like in Java, is this correct ?
03:24kumarshantanuscottj: 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
03:24bartjfor eg: import org.apache.http.* would translate to:
03:25bartj(:import org.apache.http *) ?
03:26LauJensencorrect, its not possible
03:39kumarshantanuscottj: I created a gist -- http://gist.github.com/563552
03:40scottjkumarshantanu: cool, you don't need var and future on run-jetty
03:40scottjoh nevermind forget that
03:42kumarshantanuscottj: i copy-pasted from my Eclipse IDE -- I use future and defonce for interactive web development
03:43scottjI was confusing var/future for :join? false/future
04:02LauJensenHas anyone here had trouble compiling a project which imports JFreeChart ?
04:08springifyHello 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?
04:12kumarshantanuspringify: you might as well raise a ticket on Leiningen -- asking to push to Clojars
04:14springifykumarshantanu: True, just wanted to know whether I missed something.
04:17springifyDone: http://github.com/technomancy/leiningen/issues#issue/106
04:18kumarshantanuspringify: just noticed the issue - it says "Release leiningen 1.5"
04:18springifyHeh, no, just edited. Hit the return key accidentally.
04:18kumarshantanuspringify: the next planned release is 1.3.1 as far I know
04:19springifykumarshantanu: 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.
04:21kumarshantanuspringify: Lein on Clojars may be useful for writing plugins I guess -- is that the purpose if I may ask?
04:23springifykumarshantanu: I'm maintaining a branch of lein-cuke, (cuke4duke with leiningen), which depends on leiningen, yes.
04:27kumarshantanuspringify: this is cool (googled them), thanks for sharing the details
04:30springifykumarshantanu: You're welcome. I can only claim credits for providing the project.clj and a single fix, tho :)
04:31kumarshantanu**time for lunch...ciao
04:31yayitsweiquick question: what's the equivalent of clojure.set/select for lists? for example I want to write (select #(> % 2) '(1 2 3 4))
04:32yayitswei;; => (3 4)
04:33LauJensenfilter comes to mind
04:33Raynes-> (filter #(> % 2) '(1 2 3 4))
04:33sexpbot=> (3 4)
04:33yayitsweiah, that's exactly what i was looking for
04:34LauJensen-> (remove #(< % 2) '(1 2 3 4))
04:34sexpbot=> (2 3 4)
04:34yayitsweior remove too.. thanks guys
04:34LauJensennp
04:35ordnungswidrigLauJensen: I will not higlight you, as cuke was mostly a drop-in. :-)
04:35LauJensencuke-de-duke? :)
04:36ordnungswidrigcuke-de-cake, actually :)
04:36LauJensenIts 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
04:36ordnungswidrigLauJensen: I noticed that too.
04:36LauJensenYou've been checking my referrers?
04:38ordnungswidrigLauJensen: 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 :)
04:38LauJensenthats an awesome feat, especially considering I dont have a webmail :)
04:38ordnungswidrig*doh*
04:42esj<greetings>All<Special Greeting>LauJensen</Special Greeting></greetings>
04:42esj:P
04:42LauJensenGreetings and salutations esj! :) Whats the the XML, you started greeting people in Maven? :)
04:43esjcorrect in one :)
04:43esjof course, in future, I just need to go $mvn greet
04:43esjand I'm done :)
04:44LauJensenWell - Its not a real Maven vs Sane Tools smackdown before we have a blogpost :) I'll cook something up
04:45esjlol
04:49LauJensenI cant decide "Wasting your life like a pro - Maven" or "Wasting your customers money - Maven", which is better?
04:49LauJensenI mean, they're both terrible accurate...
04:53bobo_i think the first one
04:53bobo_not everyone has customers
04:53bobo_and sometimes, its the customers choice
04:58LauJensenExactly what I thought :)
04:59LauJensenOr 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"
04:59LauJensenok enough, we have to stop before cemerick wakes up :)
05:00bobo_well, i have an ant build for the project i am working on now... maybe i shouldnt yell at maven
05:01esjIts the best thing I've used, super potent and easy, but as discussed, I haven't checked out cake yet.
05:01lancepantz_member:LauJensen: justin mentioned that you were thinking about writing a post on cake?
05:02esjand if I can goad Lau into doing my research for me, so much the better ;P
05:02LauJensenlancepantz_: Thats right
05:02lancepantz_awesome
05:02lancepantz_i'm working on the task system ATM
05:03LauJensenawesome begets awesome, now the pressures on me to write a good post :)
05:03lancepantz_we whiteboarded some really cool stuff today, i
05:03lancepantz_'m excited ot get it in
05:03LauJensendetails details! :)
05:04lancepantz_adding a deffile macro that's similar to deftask
05:04lancepantz_*defile
05:04LauJensendeffile is very differnt from defile
05:04lancepantz_takes in a string thats the name of the file you want build
05:04bartjer, how would one go about translating this Java stmt to Clojure ?
05:04lancepantz_hehe, i like defile :)
05:04bartjorg.apache.http.client.HttpClient client = new DefaultHttpClient();
05:04LauJensenlancepantz_: I dont, keep it clean
05:04esjlol
05:04LauJensen(let [client (DefaultHttpClient.)]
05:05bartjLauJensen, no that doesn't work - I tried that
05:05lancepantz_in the spirit of defn instead of deffn then :)
05:05LauJensenbartj: thats the translation though, so something else is wrong
05:05LauJensen(let [client ^org.apache.http.client.HttpClient (DefaultHttpClient.)] ... ?
05:06lancepantz_the defile dependences are a set of files that are the source files for the file being generated
05:06lancepantz_and the macro compares the timestamps to see if it need to be ran
05:06lancepantz_so something like
05:07lancepantz_(defile "pom.xml" #{"project.clj"} (prxml [pomstuff]))
05:08lancepantz_then the task will only generate a new pom when either it doesn't already exist, or pom.xml is older than project.clj
05:08lancepantz_it's going to clean the code up quite a bit
05:08LauJensennice
05:09lancepantz_(defile "lib/*.class" #{src/**/*.clj} (compile blah blah..))
05:10lancepantz_(defile "lib/*.class" #{"src/**/*.clj"} (compile blah blah..)) actually
05:10LauJensenSo this goes into the optimization category
05:10LauJensenIm excited to see how much mileage you'll get out of Ivy
05:11lancepantz_yeah, i think we're vectoring in on the feature set we want for 1.0
05:11lancepantz_me too, ivy looks great
05:11ordnungswidrigdoes cake only work on files as a resource? or can the artefacts that came out of a build step other things as well?
05:11lancepantz_there was a guy working on a patch for it, but i think he's gotten busy
05:11LauJensenJust make sure you weed out the bugs before 1.0 comes - I'm posting one today, if I didn't already
05:12Rayneslancepantz_: I found a bugzors.
05:12lancepantz_ordnungswidrig: you mean build things other than files?
05:13ordnungswidriglancepantz_: yes
05:13lancepantz_example?
05:13clojurebotexamples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples
05:13lancepantz_Raynes: is it with the jvm restarting?
05:13Rayneslancepantz_: Nosir.
05:13lancepantz_sup?
05:13ordnungswidrigsimple example: data into database
05:13Rayneslancepantz_: 'open' times out way, way too quickly in the download function.
05:14Rayneslancepantz: On a slow connection, there is absolutely no chance of it completing.
05:14RaynesOh a really, *really* slow connection, anyway.
05:14Raynes;)
05:14lancepantz_ordnungswidrig: ahh, well yeah, anything you can do in clojure you can do in a cake function
05:14ordnungswidrigmore 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.
05:15LauJensenordnungswidrig: 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 :)
05:15lancepantz_Raynes: ah, i believe it, get up with ninjudd tomorrow, he's been working on all that stuff
05:15Rayneslancepantz_: 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.
05:15ordnungswidrigLauJensen: in cake?
05:15LauJensenordnungswidrig: Yes
05:15Rayneslancepantz_: Will do. Just waiting on him. :D
05:15LauJensenRaynes: Just post an issue on Github, these guys work FAST :)
05:15ordnungswidrigLauJensen: would this be possible in leiningen?
05:16RaynesI'll be up for a while. If I can't talk to ninjudd before I go to sleep, I'll make an issue.
05:16LauJensenordnungswidrig: Yea I think so, but not as elegantly - I've overriden the compile task
05:16LauJensenor, extended it actually
05:16lancepantz_ordnungswidrig: yeah, you are describing dependency based programming, which was our whole goal for the project
05:16lancepantz_all the other stuff was just afterthoughts :)
05:18ordnungswidrigcool. 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.
05:18lancepantz_right, exactly
05:19adbenmorning *
05:19lancepantz_we're setting up an engineering blog and i'm going to write up a really detailed post explaining the need for it
05:21yayitsweianother question for you guys.. why doesn't -> work with anonymous functions? for example, (-> 1 #(+ % 2 3))
05:21yayitsweii would expect => 6
05:23lancepantz_,(-> 1 (partial + 2 3))
05:23clojurebot#<core$partial$fn__3678 clojure.core$partial$fn__3678@60bb22>
05:25lancepantz_yayitswei: i would expect that as well
05:25tomoj,(read-string "#(+ % 2 3)")
05:25clojurebot(fn* [p1__4395#] (+ p1__4395# 2 3))
05:26tomoj,(macroexpand-1 '(-> 1 #(+ % 2 3)))
05:26clojurebot(fn* 1 [p1__4396#] (+ p1__4396# 2 3))
05:27yayitsweihmm. or a better question: what's the idomatic way to rewrite that?
05:28yayitsweilet's say, (-> 1 #(+ % 2 3) println)
05:28tomoj(println (+ 1 2 3)) ?
05:28noidiyayitswei, you'll have to write it as (#(...))
05:28yayitswei,(println (#(+ % 2 3) 1))
05:28clojurebot6
05:29Raynes->(-> 1 (#(+ % 2 3)))
05:29sexpbot=> 6
05:29yayitsweiooh
05:30yayitswei(-> (-> 1 #(+ % 2 3) ) println)
05:30yayitswei,(-> (-> 1 #(+ % 2 3) ) println)
05:30clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.ISeq
05:30noidi,(macroexpand '#(println %))
05:30clojurebot(fn* [p1__4407#] (println p1__4407#))
05:31noidiso the #() expands to the list above
05:31noidiand -> will stick the result of the previous expression as the second item in that list
05:31noidi,(macroexpand '(-> 123 #(println %)))
05:31clojurebot(fn* 123 [p1__4410#] (println p1__4410#))
05:31noidiwhich does not make any sense
05:31noidiso you'll get an error
05:32noidi,(macroexpand '(-> 123 (#(println %))))
05:32clojurebot((fn* [p1__4413#] (println p1__4413#)) 123)
05:32noidibut that works, because the first item in the list is a function, and the second is its argument
05:33yayitsweiwhat does fn* mean?
05:35Raynes(doc fn*)
05:35clojurebotGabh mo leithscéal?
05:35yayitsweiohhh but i get your meaning
05:35yayitsweiso i should write it as ,(-> 1 (+ 2 3) println)
05:35yayitswei,(-> 1 (+ 2 3) println)
05:35clojurebot6
05:37LauJensen,(-> 1 (+ 2 3))
05:37clojurebot6
05:37LauJensenIsnt that good enough? :)
05:38LauJensenOh I see I missed a larger discussion :|
05:39noidiI don't really understand the opposition to adding a variant of -> that places the threaded value at a marked position
05:39LauJensennoidi: -> ->> is all you need IMO
05:39yayitsweiyep! thanks guys. I didn't fully understand what -> did
05:39LauJensenyayitswei: You got it now?
05:39yayitsweiyeah
05:40yayitsweifunny because you can't google ->
05:40noidi,(doc ->)
05:40clojurebot"([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."
05:40yayitsweiahh
05:40LauJensenyayitswei: Yea, thats how we get so many members in #clojure
05:40noidiyayitswei, when you are not sure what a macro does, macroexpand and macroexpand-1 are your friends
05:41tomojnoidi: "rich said no" isn't enough for you? :P
05:41yayitsweihaha cool, will try that next time
05:42noiditomoj, heh, well, that's a good reason I guess :)
05:43ordnungswidrignot be able to google for "->" and so on is a problem for haskell and scala, too.
05:43ordnungswidrigbut the haskell guys have solved the problem
05:44yayitsweiordnungswidrig: how did they solve it?
05:47ordnungswidrigyayitswei: they have hoogle and hayoo
05:47ordnungswidrigyayitswei: 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.
05:47ordnungswidrig
05:47ordnungswidrig
05:48yayitsweimember:ordnungswidrig: nice, looking at it now
05:48noidi,(find-doc "Thread")
05:48clojurebot------------------------- 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.
05:49yayitsweiwe have our trusty clojurebot
05:50ordnungswidrigthe 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
05:51LauJensenI keep getting referers from here https://secure.wikimedia.org/wikipedia/en/wiki/Main_Page , can anybody work out why?
05:52ordnungswidrigLauJensen: maybe real path is cut because it is a secured connection?
05:52LauJensenmaybe
05:53ordnungswidrigOr somebody playing a joke on your logfile?
05:53LauJensenNot possible
05:53LauJensenUnless you mean, by way of referrer spam
05:57ordnungswidrigNot possible? I can do a curl -H'Referer: https://secure....' https://secure.wikimedia.org/wikipedia/en/wiki/Main_Page can't I?
06:01Raynesordnungswidrig: Once clojuredocs has an API, we'll have that as well.
06:01RaynesI mean, we have it now, but once we have an API, it can be integrated with the bots.
06:03LauJensenordnungswidrig: Yes, thats referrer spam
06:03LauJensen(ps: if you dont highlight me, chances are I wont look)
06:05ordnungswidrigLauJensen: ok, I think some day, we can manage on a proper mutual highlighting policy :)
06:09ordnungswidrigcan I search for a ns where a symbol / function is defined?
06:25LauJensenM-. fn
06:25LauJensen@ ordnungswidrig
08:14arnorhswhazzup
08:14arnorhsAre there any stable zero mq bindings for clojure? You just use the java ones right?
08:14arnorhsDo you think they can be set up using lein ?
08:16dnolenarrnorhs: yeah use the zeromq java bindings. you'll probably want to use native-deps for that.
08:19mrBlissis there a reason for the absence of (copy ^URL *) in the io libraries?
08:19stuartsierramrBliss: nobody wrote it
08:20mrBlissI have written the 3 needed methods if you want them (thanks goes to LauJensen)
08:20stuartsierracool, post to the mailing list and we'll take a look
08:20mrBlissalright
08:21mrBlissclojure or clojure-dev?
08:22stuartsierramrBliss: clojure
08:32mrBlisscould 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
08:33stuartsierraclojure.contrib.io is slated for removal anyway
08:35mrBlisscopy's also deprecated I see, so should I continue?
08:35stuartsierraall that has moved to clojure.java.io
08:35stuartsierraFurther development will continue there.
08:35mrBlissok I see
08:37mrBlisssame 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
08:38stuartsierrayes, although it doesn't actually matter
08:42Licensergreetings my lispy friendsw
08:42Licenseris 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
08:51kumarshantanucan anybody help me understand how to express (if cond step1 else-step-2-and-step3)
08:51mrBliss(if cond step1 (do step2 step3))
08:51kumarshantanustep2 and step3 are independent
08:51kumarshantanumrBliss: will (do ...) return the value that step3 returns?
08:51mrBlisscorrect
09:06mrBlissstuartsierra: post sent
09:28bartj, (doc do)
09:28clojurebotIt's greek to me.
09:29bartjthe error - " Unable to resolve classname" occurs because the class was not imported ?
09:30chouserprobably
09:30bartjchouser, what could be the other reasons ?
09:32bartjif I have the following line in Java: org.apache.http.client.HttpClient client = new DefaultHttpClient();
09:33bartjthe DefaultHttpClient is present in org.apache.http.client
09:33bartjI am sorry, DefaultHttpClient is present in org.apache.http.impl.client
09:34bartjand HttpClient is present in org.apache.http.client
09:34bartjso, while importing the java classes, I have something like:
09:34bartj(:import [org.apache.http.client.HttpClient] [org.apache.http.impl.client.DefaultHttpClient])
09:35bartjstill, I get a Unable to resolve classname error
09:35bartjcan someone please point what I am doing wrong ?
09:35mrBlisstry (:import [org.apache.http.client. HttpClient]
09:35mrBliss[org.apache.http.impl.client DefaultHttpClient])
09:35mrBlissnote the spaces
09:35mrBliss(remove that trailing dot from client.)
09:36raekdoes that work with the vectors?
09:36mrBlissyes
09:36mrBliss[package.subpackage Class]
09:36stuartsierravectors should be lists there
09:36raekparantheses are the most commonly used for prefix lists
09:36bartjLauJensen, told me that they were one and the same!
09:36stuartsierraThat's an implementation detail.
09:36stuartsierraIt just happens to work.
09:37raek(ns foo.bar (:import org.apache.http.client.HttpClient org.apache.http.impl.client.DefaultHttpClient))
09:37raek(ns foo.bar (:import (org.apache.http.client HttpClient) (org.apache.http.impl.client DefaultHttpClient)))
09:38raekso, using 1-vectors happens to be the same as the infamous empty-prefix-list
09:38bartjraek: I am assuming your last import is the correct one ?
09:38raekyes
09:39raekit is the way I have learned that it should be done
09:39raek(please correct me, someone, if I have learned the wrong thing)
09:39bartjok, I now get an error that makes sense!
09:40raekanyway, (:import [org.apache.http.client.HttpClient]) is treated like (:import (org.apache.http.client.HttpClient))
09:40chouserstuartsierra: why are parens preferred?
09:40raekthat is, import *nothing* from the "org.apache.http.client.HttpClient" package
09:40stuartsierrachouser: 'Cause that's what the docs say, dammit!
09:40bartjraek, org.apache.http.client.HttpClient is not the same as org.apache.http.client HttpClient !
09:40bartjraek, why so ?
09:41chouserstuartsierra: hm. good point.
09:41raekno
09:41raekfoo.bar.A is the same as (foo.bar A)
09:41raekfoo.bar.A foo.bar.B is the same as (foo.bar A B)
09:41bartjok, then the only change that I did was to convert [] to ()
09:42raekyou need to either drop the parens or replace the last period with a space
09:43bartjI did both
09:43raek(:import (foo.bar)) means "for all elements of the emply list, import them from the foo.bar package"
09:43bartjand thinks seem to work fine
09:44raekok, great!
09:44raekwhat does your :import look like now?
09:45bartj(:import (foo1 bar1) (foo2 bar2))
09:46bartjI previously had:
09:46bartj(:import [foo1.bar1] [foo2.bar2])
09:48bartjI wonder why that is wrong!
09:48raekthe previous?
09:48bartjyes, my last statement
09:49raekbecause of how it's implemented, it gets treaded as (:import (foo1.bar1) (foo2.bar2)) would have
09:50raeksince you should only use vectors when passing options, iirc
09:50raekdo you understand how (:import (foo1.bar1) (foo2.bar2)) is interpreted?
09:50bartjno
09:52raekbut you understand how (foo.bar X Y Z) would be interpreted, right?
09:52bartjcan you please explain
09:52bartjyes, import the classes X Y Z of package foo.bar
09:53raeknow, imagine that you import *no* classes from package foo.bar... how would that be written?
09:53bartj(:import (foo.bar '()))
09:54raek(foo.bar X Y) = two classes, (foo.bar X) = one class, (foo.bar) = zero classes
09:54bartjok
09:54raekyour example has an empty list where the first class should go
09:54bartjyes, right - just (foo.bar)
09:54raekexactly
09:54bartjI think I was trying to be a bit clever - unnecessarily
09:55raekit's too bad that it doesn't signal any error when you do that
09:55raeksince I don't think *anyone* wants to import zero number of classes
09:55bartjok
09:56bartjso (:import (foo1.bar1) (foo2.bar2))
09:56bartjactually don't make sense
09:56bartjbecause you don't specify any classes for the packages ?
09:56chouserit really ought to print a warning
09:56bartjam I correct ?
09:57bartjI am sorry, I gotta run
09:58bartjraek, thanks a lot
10:26hugodis there any way (defn f [a b c :as argv] ..) could work?
10:26chouser(defn f [ & [a b c :as argv]] ...)
10:29hugodhow about (defn f [a b & c :as argv] ..)
10:30chouserthe parameter lists given to fn's are not destructuring. Instead you can provide multiple arg lists, one of which may use &
10:31chouser:as is a destructuring feature
10:31chouserso 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:31hugoddestructuring works well with map arguments :)
10:32chouser(defn f [ & [a b & c :as argv]] ...)
10:32hugodbut as you say (defn f [& [a b & c :as argv]] (println argv)) works
10:32hugodthanks
10:40stuartsierrahello, contrib committers
10:40stuartsierra?
10:43chouseruh.. um... ahem, yes?
10:43stuartsierraI'm working on a versioning / release policy for the modularized contrib
10:44stuartsierrawith the goal to get people committing again
10:44chouserhm.
10:44stuartsierraTrying to figure out how to handle dependencies.
10:44chouserpolicies will increase motivation?
10:44stuartsierraWell, I want to make it easier to release a module with a stable version number.
10:44chouserok, I can see the benefit there.
10:45stuartsierraSo that modules can improve independently from the monolithic clojure-contrib
10:45stuartsierraBut that raises questions, such as...
10:45stuartsierraWhich version of Clojure (core) should modules depend on?
10:46stuartsierraMaven 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:49stuartsierraRight now, all sub-modules inherit the Clojure dependency (pegged at 1.2.0) from a "parent" module.
10:50chousercan that be tweaked per-module?
10:50stuartsierrayes
10:50chousersounds good.
10:50stuartsierraSo I think the default should be something fairly broad, like "[1.0.0,2.0.0)", which individual modules can override.
10:51fliebelhey
10:51stuartsierraThe only problem is AOT-compilation (dun dun DAAAH).
10:51chouserheh
10:51raekwhat happens if the dependencies of a project depends on different clojure versions, btw?
10:51chouserseriously. that was perfect.
10:51stuartsierra:)
10:52stuartsierraclojure-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:52stuartsierraHOWEVER
10:52stuartsierraAs we know, AOT-compilation is indiscriminately transitive.
10:53stuartsierraFor example, AOT-compiling clojure.contrib.condition.Condition (for gen-class purposes) also AOT-compiles clojure.contrib.seq.
10:53abedrastuartsierra: and indiscriminately awesome
10:54chouseris that behavior not yet slated to be changed?
10:54stuartsierraThose AOT-compiled functions may be binary-incompatible with any Clojure version other than the one they were compiled with.
10:54stuartsierrachouser: not yet, despite many requests
10:56chouseris there not buy-in on the idea of intransitive compilation, or is it just a issue of correct implementation?
10:56stuartsierrathe latter, I think
10:57chousercemerick: c'mon, man, write a better patch!
10:57chouser:-)
10:58cemerickha
10:58cemerickchouser: 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:58cemerickBut then, rhickey has shown me up before. :-)
10:58stuartsierrahttps://www.assembla.com/spaces/clojure/tickets/322-enhance-aot-compilation-process-to-emit-classfiles-only-for-explicitly-specified-namespaces
10:59stuartsierraStu Halloway has moved this to Release.Next, meaning 1.3.0 probably.
10:59chouserperhaps it should be committed to master soon so people can start experiencing the pain, if any.
11:00stuartsierraNow, there are very few contrib modules that still require AOT-compilation.
11:00cemerickI'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:00stuartsierraSo my plan would be to release those with clojure.version set to 1.2.0 exactly.
11:01stuartsierracemerick: yes that sounds right
11:01chousercould an individual module specifically prevent itself from being AOT compiled?
11:02chouserI guess that might bug people building their own apps based on contrib.
11:03stuartsierrachouser: I don't think there's any way to do that
11:03cemerickThere's always banging away at *compile-path* as desired, before and after the entirety of the ns....
11:03chousercemerick: that's roughly what I was thinking.
11:04stuartsierraYeah, there's even an option in clojure-maven-plugin to do that.
11:04stuartsierraBut I really don't want to go there.
11:04cemericka lib should never be able to *prevent* itself from being AOT-compiled.
11:04cemerickYou never know what people downstream will need to do.
11:04cemerickBesides, AOT is orthogonal to code, and belongs in the build config (whatever form that may take).
11:06stuartsierraSo if I can clean up the deprecations, I will try to release clojure-contrib 1.3.0 later today.
11:06stuartsierraFrom that point, each module can follow its own release / versioning path.
11:07stuartsierraWe'll just have to figure out how to get the "release" artifacts deployed on build.clojure.org.
11:07chouserwill there still be whole-contrib releases?
11:07cemerick...and chaos will rule the land.. ;-)
11:07stuartsierracemerick: you got that right
11:08stuartsierraThere will still be versioned releases of org.clojure.contrib:complete, which will have transitive dependencies on all other modules.
11:08stuartsierraUsing the latest released version of each module.
11:08cemerickI presume chouser is talking about an aggregate *shrug*
11:09stuartsierraYou can already get an aggregated JAR from the "complete" module.
11:09stuartsierraAggregated ZIP releases are on my TODO list as well.
11:09cemerickoh, oh -- I figured that was just a shell to point @ the transitive deps.
11:10stuartsierracemerick: it is, but it has a Maven assembly configuration to produce a contrib uberjar.
11:10stuartsierraAlthough this is not deployed as an artifact on build.clojure.org
11:10cemerickOh how I dislike that term...
11:11stuartsierraNevertheless, in Maven or Leiningen, depending on org.clojure.contrib:complete will give you all of contrib
11:11stuartsierracemerick: me too, but I have fun saying it in a faux-German accent.
11:16ordnungswidrigI'm looking for an easy way to "join" map, say {:a 1 :b 2} to "a=1;b=2"
11:17fliebelordnungswidrig: With that specific syntax?
11:17cemerickstuartsierra: 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:17ordnungswidrigfliebel: , instead of ;
11:17fliebelordnungswidrig: I'll try to cook something up...
11:23fliebel,(reduce #(str %1 (name (first %2)) "=" (last %2) ", ") "" {:a 1 :b 2})
11:23clojurebot"a=1, b=2, "
11:23stuartsierrafliebel: that's less efficient that using a StringBuilder
11:24fliebelstuartsierra: Enlighten us :)
11:24ordnungswidrigstuartsierra: what would be acomplished how?
11:24chouser(symbol (apply str (mapcat #(cons "\n" (next (map {\0 \ \1 \#} (Long/toBinaryString %)))) [185 13235209671M 25939708511M 1654794401M 12429901063M 131081 65539])))
11:25chouseroh wait, that's something else
11:25mrBliss,(require '[clojure.string :as s])
11:25clojurebotnil
11:25mrBliss,(s/join ", " (map #(str (first %) "=" (second %)) {:a 1, :b 2}))
11:25clojurebot":a=1, :b=2"
11:25stuartsierra(let [sb (StringBuilder.)] (doseq [[k v]] (.append sb (str k)) (.append sb "=") (.append sb (str v))) (str sb))
11:26stuartsierraStrings make me go all imperative for some reason.
11:26ordnungswidrigstuartsierra: where comes the map in?
11:26stuartsierraoops
11:26stuartsierra(doseq [[k v] the-map] ...)
11:26stuartsierraand I bet I missed a paren or six
11:26chouser,(apply str (butlast (mapcat (fn [[k v]] [(name k) \= v \,]) {:a 1 :b 2})))
11:26clojurebot"a=1,b=2"
11:27mrBliss,(s/join "," (map #(str (name (first %)) "=" (second %)) {:a 1, :b 2}))
11:27clojurebot"a=1,b=2"
11:27fliebelchouser: Thanks, a new function was learnt :)
11:28ordnungswidrigthanks all
11:28ordnungswidrigI throw in a (-> % first name) to get rid of the :
11:30chouserfliebel: probably should be drop-last instead
11:30ordnungswidrigWhat is "Unsupported binding form: ..."
11:30chouserin fact, it should be. please pretend I never mentioned butlast
11:31fliebelchouser: What's the difference? they both seem to produce the desired result.
11:33chouserbutlast is eager but returns a seq. odd beast.
11:33fliebelchouser: So the only difference is that drop-last is lazy?
11:33arkhwhy doesn't this return anything? (for [x (repeatedly rand)] (prn x))
11:34chouserdrop-last returns a normal lazy seq, plus can take a numeric arg and has a beautifully clever definition.
11:35chouserarkh: 'for' is lazy, so 'prn' won't be called unless you force the sequence.
11:35chouserarkh: you could try replacing 'for' with 'doseq', but that'll never end.
11:35fliebel,(take 3 (for [x (repeatedly rand)] (prn x)))
11:35clojurebot(nil nil nil)
11:36stuartsierra,(take 3 (for [x (repeatedly rand)] x)
11:36clojurebotEOF while reading
11:36stuartsierra,(take 3 (for [x (repeatedly rand)] x))
11:36clojurebot(0.7727220105041916 0.9438459028734485 0.38389401142129465)
11:36arkhthat makes sense - thank you
11:38fliebelWould it be appropriate to use a markov chain to make a rock paper scissors game?
11:41thunkThat's a psychology question :)
11:42fliebelthunk…. you're probably right. But it's going to be in Clojure :D *cheap excuse*
11:43fliebelIt's going to be fun to make anyway, so I'll just do it. The other option is some more complex patter matcher.
11:45arkhit'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:47arkhwell ... assuming the state that follows is one that must win or tie. Nvm ... I don't know what I'm talking about. :)
11:47fliebelme neither
11:48fliebelarkh: the idea is that humans are not proper random number generators, and so are predictable
11:50fliebelarkh: 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:50fliebelI'm about to find out if it works
11:52arkhfliebel: 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:53fliebelarkh: I was just thinking about this game, but the experience might come in handy later on…
11:54fliebelarkh: Might be fun to predict other things thoug, but I don't think markov is the golden standard for predicting human.
11:58grcIs it possible to get hold of the body of a function from its symbol?
11:59grcI've got as far as getting the function object but don't know how it is structured
11:59chousergrc: sort of. see the 'source' macro or source-fn
11:59grcchouser: thanks I'll go and have a play
12:02chouserfn'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:06technomancyfns can store their source
12:06technomancywith special sauce
12:06technomancyhttp://github.com/Seajure/serializable-fn
12:07chouserthat doesn't handle closures, does it?
12:09stuartsierraNothing handles closures.
12:10stuartsierra"You wan't closure? You can't handle this closure."
12:10technomancychouser: depends on what you close over
12:10pheuterI'm having trouble running the jar file created with leiningen
12:11technomancyit's not smart enough to drop it silently if you close over something unseriablizable; it just freaks out
12:11pheuterFailed to load Main-Class
12:11fliebelWhat is the Clojure equivalent of a switch statement? Multimethod?
12:11stuartsierrafliebel: "case" in 1.23
12:11stuartsierra1.2
12:11technomancyor rather, something un-pr-str-able
12:12grcchouser: What I'm trying to do is ascertain whether or not a function is pure by checking it and its callees for impurity
12:12fliebeltechnomancy: What is un-pr-str-able?
12:12stuartsierragrc: I think that's called the Halting Problem
12:12technomancyfliebel: Java objects which pr-str is inable to print correctly
12:16grcstuartsierra: 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:16grcWhether or not teh function is *actually* called I can live with
12:16stuartsierra:pre/:post should never have side-effects
12:17stuartsierranever ever
12:18grcagreed, but that's enforced only by good behaviour
12:18slyrusthere go the debugging printlns in the :pre/:post methods
12:18_fogus_should never != cannot
12:18grcstuartsierra: 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:19stuartsierra_fogus_: true, but if they are, you're screwed anyway
12:19_fogus_stuartsierra: not unless you never violate your constraints. ;-)
12:19_fogus_or are you referring to a deeper psychological screwed?
12:20stuartsierraScrewed psychologically and metaphysically
12:22_fogus_you can add ethically to that list also
12:22arkhIf 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:22chouserponders being metaphysically screwed.
12:22chouser /me, that is.
12:23chouserarkh: no, lazy-seq just creates one step
12:23chouserdon't see how it'd be useful to call it on a string
12:23arkhchouser: oh, cool
12:23arkhit returns a different string each time
12:24arkhit's some networking stuff I want to hand to seque
12:24chouserprobably calling seq would be sufficient.
12:24arkhI need multiple threads, though, too ;)
12:25chouserstill don't see what lazy-seq buys you there
12:25chouserbut it's lunchtime, so I'm off...
12:25arkhdoh
12:26stuartsierraOK, pushed Ben's #93 patches to master.
12:26arkhseque 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:26stuartsierraThis removes namespaces deprecated in 1.2.0
12:26stuartsierraWe'll see if the Hudson build passes.
12:35stuartsierraWoohoo! Pass!
12:44cemerickThe joys and sorrows of a build jockey. :-D
12:45raekarkh: maybe you could do something like this: http://github.com/raek/stream-seq/blob/master/src/se/raek/stream_seq.clj#L30
12:45raekarkh: just replace take! with your java call
12:46raekonly as much of a lazy sequence you keep a reference to will be retained
12:48stuartsierraNow I just need to figure out how to deal with *releases* of individual modules.
12:49stuartsierraThat is, how to handle the case when module X wants to make a stable release while all other modules are on SNAPSHOT versions.
12:52stuartsierraNow pushing patches to inhibit AOT compilation except where necessary.
12:53cemerick....and build times everywhere else go up... :-)
12:53raekI should really complete the patch and tests for the c.c.json eof bug...
12:55stuartsierraraek: I fixed that, by the way, just haven't pushed to master yet
12:55raekI have a fix too, just some tests left
12:57stuartsierraDamn, build #188 failed because of clojure.contrib.logging
12:58raekstuartsierra: do you have it committed anywhere where I can look at it?
12:58stuartsierraraek: on Assembla
12:59raekoh. right.
13:02raeklooks good
13:28joshua-choiCan defrecord take a doc-string at all?
13:30spewnjoshua-choi: No. Something about metadata being lost on Java objects.
13:30joshua-choispewn: Unfortunate. Thanks for the answer.
13:36chouseryou can put doc strings on record instances
13:36chousernot sure that that's useful. :-P
13:37joshua-choiWell, doc-strings are usually in vars' metadata anyway, right?
13:37chouseryeah
13:38joshua-choiI guess that defrecord creates a Java class rather than a var...
13:38chouserdefrecord doesn't create a var, hense the problem
13:38chouserright
13:38joshua-choi..and that's why.
13:38joshua-choiIt's still unfortunate.
13:38chouserand for some reason Class doesn't implement clojure.lang.IMeta
13:38joshua-choiHa
13:39_fogus_(extend-type java.lang Class IMeta ...)
13:39_fogus_:p
13:40technomancy(extend-type java.util.regex.Pattern IFn) ;; <= if only =\
13:40chouser(extend-protocol PMeta Class ...)
13:41chouserbut there'd still be no storage for the metadata
13:41arkhraek: thanks, I'm looking at that now
13:42jneirahi people
13:42_fogus_(extend Fogus IAwesomeness {:haikeeba (fn [_] ...))
13:42chouserJust read http://dreamsongs.com/ObjectsHaveNotFailedNarr.html -- interesting to hear a Guy like Steele defend objects in the face of functional programming.
13:42jneira(defprotocol DontWorks (for [me]))
13:42jneira:-(
13:43jneirai suppose defprotocol in 1.2.0 works for everyone else ...
13:44jneira.(+ 1 2 3)
13:44jneirajum i have to enter in irc a little bit more
13:46jneira, (+ 1 2 3)
13:46clojurebot6
13:56luc4sHi. Why do I get NullPointerException when println something and then flush? Like when I try: ((println "any")(flush))
13:57chousertry (do (println "any") (flush))
13:57raekluc4s: if you want to "do" multiple things as one expression, you have to use "do"
13:57chouserluc4s: those outer parens mean Clojure will try to use the return value of (println "any") as a function
13:57chouserbut (println "any") returns nil, and calling nil as a function is a NullPointerException
13:58luc4soh, I understand. I thought they where like ; and enter hehe
13:58kumarshantanuis a CCW user around? need to pointer on namespaces with dash character
13:58luc4s:chouser :raek Thanks!
13:59raekjneira: what error do you get?
13:59kumarshantanus/to/some/
13:59sexpbot<kumarshantanu> is a CCW user around? need some pointer on namespaces with dash character
13:59raekin clojure in general, dashes in namespace names corresponds to hyphens in file names
14:00kumarshantanuraek: did you mean underscore in file names?
14:00raekeh. yes.
14:01jneirajum my silly fault, better i dont say nothing :-/
14:02jneirathanks raek
14:02raekkumarshantanu: but since you knew that, I guess that wasn't the problem anyway ;-)
14:02kumarshantanuraek: thanks, it's working in CCW now
14:03kumarshantanuraek: is it idiomatic in Clojure to create namespaces with a dash? I have noticed some libs that use
14:04raekdashes to separate words is the ideomatic way (except for generated class names, protocols, records and types)
14:05raekit is what clojure.core uses, anyway...
14:06arkhI finally half understand lazy-seq
14:07arkhsomeday I'll bother to learn macro syntax and then I'll understand the other half
14:11mcavI 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:13fliebelWhat 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:13mcavfliebel: assoc-in?
14:14dnolen_,(update-in {:foo {:bar 0}} [:foo :bar] inc)
14:14clojurebot{:foo {:bar 1}}
14:14fliebeldnolen: That looks more like it :)
14:15chouser,(update-in nil [:foo :bar] nil?)
14:15clojurebot{:foo {:bar true}}
14:16technomancymcav: you can set :warn-on-reflection true in project.clj so it will just work at dev-time if you're using leiningen
14:17mcavyeah, i'm using lein and turned that on afterward
14:18raekarkh: have you tried this: http://gist.github.com/480608
14:18raekit can be quite useful when learning when lazy sequences are realized
14:19raekarkh: I'm awesome? thank!
14:20ssiderisraek: again, very good example
14:20arkhraek: 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:28chouser(is (= {} (#'garner-unifiers ...))) should work
14:28chouser@#'foo for non-function values
14:28mrBlissHow do I hint something of the following type:
14:29mrBliss,(class (.getParameterTypes (first (.getDeclaredConstructors Integer))))
14:29clojurebot[Ljava.lang.Class;
14:29mrBlissadding ^"[Ljava.lang.Class" in front of it didn't work
14:29chousermrBliss: keep the ;
14:29mrBlissgives a ClassNotFoundException [Ljava/lang/Class..
14:30mrBlissI'll tryit
14:31mrBlissI think it works (not so clear because of other warnings in the same method)
14:31mrBlissthanks
14:32raekthe "L" and "[...;" notation of the JVM is not very aestethic...
14:33raek*"L...;" and "["
14:33chouserno
14:35_fogus_chouser: no go
14:36_fogus_oh wait, it needs ns qualification
14:36chousersorry, try fully-qualifiying the ... yeah
14:36chousercgrand'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:37fliebelyay, 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:38chouser_fogus_: I grepped for @#'
14:38chouserI knew the answer -- was just looking for the date/time
14:46mrBlissIs it possible that type hints are lost in with-open?
14:51chouser,(binding [*print-meta* true] (prn (macroexpand '(with-open [f1 ^File f2]))))
14:51clojurebot(let* [f1 ^File f2] (try (clojure.core/with-open []) (finally (. f1 clojure.core/close))))
14:51chouserlooks ok there
15:00mrBlissthanks chouser
15:01mrBlissfound my problem, I had a File in with-open, but File hasn't got a .close method
15:01chouserah
15:01chouserand my use of ^File didn't exactly help in that regard. :-P sorry
15:17@rhickeyclojure-conj registration is now open! http://groups.google.com/group/clojure/browse_frm/thread/210ac9303d7ccec1
15:17chouserwoo!
15:19wwmorgandamn. My sister's wedding is that weekend
15:20wwmorganShe's going to be so disappointed ;-)
15:21chouserheh
15:21danlarkinI love fogus' picture
15:22cemerickVery exciting.
15:22cemerickGreat price point, hope there's a big venue :-)
15:23mrBlissare the talks gonna be filmed and put online?
15:26lancepantzthey should be
15:28raekis rhickey's talk on pods from emerging langs available somewhere, btw?
15:29cemerickrhickey: might want to get someone to redirect http://first.clojure-conj.org/ to the main site
15:29woobycemerick: working on it
15:42mabes,(str #"foo\.bar")
15:42clojurebot"foo\\.bar"
15:42mabesIs there a way I can get "foo\.bar"? So, the non-escaped version?
15:43chouserthat is unescaped. the string only has one backslash, it's just that when printed it needs to show you two.
15:45mabeschouser: 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:46mabeschouser: and when I send back the str version the response has the two slashes in it.. what am I missing?
15:46chouserI'm not sure.
15:46chouser,(println #"foo\.bar")
15:46clojurebot#"foo\.bar"
15:46chouser,(println (.pattern #"foo\.bar"))
15:46clojurebotfoo\.bar
15:47mabes,(prn-str #"foo\.bar")
15:47clojurebot"#\"foo\\.bar\"\n"
15:47chouser,(count (str #"foo\.bar"))
15:47clojurebot8
15:50pdk,(* 6 1024)
15:50clojurebot6144
15:50pdkshow of hands
15:50pdkhow much swap space would you give to a system youre setting up with 4gb ram
15:51pdk,(* 8 1024)
15:51clojurebot8192
15:52pdk,(* 30 1024)
15:52clojurebot30720
15:52pdk,(* 35 1024)
15:52clojurebot35840
15:53ssiderisi know it's not a plausible situation, but how would you write this more elegantly?
15:53ssideris,(update-in {} [:a :b :c] #(do '(%) 4))
15:53clojurebot{:a {:b {:c 4}}}
15:55wwmorgan,(assoc-in {} [:a :b :c] 4) ; ssideris: like this?
15:55clojurebot{:a {:b {:c 4}}}
15:56ssiderishaha ok, I think I took the fact that you needed a function at face value
15:56ssideristhanks
15:57Chousukessideris: out of curiosity, why did you put the '(%) in the function?
15:57Chousukejust #(do 4) would've been enough.
15:57wwmorganChousuke: My guess it to make it unary?
15:58Chousukeah. right.
15:58Chousukeof course.
15:58wwmorganpretty creative, actually
15:58ssiderisChousuke: yeah it is called with one argument
15:58Chousuke(constantly 4), then :)
15:58ssideriswwmorgan: the awkward creativity of a newbie
15:59ChousukeIn cases like that I'd just use fn directly and not the shortcut form
15:59stuartsierraClojure-Conj!
15:59Chousukeso you can write (fn [_] ...)
15:59ssiderisis _ the convention for unused arguments?
15:59Chousukeyeah
16:00ssiderisok
16:00Chousukethough you can name the arguments too if you want to.
16:00stuartsierraClojure-Conj! Clojure-Conj!
16:00ssiderisclojure-conj would be nice, but it's a bit too far for me :-)
16:00Chousuke_ is just often used if neither the name or the argument matter.
16:01stuartsierrahttp://clojure-conj.org/
16:01kumarshantanuChousuke: In my case _ led to non-evaluation of an expression
16:02Chousukekumarshantanu: hm? how did that happen?
16:02kumarshantanu(defonce _ (nomnomnom)) ;; doesn't evaluate
16:03Chousukekumarshantanu: Hm, I see no reason why that shouldn't evaluate but it's not a good idea anyway
16:04wwmorgankumarshantanu: I think that's the defonce, and not the _. I got similar behavior until I remembered to ns-map '_ from *ns*
16:04kumarshantanuChousuke: I needed a defonce to do interactive web development using Eclipse/CCW and Ring/Compojure
16:04Chousuke_ is a valid symbol in clojure so technically you can define a var called _ if you want to.
16:04kumarshantanuChousuke: defonce was supposed to start Jetty inside a future
16:05Chousukebut that's not a good idea because _ is used as the "not-used" name by pretty much everything :P
16:05kumarshantanuChousuke: strangely, Jetty doesn't start when I put a _, but does when I put any other name
16:06kumarshantanuChousuke: I was trying _ because I didn't need to refer the value of future
16:07ChousukeI see.
16:07ChousukeI have no idea why jetty would break because of something like that though.
16:08kumarshantanuChousuke: maybe it's not jetty....perhaps CCW or Clojure's reload-feature, I am not sure
16:08kumarshantanus/reload/load-reload/
16:08sexpbot<kumarshantanu> Chousuke: maybe it's not jetty....perhaps CCW or Clojure's load-reload-feature, I am not sure
16:26arohneris there a java compiler library somewhere that could be used from a clojure repl?
16:26arohnerI really want slime to be able to eval Java classes
16:27kumarshantanuarohner: ASM or CGLIB?
16:27arohnerkumarshantanu: I don't understand
16:28stuartsierraarohner: there are Java "interpreters"
16:28kumarshantanuarohner: ASM -- http://asm.ow2.org/ and CGLIB -- http://cglib.sourceforge.net/
16:28arohnerkumarshantanu: thanks
16:28arohnerso javac doesn't have a Java API?
16:29arohnerooh, http://download.oracle.com/javase/6/docs/api/javax/tools/JavaCompiler.html
16:29kumarshantanuarohner: I think you can use the Groovy's eval which can accept Java code mostly as it is
16:40lancepantzarohner: there is an ant task for javac, which does have a java api
16:58fliebelDoes anyone want to try and beat my Clojure Markov Rock Paper Scissors bot?
16:59fliebelhttp://gist.github.com/564552
17:04dysingerfliebel: my draw is (chuck-norris) your bot just lost
17:05fliebeldysinger: What do you mean by the whole part before the last paren?
17:07fliebelPsygology is complicated...
17:09fliebelI'm going to switch to a better system tomorrow *yawn*
17:11fliebeldysinger: 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:32replacaIs there a way to make a java List<String> from clojure? (So I can pass it to ProcessBuilder.)
17:33kumarshantanureplaca: pass this -- '("string1" "string2" "string3")
17:34replacadirectly to ProcessBuilder?
17:34kumarshantanureplaca: java's generics have type erasure, so at runtime it's just List, not List<String>
17:34kumarshantanureplaca: yes
17:34replacaahh, thx, I'll give it a try
17:37raek,(map #(instance? java.util.List %) [(list 1 2 3) [1 2 3]])
17:37clojurebot(true true)
17:41replacakumarshantanu: works like a charm! thanks
17:42kumarshantanureplaca: clojure is a better language to write Java code too :-)
17:44replacakumarshantanu: 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:45replaca*is => in
17:46kumarshantanureplaca: cool, what libraries are you using? just curious
18:10mvidim 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:11lancepantzmvid: just lein repl
18:11mvidthen what?
18:11mvidthat doesn't run jetty
18:12raekmvid: I think you need to update leiningen
18:12arbschtrequire your ns
18:12raekthe script argument was added pretty recently
18:12raeklein repl
18:12raek(require 'project.core)
18:13mvidim using lein v 1.3
18:14mvidis that too old?
18:14mvidraek that worked
18:15arbscht1.3 is fine. I don't think lein supports that argument anymore, if it ever did
18:15mvidcool
18:15mvidthanks
18:15technomancyit never supported arguments on purpose; it just accepted them because it used to be based on clojure.main.
18:16technomancybut if you set an ns as your :main in project.clj it will requrie and in-ns it
18:20Rayneschouser: 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:23chouseryourkit does a somewhat better job of making the data make sense, but it's still a bit befuddling to me
18:28replacakumarshantanu: sorry, I wandered off
18:29kumarshantanureplaca: np
18:29replacakumarshantanu: for bugzilla I'm using the apache xmlrpc lib and for perforce I'm just grinding on shell output
18:30kumarshantanureplaca: what's for the web handling? ring/compojure/enlive? or something else?
18:30replacaon 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:30kumarshantanuokay
18:31replacaClojure really shines in this "gluing a whole bunch of stuff together" area
18:31technomancyyou could use coldfusion
18:31technomancyit's an option these days
18:32replacatechnomancy: are you being sarcastic? That's not allowed on this list
18:32technomancysorry, I forgot my unicode irony mark
18:32replaca:)
18:32technomancy
18:33replacaYeah, 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:35mviddoes anyone have a favorite compojure authentication library?
18:37tomojis there more than one choice?
18:37mvidis there any choice?
18:41tomojcould've sworn I saw something on planet clojure recently
18:41lancepantzi think it was the guy that does sandbar talking about it
18:41lancepantzbrenton somebody
18:42tomojaha http://github.com/brentonashworth/sandbar
18:42tomojyeah
18:42tomojmvid: don't take that as a recommendation
18:43lancepantzhttp://formpluslogic.blogspot.com/2010/08/securing-clojure-web-applications-with.html
18:46tomojhurray fnparse activity
20:08DanielGlauserLet'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:12kumarshantanuhi, 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:12LicenserDanielGlauser: you can't change values in the map, they are imutable that is the whole point
20:13kumarshantanu(GET "/foo/:id" {params :params} [id] (whatever...))
20:14Licenserkumarshantanu: sorry I don't know compojure
20:15DanielGlauserLicenser: 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:16technomancyDanielGlauser: you want to call alter with assoc
20:17Licenseryes so it won't mutate the map in the end it's still a new map
20:17Licenser(unless it are transients but I think that goes too far)
20:18DanielGlausertechnomancy: 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:18technomancywell... you're still not mutating a data structure
20:18DanielGlauserLicenser: 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:19Licenserah okay then I missunderstood you sorry :)
20:20DanielGlausertechnomancy: Yeah, I get that part, thanks! Wrote code to iterate through the map and figured there was a better way. Thanks guys.
20:21Licenserwow I really wasn't helpful o.O sorry DanielGlauser :)
20:26jneirai think if i continue twetting translations from raw to monadic computations my popularity is going to go down...
21:44zztr,(deftype Mytype [a b] Object (toString [this] (str a b)))
21:44clojurebotsandbox.Mytype
21:44zztr,(def mt (Mytype :y :z))
21:44clojurebotDENIED
21:45zztr,(Mytype :y :z)
21:45clojurebotjava.lang.Exception: Expecting var, but Mytype is mapped to class sandbox.Mytype
21:45zztrI can't find an example of how to do this correctly
21:49zztr,(Mytype. :y :z)
21:49clojurebot#<Mytype :y:z>
21:50zztrsigh
22:29dnolenzztr: http://github.com/ztellman/cantor/blob/master/src/cantor/vector.clj#L358
23:02qbgFinally found a use for promise/deliver
23:02qbgI use it once in my parallel mapreduce function