2010-09-03
| 00:27 | Bahman | Hi all! |
| 01:05 | blais | Q: Is is possible to redefine the dispatch-fn of a multimethod in a running environment? |
| 01:05 | blais | i.e., I use Emacs, I eval gradually. I want to change the dispatch function of a multimethod. Doesn't seem to work. |
| 01:05 | blais | Any idea? |
| 01:06 | kumarshantanu | hi, can anybody point me to a code sample that uses flash messages in ring/compojure? |
| 01:08 | wwmorgan | blais: the defmethod behavior was changed with 1.2. It now has defonce semantics |
| 01:08 | wwmorgan | *defmulti |
| 01: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. |
| 01:09 | Raynes | (doc ns-unmap) |
| 01:09 | clojurebot | "([ns sym]); Removes the mappings for the symbol from the namespace." |
| 01:09 | wwmorgan | apparently, (def foo nil) will also work |
| 01:09 | Raynes | Or that. |
| 01:10 | scottj | kumarshantanu: I don't think there are any. |
| 01:11 | kumarshantanu | scottj: I am looking to use flash messages (now added in ring), but not sure what's the syntax etc |
| 01:11 | kumarshantanu | scottj: so any doc link may also be useful |
| 01: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. |
| 01:30 | blais | Raynes: thx man. |
| 01:31 | blais | wwmorgan: thx. |
| 01:33 | kumarshantanu | scottj: thanks, I am experimenting with the flash middleware |
| 01:37 | scottj | kumarshantanu: if you come up with a simple example please post it |
| 01:37 | kumarshantanu | scottj: sure |
| 02:04 | luc4s | Hi. I'm learning Clojure and have a little problem. |
| 02:04 | luc4s | How can I transform this: ("1" "2" "3") ("a" "b" "c") into this: (["1" "a"] ["2" "b"] ["3" "c"]) |
| 02:05 | wwmorgan | ,(map vector '("1" "2" "3") '("a" "b" "c")) |
| 02:05 | clojurebot | (["1" "a"] ["2" "b"] ["3" "c"]) |
| 02:06 | luc4s | :wwmorgan thanks a lot. I was like a couple of hours struggling with that and interleave and etc. |
| 02:08 | wwmorgan | ,(partition 2 (interleave '("1" "2" "3") '("a" "b" "c"))) ;-) is another way to do it, if you don't need vectors |
| 02:08 | clojurebot | (("1" "a") ("2" "b") ("3" "c")) |
| 02:09 | luc4s | oh, no. I need the vectors for a func I made already hehe |
| 02:10 | luc4s | thanks again. Clojure is a fantastic language, but a little hard for a imperative c++ programmer like myself |
| 02:37 | kumarshantanu | scottj: got the flash thing working, but it's a bit involved |
| 03:19 | LauJensen | Is there a cake option for adding arbitrary options to the jvm at compile time? |
| 03:20 | LauJensen | .cake/config => project.java_opts = ... |
| 03:20 | scottj | kumarshantanu: sweet, have a basic example you can gist or something? |
| 03:21 | noidi | LauJensen, did that work? |
| 03:21 | LauJensen | testing now |
| 03:21 | kumarshantanu | scottj: I will...I am re-factoring few things -- will post a gist |
| 03: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? |
| 03:21 | LauJensen | yes it did noidi |
| 03:21 | scottj | kumarshantanu: cool |
| 03: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 |
| 03:22 | noidi | Cake looks interesting, I should really give it a try some day |
| 03:23 | LauJensen | agreed :) |
| 03:23 | octe | how do i require multiple things in an ns-declaration? i tried this: http://pastebin.com/xKqwACtC but it's not correct.. |
| 03: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 |
| 03:24 | bartj | I think it is not possible to import all the classes in a package like in Java, is this correct ? |
| 03: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 |
| 03:24 | bartj | for eg: import org.apache.http.* would translate to: |
| 03:25 | bartj | (:import org.apache.http *) ? |
| 03:26 | LauJensen | correct, its not possible |
| 03:39 | kumarshantanu | scottj: I created a gist -- http://gist.github.com/563552 |
| 03:40 | scottj | kumarshantanu: cool, you don't need var and future on run-jetty |
| 03:40 | scottj | oh nevermind forget that |
| 03:42 | kumarshantanu | scottj: i copy-pasted from my Eclipse IDE -- I use future and defonce for interactive web development |
| 03:43 | scottj | I was confusing var/future for :join? false/future |
| 04:02 | LauJensen | Has anyone here had trouble compiling a project which imports JFreeChart ? |
| 04: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? |
| 04:12 | kumarshantanu | springify: you might as well raise a ticket on Leiningen -- asking to push to Clojars |
| 04:14 | springify | kumarshantanu: True, just wanted to know whether I missed something. |
| 04:17 | springify | Done: http://github.com/technomancy/leiningen/issues#issue/106 |
| 04:18 | kumarshantanu | springify: just noticed the issue - it says "Release leiningen 1.5" |
| 04:18 | springify | Heh, no, just edited. Hit the return key accidentally. |
| 04:18 | kumarshantanu | springify: the next planned release is 1.3.1 as far I know |
| 04: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. |
| 04:21 | kumarshantanu | springify: Lein on Clojars may be useful for writing plugins I guess -- is that the purpose if I may ask? |
| 04:23 | springify | kumarshantanu: I'm maintaining a branch of lein-cuke, (cuke4duke with leiningen), which depends on leiningen, yes. |
| 04:27 | kumarshantanu | springify: this is cool (googled them), thanks for sharing the details |
| 04:30 | springify | kumarshantanu: You're welcome. I can only claim credits for providing the project.clj and a single fix, tho :) |
| 04:31 | kumarshantanu | **time for lunch...ciao |
| 04: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)) |
| 04:32 | yayitswei | ;; => (3 4) |
| 04:33 | LauJensen | filter comes to mind |
| 04:33 | Raynes | -> (filter #(> % 2) '(1 2 3 4)) |
| 04:33 | sexpbot | => (3 4) |
| 04:33 | yayitswei | ah, that's exactly what i was looking for |
| 04:34 | LauJensen | -> (remove #(< % 2) '(1 2 3 4)) |
| 04:34 | sexpbot | => (2 3 4) |
| 04:34 | yayitswei | or remove too.. thanks guys |
| 04:34 | LauJensen | np |
| 04:35 | ordnungswidrig | LauJensen: I will not higlight you, as cuke was mostly a drop-in. :-) |
| 04:35 | LauJensen | cuke-de-duke? :) |
| 04:36 | ordnungswidrig | cuke-de-cake, actually :) |
| 04: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 |
| 04:36 | ordnungswidrig | LauJensen: I noticed that too. |
| 04:36 | LauJensen | You've been checking my referrers? |
| 04: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 :) |
| 04:38 | LauJensen | thats an awesome feat, especially considering I dont have a webmail :) |
| 04:38 | ordnungswidrig | *doh* |
| 04:42 | esj | <greetings>All<Special Greeting>LauJensen</Special Greeting></greetings> |
| 04:42 | esj | :P |
| 04:42 | LauJensen | Greetings and salutations esj! :) Whats the the XML, you started greeting people in Maven? :) |
| 04:43 | esj | correct in one :) |
| 04:43 | esj | of course, in future, I just need to go $mvn greet |
| 04:43 | esj | and I'm done :) |
| 04:44 | LauJensen | Well - Its not a real Maven vs Sane Tools smackdown before we have a blogpost :) I'll cook something up |
| 04:45 | esj | lol |
| 04:49 | LauJensen | I cant decide "Wasting your life like a pro - Maven" or "Wasting your customers money - Maven", which is better? |
| 04:49 | LauJensen | I mean, they're both terrible accurate... |
| 04:53 | bobo_ | i think the first one |
| 04:53 | bobo_ | not everyone has customers |
| 04:53 | bobo_ | and sometimes, its the customers choice |
| 04:58 | LauJensen | Exactly what I thought :) |
| 04:59 | LauJensen | 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" |
| 04:59 | LauJensen | ok enough, we have to stop before cemerick wakes up :) |
| 05:00 | bobo_ | well, i have an ant build for the project i am working on now... maybe i shouldnt yell at maven |
| 05:01 | esj | Its the best thing I've used, super potent and easy, but as discussed, I haven't checked out cake yet. |
| 05:01 | lancepantz_ | member:LauJensen: justin mentioned that you were thinking about writing a post on cake? |
| 05:02 | esj | and if I can goad Lau into doing my research for me, so much the better ;P |
| 05:02 | LauJensen | lancepantz_: Thats right |
| 05:02 | lancepantz_ | awesome |
| 05:02 | lancepantz_ | i'm working on the task system ATM |
| 05:03 | LauJensen | awesome begets awesome, now the pressures on me to write a good post :) |
| 05:03 | lancepantz_ | we whiteboarded some really cool stuff today, i |
| 05:03 | lancepantz_ | 'm excited ot get it in |
| 05:03 | LauJensen | details details! :) |
| 05:04 | lancepantz_ | adding a deffile macro that's similar to deftask |
| 05:04 | lancepantz_ | *defile |
| 05:04 | LauJensen | deffile is very differnt from defile |
| 05:04 | lancepantz_ | takes in a string thats the name of the file you want build |
| 05:04 | bartj | er, how would one go about translating this Java stmt to Clojure ? |
| 05:04 | lancepantz_ | hehe, i like defile :) |
| 05:04 | bartj | org.apache.http.client.HttpClient client = new DefaultHttpClient(); |
| 05:04 | LauJensen | lancepantz_: I dont, keep it clean |
| 05:04 | esj | lol |
| 05:04 | LauJensen | (let [client (DefaultHttpClient.)] |
| 05:05 | bartj | LauJensen, no that doesn't work - I tried that |
| 05:05 | lancepantz_ | in the spirit of defn instead of deffn then :) |
| 05:05 | LauJensen | bartj: thats the translation though, so something else is wrong |
| 05:05 | LauJensen | (let [client ^org.apache.http.client.HttpClient (DefaultHttpClient.)] ... ? |
| 05:06 | lancepantz_ | the defile dependences are a set of files that are the source files for the file being generated |
| 05:06 | lancepantz_ | and the macro compares the timestamps to see if it need to be ran |
| 05:06 | lancepantz_ | so something like |
| 05:07 | lancepantz_ | (defile "pom.xml" #{"project.clj"} (prxml [pomstuff])) |
| 05:08 | lancepantz_ | 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:08 | lancepantz_ | it's going to clean the code up quite a bit |
| 05:08 | LauJensen | nice |
| 05:09 | lancepantz_ | (defile "lib/*.class" #{src/**/*.clj} (compile blah blah..)) |
| 05:10 | lancepantz_ | (defile "lib/*.class" #{"src/**/*.clj"} (compile blah blah..)) actually |
| 05:10 | LauJensen | So this goes into the optimization category |
| 05:10 | LauJensen | Im excited to see how much mileage you'll get out of Ivy |
| 05:11 | lancepantz_ | yeah, i think we're vectoring in on the feature set we want for 1.0 |
| 05:11 | lancepantz_ | me too, ivy looks great |
| 05: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? |
| 05:11 | lancepantz_ | there was a guy working on a patch for it, but i think he's gotten busy |
| 05:11 | LauJensen | Just make sure you weed out the bugs before 1.0 comes - I'm posting one today, if I didn't already |
| 05:12 | Raynes | lancepantz_: I found a bugzors. |
| 05:12 | lancepantz_ | ordnungswidrig: you mean build things other than files? |
| 05:13 | ordnungswidrig | lancepantz_: yes |
| 05:13 | lancepantz_ | example? |
| 05:13 | clojurebot | examples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples |
| 05:13 | lancepantz_ | Raynes: is it with the jvm restarting? |
| 05:13 | Raynes | lancepantz_: Nosir. |
| 05:13 | lancepantz_ | sup? |
| 05:13 | ordnungswidrig | simple example: data into database |
| 05:13 | Raynes | lancepantz_: 'open' times out way, way too quickly in the download function. |
| 05:14 | Raynes | lancepantz: On a slow connection, there is absolutely no chance of it completing. |
| 05:14 | Raynes | Oh a really, *really* slow connection, anyway. |
| 05:14 | Raynes | ;) |
| 05:14 | lancepantz_ | ordnungswidrig: ahh, well yeah, anything you can do in clojure you can do in a cake function |
| 05: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. |
| 05: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 :) |
| 05:15 | lancepantz_ | Raynes: ah, i believe it, get up with ninjudd tomorrow, he's been working on all that stuff |
| 05: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. |
| 05:15 | ordnungswidrig | LauJensen: in cake? |
| 05:15 | LauJensen | ordnungswidrig: Yes |
| 05:15 | Raynes | lancepantz_: Will do. Just waiting on him. :D |
| 05:15 | LauJensen | Raynes: Just post an issue on Github, these guys work FAST :) |
| 05:15 | ordnungswidrig | LauJensen: would this be possible in leiningen? |
| 05: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. |
| 05:16 | LauJensen | ordnungswidrig: Yea I think so, but not as elegantly - I've overriden the compile task |
| 05:16 | LauJensen | or, extended it actually |
| 05:16 | lancepantz_ | ordnungswidrig: yeah, you are describing dependency based programming, which was our whole goal for the project |
| 05:16 | lancepantz_ | all the other stuff was just afterthoughts :) |
| 05: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. |
| 05:18 | lancepantz_ | right, exactly |
| 05:19 | adben | morning * |
| 05: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 |
| 05:21 | yayitswei | another question for you guys.. why doesn't -> work with anonymous functions? for example, (-> 1 #(+ % 2 3)) |
| 05:21 | yayitswei | i would expect => 6 |
| 05:23 | lancepantz_ | ,(-> 1 (partial + 2 3)) |
| 05:23 | clojurebot | #<core$partial$fn__3678 clojure.core$partial$fn__3678@60bb22> |
| 05:25 | lancepantz_ | yayitswei: i would expect that as well |
| 05:25 | tomoj | ,(read-string "#(+ % 2 3)") |
| 05:25 | clojurebot | (fn* [p1__4395#] (+ p1__4395# 2 3)) |
| 05:26 | tomoj | ,(macroexpand-1 '(-> 1 #(+ % 2 3))) |
| 05:26 | clojurebot | (fn* 1 [p1__4396#] (+ p1__4396# 2 3)) |
| 05:27 | yayitswei | hmm. or a better question: what's the idomatic way to rewrite that? |
| 05:28 | yayitswei | let's say, (-> 1 #(+ % 2 3) println) |
| 05:28 | tomoj | (println (+ 1 2 3)) ? |
| 05:28 | noidi | yayitswei, you'll have to write it as (#(...)) |
| 05:28 | yayitswei | ,(println (#(+ % 2 3) 1)) |
| 05:28 | clojurebot | 6 |
| 05:29 | Raynes | ->(-> 1 (#(+ % 2 3))) |
| 05:29 | sexpbot | => 6 |
| 05:29 | yayitswei | ooh |
| 05:30 | yayitswei | (-> (-> 1 #(+ % 2 3) ) println) |
| 05:30 | yayitswei | ,(-> (-> 1 #(+ % 2 3) ) println) |
| 05:30 | clojurebot | java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.ISeq |
| 05:30 | noidi | ,(macroexpand '#(println %)) |
| 05:30 | clojurebot | (fn* [p1__4407#] (println p1__4407#)) |
| 05:31 | noidi | so the #() expands to the list above |
| 05:31 | noidi | and -> will stick the result of the previous expression as the second item in that list |
| 05:31 | noidi | ,(macroexpand '(-> 123 #(println %))) |
| 05:31 | clojurebot | (fn* 123 [p1__4410#] (println p1__4410#)) |
| 05:31 | noidi | which does not make any sense |
| 05:31 | noidi | so you'll get an error |
| 05:32 | noidi | ,(macroexpand '(-> 123 (#(println %)))) |
| 05:32 | clojurebot | ((fn* [p1__4413#] (println p1__4413#)) 123) |
| 05:32 | noidi | but that works, because the first item in the list is a function, and the second is its argument |
| 05:33 | yayitswei | what does fn* mean? |
| 05:35 | Raynes | (doc fn*) |
| 05:35 | clojurebot | Gabh mo leithscéal? |
| 05:35 | yayitswei | ohhh but i get your meaning |
| 05:35 | yayitswei | so i should write it as ,(-> 1 (+ 2 3) println) |
| 05:35 | yayitswei | ,(-> 1 (+ 2 3) println) |
| 05:35 | clojurebot | 6 |
| 05:37 | LauJensen | ,(-> 1 (+ 2 3)) |
| 05:37 | clojurebot | 6 |
| 05:37 | LauJensen | Isnt that good enough? :) |
| 05:38 | LauJensen | Oh I see I missed a larger discussion :| |
| 05:39 | noidi | I don't really understand the opposition to adding a variant of -> that places the threaded value at a marked position |
| 05:39 | LauJensen | noidi: -> ->> is all you need IMO |
| 05:39 | yayitswei | yep! thanks guys. I didn't fully understand what -> did |
| 05:39 | LauJensen | yayitswei: You got it now? |
| 05:39 | yayitswei | yeah |
| 05:40 | yayitswei | funny because you can't google -> |
| 05:40 | noidi | ,(doc ->) |
| 05: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." |
| 05:40 | yayitswei | ahh |
| 05:40 | LauJensen | yayitswei: Yea, thats how we get so many members in #clojure |
| 05:40 | noidi | yayitswei, when you are not sure what a macro does, macroexpand and macroexpand-1 are your friends |
| 05:41 | tomoj | noidi: "rich said no" isn't enough for you? :P |
| 05:41 | yayitswei | haha cool, will try that next time |
| 05:42 | noidi | tomoj, heh, well, that's a good reason I guess :) |
| 05:43 | ordnungswidrig | not be able to google for "->" and so on is a problem for haskell and scala, too. |
| 05:43 | ordnungswidrig | but the haskell guys have solved the problem |
| 05:44 | yayitswei | ordnungswidrig: how did they solve it? |
| 05:47 | ordnungswidrig | yayitswei: they have hoogle and hayoo |
| 05:47 | ordnungswidrig | 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. |
| 05:47 | ordnungswidrig | |
| 05:47 | ordnungswidrig | |
| 05:48 | yayitswei | member:ordnungswidrig: nice, looking at it now |
| 05:48 | noidi | ,(find-doc "Thread") |
| 05: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. |
| 05:49 | yayitswei | we have our trusty clojurebot |
| 05: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 |
| 05:51 | LauJensen | I keep getting referers from here https://secure.wikimedia.org/wikipedia/en/wiki/Main_Page , can anybody work out why? |
| 05:52 | ordnungswidrig | LauJensen: maybe real path is cut because it is a secured connection? |
| 05:52 | LauJensen | maybe |
| 05:53 | ordnungswidrig | Or somebody playing a joke on your logfile? |
| 05:53 | LauJensen | Not possible |
| 05:53 | LauJensen | Unless you mean, by way of referrer spam |
| 05: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? |
| 06:01 | Raynes | ordnungswidrig: Once clojuredocs has an API, we'll have that as well. |
| 06:01 | Raynes | I mean, we have it now, but once we have an API, it can be integrated with the bots. |
| 06:03 | LauJensen | ordnungswidrig: Yes, thats referrer spam |
| 06:03 | LauJensen | (ps: if you dont highlight me, chances are I wont look) |
| 06:05 | ordnungswidrig | LauJensen: ok, I think some day, we can manage on a proper mutual highlighting policy :) |
| 06:09 | ordnungswidrig | can I search for a ns where a symbol / function is defined? |
| 06:25 | LauJensen | M-. fn |
| 06:25 | LauJensen | @ ordnungswidrig |
| 08:14 | arnorhs | whazzup |
| 08:14 | arnorhs | Are there any stable zero mq bindings for clojure? You just use the java ones right? |
| 08:14 | arnorhs | Do you think they can be set up using lein ? |
| 08:16 | dnolen | arrnorhs: yeah use the zeromq java bindings. you'll probably want to use native-deps for that. |
| 08:19 | mrBliss | is there a reason for the absence of (copy ^URL *) in the io libraries? |
| 08:19 | stuartsierra | mrBliss: nobody wrote it |
| 08:20 | mrBliss | I have written the 3 needed methods if you want them (thanks goes to LauJensen) |
| 08:20 | stuartsierra | cool, post to the mailing list and we'll take a look |
| 08:20 | mrBliss | alright |
| 08:21 | mrBliss | clojure or clojure-dev? |
| 08:22 | stuartsierra | mrBliss: clojure |
| 08: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 |
| 08:33 | stuartsierra | clojure.contrib.io is slated for removal anyway |
| 08:35 | mrBliss | copy's also deprecated I see, so should I continue? |
| 08:35 | stuartsierra | all that has moved to clojure.java.io |
| 08:35 | stuartsierra | Further development will continue there. |
| 08:35 | mrBliss | ok I see |
| 08:37 | mrBliss | 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 |
| 08:38 | stuartsierra | yes, although it doesn't actually matter |
| 08:42 | Licenser | greetings my lispy friendsw |
| 08:42 | Licenser | 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 |
| 08:51 | kumarshantanu | can anybody help me understand how to express (if cond step1 else-step-2-and-step3) |
| 08:51 | mrBliss | (if cond step1 (do step2 step3)) |
| 08:51 | kumarshantanu | step2 and step3 are independent |
| 08:51 | kumarshantanu | mrBliss: will (do ...) return the value that step3 returns? |
| 08:51 | mrBliss | correct |
| 09:06 | mrBliss | stuartsierra: post sent |
| 09:28 | bartj | , (doc do) |
| 09:28 | clojurebot | It's greek to me. |
| 09:29 | bartj | the error - " Unable to resolve classname" occurs because the class was not imported ? |
| 09:30 | chouser | probably |
| 09:30 | bartj | chouser, what could be the other reasons ? |
| 09:32 | bartj | if I have the following line in Java: org.apache.http.client.HttpClient client = new DefaultHttpClient(); |
| 09:33 | bartj | the DefaultHttpClient is present in org.apache.http.client |
| 09:33 | bartj | I am sorry, DefaultHttpClient is present in org.apache.http.impl.client |
| 09:34 | bartj | and HttpClient is present in org.apache.http.client |
| 09:34 | bartj | so, while importing the java classes, I have something like: |
| 09:34 | bartj | (:import [org.apache.http.client.HttpClient] [org.apache.http.impl.client.DefaultHttpClient]) |
| 09:35 | bartj | still, I get a Unable to resolve classname error |
| 09:35 | bartj | can someone please point what I am doing wrong ? |
| 09:35 | mrBliss | try (:import [org.apache.http.client. HttpClient] |
| 09:35 | mrBliss | [org.apache.http.impl.client DefaultHttpClient]) |
| 09:35 | mrBliss | note the spaces |
| 09:35 | mrBliss | (remove that trailing dot from client.) |
| 09:36 | raek | does that work with the vectors? |
| 09:36 | mrBliss | yes |
| 09:36 | mrBliss | [package.subpackage Class] |
| 09:36 | stuartsierra | vectors should be lists there |
| 09:36 | raek | parantheses are the most commonly used for prefix lists |
| 09:36 | bartj | LauJensen, told me that they were one and the same! |
| 09:36 | stuartsierra | That's an implementation detail. |
| 09:36 | stuartsierra | It just happens to work. |
| 09:37 | raek | (ns foo.bar (:import org.apache.http.client.HttpClient org.apache.http.impl.client.DefaultHttpClient)) |
| 09:37 | raek | (ns foo.bar (:import (org.apache.http.client HttpClient) (org.apache.http.impl.client DefaultHttpClient))) |
| 09:38 | raek | so, using 1-vectors happens to be the same as the infamous empty-prefix-list |
| 09:38 | bartj | raek: I am assuming your last import is the correct one ? |
| 09:38 | raek | yes |
| 09:39 | raek | it is the way I have learned that it should be done |
| 09:39 | raek | (please correct me, someone, if I have learned the wrong thing) |
| 09:39 | bartj | ok, I now get an error that makes sense! |
| 09:40 | raek | anyway, (:import [org.apache.http.client.HttpClient]) is treated like (:import (org.apache.http.client.HttpClient)) |
| 09:40 | chouser | stuartsierra: why are parens preferred? |
| 09:40 | raek | that is, import *nothing* from the "org.apache.http.client.HttpClient" package |
| 09:40 | stuartsierra | chouser: 'Cause that's what the docs say, dammit! |
| 09:40 | bartj | raek, org.apache.http.client.HttpClient is not the same as org.apache.http.client HttpClient ! |
| 09:40 | bartj | raek, why so ? |
| 09:41 | chouser | stuartsierra: hm. good point. |
| 09:41 | raek | no |
| 09:41 | raek | foo.bar.A is the same as (foo.bar A) |
| 09:41 | raek | foo.bar.A foo.bar.B is the same as (foo.bar A B) |
| 09:41 | bartj | ok, then the only change that I did was to convert [] to () |
| 09:42 | raek | you need to either drop the parens or replace the last period with a space |
| 09:43 | bartj | I did both |
| 09:43 | raek | (:import (foo.bar)) means "for all elements of the emply list, import them from the foo.bar package" |
| 09:43 | bartj | and thinks seem to work fine |
| 09:44 | raek | ok, great! |
| 09:44 | raek | what does your :import look like now? |
| 09:45 | bartj | (:import (foo1 bar1) (foo2 bar2)) |
| 09:46 | bartj | I previously had: |
| 09:46 | bartj | (:import [foo1.bar1] [foo2.bar2]) |
| 09:48 | bartj | I wonder why that is wrong! |
| 09:48 | raek | the previous? |
| 09:48 | bartj | yes, my last statement |
| 09:49 | raek | because of how it's implemented, it gets treaded as (:import (foo1.bar1) (foo2.bar2)) would have |
| 09:50 | raek | since you should only use vectors when passing options, iirc |
| 09:50 | raek | do you understand how (:import (foo1.bar1) (foo2.bar2)) is interpreted? |
| 09:50 | bartj | no |
| 09:52 | raek | but you understand how (foo.bar X Y Z) would be interpreted, right? |
| 09:52 | bartj | can you please explain |
| 09:52 | bartj | yes, import the classes X Y Z of package foo.bar |
| 09:53 | raek | now, imagine that you import *no* classes from package foo.bar... how would that be written? |
| 09:53 | bartj | (:import (foo.bar '())) |
| 09:54 | raek | (foo.bar X Y) = two classes, (foo.bar X) = one class, (foo.bar) = zero classes |
| 09:54 | bartj | ok |
| 09:54 | raek | your example has an empty list where the first class should go |
| 09:54 | bartj | yes, right - just (foo.bar) |
| 09:54 | raek | exactly |
| 09:54 | bartj | I think I was trying to be a bit clever - unnecessarily |
| 09:55 | raek | it's too bad that it doesn't signal any error when you do that |
| 09:55 | raek | since I don't think *anyone* wants to import zero number of classes |
| 09:55 | bartj | ok |
| 09:56 | bartj | so (:import (foo1.bar1) (foo2.bar2)) |
| 09:56 | bartj | actually don't make sense |
| 09:56 | bartj | because you don't specify any classes for the packages ? |
| 09:56 | chouser | it really ought to print a warning |
| 09:56 | bartj | am I correct ? |
| 09:57 | bartj | I am sorry, I gotta run |
| 09:58 | bartj | 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 | chouser | :as is a destructuring feature |
| 10:31 | chouser | 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 | hugod | thanks |
| 10:40 | stuartsierra | hello, contrib committers |
| 10:40 | stuartsierra | ? |
| 10:43 | chouser | uh.. um... ahem, yes? |
| 10:43 | stuartsierra | I'm working on a versioning / release policy for the modularized contrib |
| 10:44 | stuartsierra | 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 | stuartsierra | But that raises questions, such as... |
| 10:45 | stuartsierra | Which version of Clojure (core) should modules depend on? |
| 10:46 | stuartsierra | 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 | stuartsierra | 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 | stuartsierra | 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 | stuartsierra | HOWEVER |
| 10:52 | stuartsierra | As we know, AOT-compilation is indiscriminately transitive. |
| 10:53 | stuartsierra | 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 | stuartsierra | 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 | chouser | cemerick: c'mon, man, write a better patch! |
| 10:57 | chouser | :-) |
| 10:58 | cemerick | ha |
| 10:58 | cemerick | 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 | cemerick | 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 | stuartsierra | 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 | stuartsierra | cemerick: yes that sounds right |
| 11:01 | chouser | could an individual module specifically prevent itself from being AOT compiled? |
| 11:02 | chouser | 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 | 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 | stuartsierra | 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 | cemerick | You never know what people downstream will need to do. |
| 11:04 | cemerick | 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 | stuartsierra | From that point, each module can follow its own release / versioning path. |
| 11:07 | stuartsierra | 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 | stuartsierra | There will still be versioned releases of org.clojure.contrib:complete, which will have transitive dependencies on all other modules. |
| 11:08 | stuartsierra | 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 | stuartsierra | 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 | stuartsierra | 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 | stuartsierra | 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 | fliebel | ,(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 | chouser | 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 | stuartsierra | Strings make me go all imperative for some reason. |
| 11:26 | ordnungswidrig | stuartsierra: where comes the map in? |
| 11:26 | stuartsierra | oops |
| 11:26 | stuartsierra | (doseq [[k v] the-map] ...) |
| 11:26 | stuartsierra | 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 | ordnungswidrig | 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 | chouser | arkh: 'for' is lazy, so 'prn' won't be called unless you force the sequence. |
| 11:35 | chouser | 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 | fliebel | 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 | arkh | 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 | fliebel | arkh: the idea is that humans are not proper random number generators, and so are predictable |
| 11:50 | fliebel | 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 | fliebel | 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 | fliebel | 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 | grc | 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 | technomancy | with special sauce |
| 12:06 | technomancy | http://github.com/Seajure/serializable-fn |
| 12:07 | chouser | that doesn't handle closures, does it? |
| 12:09 | stuartsierra | Nothing handles closures. |
| 12:10 | stuartsierra | "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 | stuartsierra | 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 | grc | Whether or not teh function is *actually* called I can live with |
| 12:16 | stuartsierra | :pre/:post should never have side-effects |
| 12:17 | stuartsierra | 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 | _fogus_ | 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 | chouser | /me, that is. |
| 12:23 | chouser | arkh: no, lazy-seq just creates one step |
| 12:23 | chouser | don't see how it'd be useful to call it on a string |
| 12:23 | arkh | chouser: oh, cool |
| 12:23 | arkh | it returns a different string each time |
| 12:24 | arkh | 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 | chouser | 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 | stuartsierra | We'll see if the Hudson build passes. |
| 12:35 | stuartsierra | 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 | raek | arkh: just replace take! with your java call |
| 12:46 | raek | 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 | stuartsierra | 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 | stuartsierra | 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: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 | raek | 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 | chouser | 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 | chouser | right |
| 13:38 | joshua-choi | ..and that's why. |
| 13:38 | joshua-choi | 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 | _fogus_ | :p |
| 13:40 | technomancy | (extend-type java.util.regex.Pattern IFn) ;; <= if only =\ |
| 13:40 | chouser | (extend-protocol PMeta Class ...) |
| 13:41 | chouser | 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 | jneira | :-( |
| 13:43 | jneira | i suppose defprotocol in 1.2.0 works for everyone else ... |
| 13:44 | jneira | .(+ 1 2 3) |
| 13:44 | jneira | jum i have to enter in irc a little bit more |
| 13:46 | jneira | , (+ 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 | chouser | 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 | jneira | 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 | kumarshantanu | 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 | raek | it is what clojure.core uses, anyway... |
| 14:06 | arkh | I finally half understand lazy-seq |
| 14:07 | arkh | 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 | raek | it can be quite useful when learning when lazy sequences are realized |
| 14:19 | raek | 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 | chouser | @#'foo for non-function values |
| 14:28 | mrBliss | How do I hint something of the following type: |
| 14:29 | mrBliss | ,(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 | mrBliss | I'll tryit |
| 14:31 | mrBliss | I think it works (not so clear because of other warnings in the same method) |
| 14:31 | mrBliss | thanks |
| 14:32 | raek | the "L" and "[...;" notation of the JVM is not very aestethic... |
| 14:33 | raek | *"L...;" and "[" |
| 14:33 | chouser | no |
| 14:35 | _fogus_ | chouser: no go |
| 14:36 | _fogus_ | oh wait, it needs ns qualification |
| 14:36 | chouser | sorry, try fully-qualifiying the ... yeah |
| 14:36 | chouser | 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 | chouser | 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 | mrBliss | found my problem, I had a File in with-open, but File hasn't got a .close method |
| 15:01 | chouser | ah |
| 15:01 | chouser | 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 | wwmorgan | 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 | cemerick | 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 | mabes | 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 | chouser | ,(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 | pdk | how much swap space would you give to a system youre setting up with 4gb ram |
| 15:51 | pdk | ,(* 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 | ssideris | ,(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 | ssideris | thanks |
| 15:57 | Chousuke | ssideris: out of curiosity, why did you put the '(%) in the function? |
| 15:57 | Chousuke | 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 | Chousuke | 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 | kumarshantanu | Chousuke: I was trying _ because I didn't need to refer the value of future |
| 16:07 | Chousuke | I see. |
| 16:07 | Chousuke | 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 | kumarshantanu | 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 | arohner | 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 | arohner | so javac doesn't have a Java API? |
| 16:29 | arohner | 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 | fliebel | 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 | fliebel | Psygology is complicated... |
| 17:09 | fliebel | I'm going to switch to a better system tomorrow *yawn* |
| 17:11 | fliebel | 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 | kumarshantanu | 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 | replaca | *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 | mvid | 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 | raek | lein repl |
| 18:12 | raek | (require 'project.core) |
| 18:13 | mvid | im using lein v 1.3 |
| 18:14 | mvid | is that too old? |
| 18:14 | mvid | 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 | mvid | 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 | technomancy | 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 | technomancy | 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 | lancepantz | brenton somebody |
| 18:42 | tomoj | aha http://github.com/brentonashworth/sandbar |
| 18:42 | tomoj | yeah |
| 18:42 | tomoj | 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 | Licenser | (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 | zztr | ,(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 | qbg | I use it once in my parallel mapreduce function |