#clojure log - Nov 30 2010

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

0:09 Raynes: KirinDave: Any particular reason for not mentioning Practical Clojure.

0:09 s/Clojure./Clojure?/

0:09 sexpbot: <Raynes> KirinDave: Any particular reason for not mentioning Practical Clojure?

0:09 KirinDave: Raynes: Haven't ready it yet

0:10 Raynes: Neither have I. Still think I'd recommend it, after hearing stuff like "It's like Programming Clojure for Clojure 1.2"

0:12 Not as much recommend it as point it out. Can't really give a solid recommendation without having read it.

0:12 I was going to buy a copy at the Conj, but didn't get around to it.

0:58 ossareh: zippers are fkin cool

0:59 just wrote a fn that takes a map of errors and zips across a hiccup vector set and inserts errors in the right place

1:57 replaca: hiredman: are you here?

2:03 hiredman: replaca: yes

2:32 LauJensen: Morning people

2:35 zkim: Anybody know why alter-var-root is preferred over binding for mocking? My google-fu is failing me on this.

2:54 LauJensen: I didnt know that it was ?

3:01 zkim: LauJensen: http://twoguysarguing.wordpress.com/2010/10/25/the-conj/ search for alter-var-root, I've heard this a couple of times but can't seem to find an explanation

3:02 LauJensen: Ah. I think that can only be because of the threading issues related to binding. Which I believe are solved in the lastest git code actually

3:03 zkim: ah cool, thanks lau

3:03 LauJensen: user> (def x 5)

3:03 #'user/x

3:03 user> (binding [x 10] (pmap #(+ % x) (range 10)))

3:03 (5 6 7 8 9 10 11 12 13 14)

3:03

3:34 Which S3 libs to we have ?

4:21 cpfr: are atoms the correct way to implement cyclical data structures?

4:55 drdo: cpfr: What do you mean?

4:55 cpfr: drdo, nevermind I think I got a handle on this for now

5:36 djpowell: urgh - tomcat's classloader caches every resource forever with no option to reload

5:38 things like this give 'caching' a bad name. if it isn't referentially transparent, it isn't caching, it is in-built staleness.

5:38 end-rant

5:40 it is clojure-related tho. I'm trying to have some clojure files get reloaded if they change, so this behaviour makes all the clojure.lang.RT/load stuff not work for me

5:47 lpetit: cpfr: did you solve your problem ?

5:48 cpfr: lpetit, I won't be sure until I evaluate my code in the cold clarity of tomorrow morning ;)

5:49 djpowell: Is it safe to use Compiler.load() from Java? Does all the initialisation happen?

5:50 lpetit: cpfr: there's always some tension between fp and cyclical data structures, the risk to conflate identity and value by (ab)using reference types ...

5:51 cpfr: lpetit, I am using atoms, and vectors of references

5:52 then using identity to check if I have encountered the item before

5:53 identity is for p==q, value is for *p==*q ... to borrow C parlance

5:57 lpetit: cpfr: hm, I was not talking about object identity, but with "state" semantics, as defined by Rich. "identity" = "set of values over time", "value"=immutable thing, "state" = snapshot of an identity at some point in time.

5:57 cpfr: ah yes, I remember that talk

6:11 fliebel: morning

6:19 mduerksen: fliebel: morning. i checked yesterday, and most functions with their name in the docstring have it in the first sentence (before the first occurence of '.').

6:20 fliebel: mduerksen: What is your conclusion from this?

6:22 mduerksen: i'm not sure. i certainly would guess that these cases (about 100) should not be masked. given that about 140 functions in total have their name in the doc, and there were about 30 functions with the (<name pattern, there is a chance that these sets are mostly distinct. in that case, the pattern should do well

6:23 but i haven't checked if the groups mix

6:23 fliebel: mduerksen: putting both in a set should make that a one-line I believe.

6:24 But you're saying replacing (name is the best bet?

6:26 mduerksen: with the given data, yes. but if you want to have more certainty, it would help to check which function have their name in it *after* the first dot

6:26 with or without the paren, i mean

6:27 fliebel: I see.

6:44 I'm using some old compojure code, but it seems the html code was removed from compojure, where do I get it?

6:45 raek: fliebel: it was split off into the 'hiccup' project

6:45 fliebel: ah, will try...

6:45 raek: much of the middleware has been merged into ring

6:49 fliebel: raek: So redirect-to and run-server are to found in ring?

6:50 raek: yes

6:50 http://mmcgrana.github.com/ring/ <-- docs

6:51 ring.util.response/redirect and ring.adapter.jetty/run-jetty

6:52 fliebel: raek: Awesome, thanks. Now, off to clojars to find their versions and such...

6:53 raek: [ring/ring-core "0.3.5"] and [ring/ring-jetty-adapter "0.3.5"]

6:53 fliebel: you're fast… But I must say clojars does a bad job at searching.

6:53 raek: or [ring "0.3.5"] for the big bunch

6:54 I usually look in the project.clj file at github

6:54 clojars.org/<project-name> gives accurate info most of the time

6:54 but not always

6:54 fliebel: raek: Smart, I hadn;t thought of that. Do you bother to look at the correct branch, or just assume trunk is the right one?

6:55 raek: the later I suppose :)

6:57 https://github.com/raek/lcug-guestbook <-- guestbook example web application written for one of the Linköping clojure meetings

6:57 written with Moustache (the other routing lib) and Enlive (alternative to hiccup), though...

7:04 fliebel: Why is this an unsupported binding form? (defroutes reddit (GET "/" (reddit-home session))) He's doing with-session later. Ugh, I hoped this was a clone-and-run job.

7:04 raek: I think the defroutes syntax has changed a little

7:04 fliebel: ouch :(

7:04 raek: it used to have magic variables (request, and params, IIRC)

7:05 so you need to att a binding vector somewhere

7:05 fliebel: so more like (GET  "/" [session] (reddit-home session))?

7:05 raek: (GET "/" [] (reddit-home session)))

7:05 fliebel: okay, so the session is still magic

7:05 raek: https://github.com/weavejester/compojure/wiki/Routes-In-Detail

7:06 oh, compojure has already passed 0.5

7:06 I haven't used it myself since the 0.3 days

7:07 fliebel: with-session is nowhere to be seen.

7:07 raek: http://mmcgrana.github.com/ring/middleware.session-api.html

7:08 middleware seems to use the wrap-_____ naming convention nowadays

7:08 fliebel: right…

7:10 So, :session is now on the request, so I should use wrap-session and then [session] in the route?

7:11 raek: I think the binding vector is for path segments

7:11 oh wait

7:11 seems like you can replace (GET "/" [] ...) with (GET "/" {:keys [session]} ...)

7:12 fliebel: "This can either be a vector of parameters you want, or a full Clojure destructuring form." so a vector of just session wil work as well, right?

7:13 raek: looks like [a b c] is a shorthand for {{:keys [a b c]} :params}

7:13 but I dunno...

7:13 this is one of the reasons I started using Moustache

7:14 Moustache is very regular and non-magic

7:14 fliebel: raek: I can't agree more.

7:16 raek: I'm sure compojure is great nowadays, but I learned what know about it before The Great Compojure Turbulence

7:17 one style I've come to use myself is to pick out the interesting parts of the request map with ordinary clojure destructuring in a handler function

7:17 and only let the routing choose which handler function that gets called

7:18 fliebel: I see...

7:19 Where can I find more about the destructuring syntax?

7:19 raek: of clojure?

7:20 I think its main documentation is at the docs for let: http://clojure.org/special_forms#Special Forms--(let [bindings* ] exprs*)

7:22 (defn my-handler [{{:keys [a b c], :as params} :params, session :session, :as request}] ...)

7:22 it's probably more readable to split up that into multiple steps i a let...

7:23 fliebel: huh, that is magic...

7:23 raek: *excplicit* magic... :-)

7:25 hrm, replace {:keys [a b c], :as params} with {:strs [a b c], :as params}...

7:25 fliebel: So can I write [{:keys [id]} session {:keys [title turl]} params]?

7:26 raek: almost

7:27 ,(let [{:keys [id]} :session, {:strs [a b], :as params} :params} {:session {:id 0}, :params {"a" 1, "b" 2}}] [id a b params])

7:27 clojurebot: Unmatched delimiter: }

7:27 raek: ,(let [{:keys [id]} :session, {:strs [a b], :as params} :params}} {:session {:id 0}, :params {"a" 1, "b" 2}}] [id a b params])

7:27 clojurebot: Unmatched delimiter: }

7:28 fliebel: Actually I want the whole of session and parts of params, but using a vector, compojure gives me their value in params?

7:28 raek: I now next to nothing about Compojure's binding syntax sugar...

7:29 but from what I can tell from https://github.com/weavejester/compojure/wiki/Routes-In-Detail

7:29 it seems so

7:29 it hints that [id] is the same as {{id "id"} :params}

7:30 fliebel: strange thing to do.

7:31 raek: ,(let [{{:keys [id], :as session} :session, {:strs [a b], :as params} :params} {:session {:id 0}, :params {"a" 1, "b" 2}}] [id a b session params])

7:31 clojurebot: [0 1 2 {:id 0} {"a" 1, "b" 2}]

7:33 fliebel: just {session :session} :session will give me session as well, right?

7:34 raek: session :session

7:34 or

7:34 :keys [session]

7:34 fliebel: okay, I think I know enough now :)

7:34 Lets see

7:35 raek: if the key is a keyword, the second thing is what you lookup in the map

7:35 *if the key is a symbol

7:36 ...and that symbol is bound to the value of looking up the second thing in the map

7:36 fliebel: right, but compojure params are keywords, right?

7:36 raek: ring's wrap-params gives them as strings

7:39 fliebel: oh, so I need "id" and all :(

7:41 raek: {id "id"} or {:strs [id]}

7:42 (:keys and :strs is a short form for "I want to bind these symbols to the value associated with the keyword/string with the same name")

7:42 fliebel: right

7:50 AWizzArd: Hi rhickey, good morning.

8:10 fliebel: There we are, a version of cloneit that work. https://github.com/pepijndevos/cloneit

8:10 LauJensen: ping

8:21 rhickey: has anyone tried *unchecked-math* yet?

8:22 djpowell: i had a quick go - but I was a bit confused about how it interacts with the compiler

8:22 you can't binding *unchecked-math* can you?

8:22 rhickey: djpowell: no, it's like in-ns

8:23 it is looked at by the compiler (and some macros) when compiling, not at runtime

8:23 djpowell: could it get promoted to a ns macro flag? in theory

8:24 rhickey: djpowell: it is not a property of the ns

8:25 djpowell: so, you set! it, define a funciton, then set! it back to off (?)

8:25 rhickey: you could turn it on before a few defns and off afterwards

8:26 djpowell: it seems useful anyway, ignoring the performance aspects - particularly for doing stuff with bytes, which is pretty horrible without it

8:27 rhickey: but putting a single set! true at the top of the file will cover you

8:27 djpowell: will it automatically revert to false at the end of the file?

8:28 rhickey: yes, it is pushed on file load/compile and popped after

8:28 * rhickey notices *warn-on-reflection* isn't doing that properly

8:31 djpowell: btw: are those cheap LazyPersistentVector things a big performance win?

8:33 I was looking at finger-trees, and the profiler seemed to suggest a lot of time was spent making vectors, and as they are from concatting odd bits of vectors together, they fail to take the fast-path through LazyPersistentVector. (not sure I trust the profiler, haven't investigated in detail yet)

8:33 LauJensen: fliebel: pong

8:33 fliebel: LauJensen: I made that redit clone of yours work with more recent versions of everything.

8:34 LauJensen: I didnt work?

8:34 fliebel: no, compojure has changed quite a lot

8:35 LauJensen: fliebel: If you left the dependencies alone, it worked right?

8:35 fliebel: Didn't try very hard. Cake said something weird and then I changed the version numbers.

8:36 LauJensen: fliebel: Looks OK - If I can find the time I'll do a clojureql/moustache/enlive version. Should be quite nice

8:36 fliebel: awesome :)

8:51 dnolen: ,(meta (cons 'a (with-meta '() {:type ::foo})))

8:51 clojurebot: nil

8:52 dnolen: hmm so metadata isn't preserved with cons?

8:52 raek: ,(meta (rest (cons 'a (with-meta '() {:type ::foo}))))

8:52 clojurebot: {:type :sandbox/foo}

8:53 raek: ,(meta (conj 'a (with-meta '() {:type ::foo})))

8:53 clojurebot: java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to clojure.lang.IPersistentCollection

8:53 raek: ,(meta (conj (with-meta '() {:type ::foo}) 'a))

8:53 clojurebot: {:type :sandbox/foo}

8:53 raek: good question

8:53 chouser: ,(class (conj '() 'a))

8:53 clojurebot: clojure.lang.PersistentList

8:54 chouser: ,(class (cons 'a '()))

8:54 clojurebot: clojure.lang.Cons

8:54 chouser: So metadata isn't propagated with Cons.

8:55 pdk: (doc conj)

8:55 clojurebot: "([coll x] [coll x & xs]); conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type."

9:00 fogus`: rhickey: Should *assert* act similarly?

9:01 rhickey: fogus`: assert begs for higher-level debug build control, I don't want set! *assert*'s in code

9:02 it should instead follow a parameter for the build

9:02 tonydark00: Ciao

9:03 rhickey: we never got a good proposal for debug builds, but perhaps now as we're getting deeper into maven-land...

9:04 lrenn: rhickey: what is your Go rank? Inquiring minds want to know :)

9:04 fogus`: Maven-land sounds so ominous.

9:05 rhickey: ominous is the least of it

9:05 chouser: Speak, friend, and enter.

9:05 fogus`: In the heart of Maven-land lies Mount Pom!

9:08 rhickey: lrenn: dunno, not very high, last ranked tournament was when I was first learning - AGA 7k then, played at up to 2k-ish at the NYC club (years ago), slipping ever since due to lack of playing :(

9:08 lrenn: rhickey: I know the feeling. #clojure should move off of irc and onto KGS or IGS :)

9:10 dnolen: rhickey: is the lack of metadata on the result returned by cons a bug? I'm looking at the code of Cons.java, seems like it should work.

9:16 charliekilo: ClojureQL Q: Does anyone know if LIKE is supported by current version (I couldn't find anything in the code)? ... and if it is not, if there is a reason and what the reason is.

9:20 LauJensen: charliekilo: like is defined in predicates.clj

9:21 charliekilo: LauJensen: Dooh ... there is it! Sorry about that!

9:22 LauJensen: no worries :) You might also stop and wonder about the simplicity of its implementation - If it hadn't been there, it would be trivial for you to put it there

9:29 lenw: hi all

9:30 using contrib.seq

9:30 is this right

9:30 (contains? [1] 1) returns false

9:31 LauJensen: yes

9:31 lenw: but (contains? [1 2 3] 1) is true ?

9:31 LauJensen: ,(doc contains?)

9:31 clojurebot: "([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric k...

9:32 LauJensen: Just like the doc string says

9:32 &(contains? {:one 1 :two 2} :two)

9:32 sexpbot: ⟹ true

9:32 lenw: my pardon its the key not the value

9:32 dnolen: ,(some? #{1} [1 2 3])

9:32 clojurebot: java.lang.Exception: Unable to resolve symbol: some? in this context

9:32 charliekilo: LauJensen: a follow-up question, there is no '!like' (-> name NOT LIKE 'test%')? the recommended way is the use of "restrict-not' ... how far am I off (be honest ;)?

9:32 dnolen: ,(some #{1} [1 2 3])

9:32 clojurebot: 1

9:32 dnolen: ,(some #{9} [1 2 3])

9:32 clojurebot: nil

9:32 lenw: yes thats it

9:33 LauJensen: charliekilo: right on. But defining !like wouldn't be a bad idea

9:33 Chousuke: make it not-like :P

9:33 LauJensen: mm

9:34 Chousuke: I don't thikn ! is idiomatic for "not"

9:34 lpetit: ,(doc not=)

9:34 clojurebot: "([x] [x y] [x y & more]); Same as (not (= obj1 obj2))"

9:35 LauJensen: its not. We only use it for !=

9:35 lpetit: ,(doc not-nil)

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

9:35 lpetit: woop

9:35 Hello all !

9:35 LauJensen: hello bro :;)

9:35 LauJensen: lpetit: yo buddy :)

9:47 lpetit: New ccw REPL integration is over. It's now fully functional, some (scarce) regressions have been tackled. Beta release by thursday, probably.

9:49 LauJensen: lpetit: great! Hows the OSGi coming along?

9:51 lpetit: Laujensen: that's one of the additional features I'd like to add as a bonus before releasing. aav has been working on adding a clojure.osgi/with-bundle* function which allows to evaluate code in the (classpath) context of the bundle whose name is passed in first argument => this will really (finally !) let me have proper interactive env. for ccw dev !

9:51 LauJensen: And thats close now?

9:53 lpetit: Laujensen: well, the with-bundle* feature comes with a bunch of additional ones in clojure.osgi which lead to some regressions, still fighting them

9:53 LauJensen: Ok. Looking forward to seeing the next release :)

10:11 kjeldahl: Any Incanter users on? If I just type the name of a dataset in repl, it shows me a list of vectors, the first is the column header and then the rows, but if I iterate over it, it shows me two vectors, one with column names, and one with rows inside.

10:11 Is there a special "show" method being called by default if I just tell it to show itself through repl?

10:18 chouser: kjeldahl: I don't know Incanter, but normal REPLs use the print-method multimethod to print things

10:19 so it could be that Incanter datasets have their own (defmethod print-method ...) to print specially.

10:20 raek: kjeldahl: how do you iterate over it?

11:40 cemerick: OT, but this is remarkably helpful, especially for someone like me that doesn't know IEEE bit layouts by heart: http://download.oracle.com/javase/6/docs/api/java/lang/Math.html#nextUp(double)

11:41 I vaguely remember someone here some months back mostly convincing me that the above wouldn't be generally useful; any mathy folk have opinions of such an operation?

11:43 fogus`: nunjudd in Action: http://blog.fogus.me/2010/11/30/take-6-justin-balthrop/

11:44 s/nunjudd/ninjudd/

11:44 sexpbot: <fogus> ninjudd in Action: http://blog.fogus.me/2010/11/30/take-6-justin-balthrop/

11:45 zmyrgel: hi, can the clojure.walk's postwalk function's walking be limited to certain types?

11:45 Derander: What's the best way of implementing a callback system? I have a series of sub-modules that I'd like to subscribe to filetypes

11:46 Each time I loop I generate a list of files that have changed and would like to hand them over to the appropriate functions

11:46 zmyrgel: I tried the postwalk-demo function for my game tree and it walked the fields of my record I'm storing in the gametree

11:46 Derander: bah, nevermind.

12:04 kumarshantanu: is it possible to access Java enums in Clojure?

12:04 chouser: kumarshantanu: yep

12:06 alexyk: how do you join together a vector into a string with "\t"?

12:06 chouser: ,(clojure.string/join \tab [1 2 3 4])

12:06 clojurebot: java.lang.ClassNotFoundException: clojure.string

12:06 chouser: ,(require 'clojure.string)

12:06 clojurebot: nil

12:06 chouser: ,(clojure.string/join \tab [1 2 3 4])

12:06 clojurebot: "1\t2\t3\t4"

12:07 kumarshantanu: chouser: can you give me a simple example? I just need to read enum values

12:08 alexyk: chouser: thx! I always forget where I get the join from :)

12:12 kjeldahl: raek: Iterate over clojure dataset: ($ :all nameofdataset)

12:12 raek: s/clojure/incanter/

12:13 raek: or (doall (map println nameofdataset))

12:14 raek: Eh, doall not needed.

12:14 kumarshantanu: chouser: found it! (it was an inner class that I figured needs $ as separator)

12:14 fliebel: Whoohoo, my automatic Reddit clone works: http://77.164.81.181/

12:21 chouser: kumarshantanu: sorry, I stepped out. glad you found it.

12:31 zmyrgel: How to represent "" as char?

12:32 Chousuke: hm?

12:32 does that even make sense?

12:33 zmyrgel: probably not

12:33 Chousuke: if you must, perhaps nil will work

12:33 zmyrgel: that gave NPE

12:33 raek: zmyrgel: what is you use case?

12:33 zmyrgel: raek: removing certain char from string

12:34 but I changed the code to just use strings

12:36 * raek just learned about the 'ptree' command

12:36 raek: pstree, even

12:37 fliebel: what?

12:37 clojurebot: what is short for ,(doc ...)

12:39 fliebel: raek: Where is that to be found?

12:39 raek: it is a command line program

12:40 for unix-like systems

12:42 fliebel: raek: Oh, I was trying what clojurebot suggested.

12:43 raek: 'tree' is neat too

12:45 http://pastebin.com/cMuE1mxN

12:46 fliebel: I know tree, but not ptree and pstree

12:47 raek: ptree was just a typo :)

12:48 fliebel: -bash: pstree: command not found

13:13 LOPP: man I must be too dumb for clojure

13:14 Every time I try to do a beginner exercise for java in clj I end up using loop/recur as impromptu for loop

13:15 case in point: given height (lines), print out a pyramid (triangle) out of "*"

13:16 clojure code ended up messier than java

13:24 dakrone: LOPP: how were you doing it in Clojure?

13:25 LOPP: I tried in many way

13:25 eventually it was the least hassle just approximating java for loops with loop/recur

13:26 raek: ,(take 5 (iterate #(str % "**") "*"))

13:26 clojurebot: ("*" "***" "*****" "*******" "*********")

13:26 raek: ,(count (let [s "***", n 7, spaces (repeat (/ (- n (count s)) 2) \space)] (apply str (concat spaces s spaces))))

13:26 clojurebot: 7

13:26 raek: ,(let [s "***", n 7, spaces (repeat (/ (- n (count s)) 2) \space)] (apply str (concat spaces s spaces)))

13:26 clojurebot: " *** "

13:26 LOPP: exercises for java programmers that can't be easily converted into operations over lists typically end up in ugly clojure code, at least for me

13:27 I don't think you need to add spaces at the end

13:32 nickaugust: does clojure work on the non-oracle JVMs?

13:33 fliebel: LOPP: ##(let [star (take 5 (iterate #(str "**" %) "*")) space (take 5 (iterate #(apply str (next %)) " "))] (dorun (map (comp println str) space star)))

13:33 sexpbot: ⟹ * *** ***** ******* ********* nil

13:33 raek: LOPP: my try: https://gist.github.com/722136

13:34 technomancy: nickaugust: works great on openjdk, ok on IBM, and not at all on gcj.

13:35 nickaugust: technomancy: thx

13:38 joshua__: How would I get a timestamp/datetime in Clojure? I'm working on making a function for rate limiting.

13:41 fliebel: LOPP, raek: Now, how about a christmas tree?

13:42 bortreb: ambient? are you there

13:43 I was wondering how (defn lo-pass [d coll] (reductions #(+ (* %2 d) (* %1 (- 1.0 d))) coll)) manages to implement a lo-pass filter

13:43 is it exact or approximate?

13:44 anyone know??

13:46 nickaugust: technomancy: so clojure is very much dependent on oracle not doing anything dumb with openjvm

13:48 LOPP: raek

13:48 raek: yupp?

13:48 technomancy: nickaugust: not really; openjdk 1.6 is always going to be there and free.

13:48 LOPP: now compare the complexity of your code with this

13:48 http://pastebin.com/np42jLT5

13:50 nickaugust: also whats the advantage of being on the JVM? dont you basiclly have platform independence by adhering to posix? being such a pain to maintain the JVM what is the benifit we get for using it? library support?

13:52 LOPP: bbl

13:53 Chousuke: nickaugust: you get the platform for free.

13:54 nickaugust: libraries, portability, garbage collection, optimisations

13:55 nickaugust: if you implemented Clojure "from scratch" you'd have to take care of everything yourself.

13:55 LOPP: yep

13:55 Chousuke: and the end result would probably be inferior, since the JVM is rather awesome.

13:55 LOPP: nobody cares about languages with crap libraries

14:01 raek: LOPP: https://gist.github.com/722184

14:02 * technomancy can't tell nickaugust is asking a serious question or just trolling.

14:02 raek: my previous attempt had more reusable parts, though...

14:03 nickaugust: no not trolling! not atm anyway :P just trying to make smart decisions. :)

14:03 Ive heard the JVM is hard to maintain

14:04 kumarshantanu: nickaugust: oracle is pissing lots of devs these days, but clojure is ported to CLR too

14:04 LOPP: in what way

14:04 nickaugust: CLR isnt open though :/

14:04 chouser: nickaugust: the JVM is a whole bucketful of engineering compromises. When their decisions line up with your needs, it can be truly fantastic.

14:04 technomancy: consider that Clojure was implemented by one person in a handful of years and is much faster than Ruby, which has had a large team of developers working on it for decades.

14:04 LOPP: awesome raek

14:04 good work

14:04 kumarshantanu: nickaugust: yeah, and there are people interested for Parrot too

14:05 LOPP: yeah I ended up using loop recur too

14:05 the other looping constructs seem limited

14:05 raek: LOPP: the last version is basically just a translation of the java code

14:05 modulo fixing the initial stars value

14:06 LOPP: I see

14:06 bbl

14:06 raek: LOPP: now, star-seq might not be something you use very often, but centering a string in a fixed width column might

14:06 jsanda: i'm not a ruby dev, but i've heard that in many instances jruby has outperformed the c implementation of ruby, so in terms of performance, i think the jvm is an attractive choice

14:07 nickaugust: i guess i just dont understand why VMs are the future. i mean why abstract away the OS like that? is it easier to be compatible with VMs that with OSes? I thought thats why we had posix standards. im not trolling im really trying to make a good decision on what technology to use and clojure looks awesome. im just worried i'll kick myself later for choosing to be dependent on the decisions of

14:07 oracle. i guess thats why support for the other open JVMs is important

14:07 raek: I think one of the powers of functional programming is that code tends to (at least IMHO) be easy to compose and reuse

14:07 jsanda: and as far as performance goes there is work being done to improve performance for dynamic languages. java 7 or maybe 8 now is going to add a new byte code to significantly improve the performance of dynamic method invocation

14:08 joly: I remember there being problems with posix implementations, where systems like NT were declared posix compliant but still missed out on much functionality people relied on

14:09 nickaugust: is ther performance benifits from using a bytecode compiler? obviously theres something attractive to M$ and oracle about VMs

14:09 yeah posix isnt perfect by any means

14:09 kumarshantanu: nickaugust: I know at lest one person who thinks a C port of Clojure (with FFI) would be awesome, but I am not sure how good library support will be there

14:10 s/lest/least/

14:10 sexpbot: <kumarshantanu> nickaugust: I know at least one person who thinks a C port of Clojure (with FFI) would be awesome, but I am not sure how good library support will be there

14:10 nickaugust: well thats the kicker... in order to get library support you need to gain the acceptance of the wider community but to gain thier acceptance you need... well library support

14:10 chouser: nickaugust: using a VM is not primarily a performance decision, though there are things that can be done with live profiling of a running code of the sort hotspot does that isn't done on processors today.

14:11 jsanda: i have read that there are lots of potential performances gains for runtimes like the JVM as well as the CLR since they can perform compiler optimizations at runtime based on the given runtime profile

14:11 nickaugust: so portability is the advantage of using a VM?

14:12 kumarshantanu: nickaugust: portability + libraries written in non-clojure languages

14:13 hiredman: the advantage to using a vm is the same as it every was

14:14 the unix process model is a vm, the interface it provides is an abstraction on top of hardware

14:22 pjstadig: hiredman is getting philisophical

14:22 * pjstadig .oO(What *is* a VM?)

14:23 * kryft .oO(What was my original face before my parents were born?)

14:23 technomancy: it's like a machine... but virtual. whoa.

14:23 * technomancy puts away his mirrorshades

14:26 hiredman: from what little experience I have with old gray beard unix dudes that is how they refered to it "the unix vm"

14:27 Chousuke: it's vms all the way down

14:28 the processor offers a virtual interface nowadays too :P

14:28 sort of

14:38 nickaugust: hmm interesting way of looking at it..

14:55 fliebel: raek, LOPP: This beats them all: (doseq [l (take 10 (iterate #(str % "*") ""))] (println (format "%1$30s*%1$s" l)))

14:56 KirinDave: Am I misreading this

14:56 or is there no way to import all classes in a java package?

14:56 hiredman: correct

14:56 chouser: it's a feature

14:57 KirinDave: chouser: A feature which makes me type more.

14:57 cemerick: And not particularly possible given a dynamic environment.

14:57 chouser: KirinDave: a feature that makes your code better

14:57 KirinDave: chouser: When a package name ends in "schema" you know things are about to get exciting with import, eh?

14:58 chouser: I do wish there were a way to alias classes and/or package names.

14:59 KirinDave: I've got probably 30 classes to import. I can feel the typing making my programming skills grow. :)

14:59 Oh wait, I'm going to use ack and awk.

14:59 I guess using those every once in awhile does constitute the kind of mental gymnastics that help keep one's edge sharp.

15:00 chouser: well, you could use a macro

15:00 it you're desperate

15:00 pjstadig: can you write a program to generate the import for you?

15:00 KirinDave: pjstadig: That's what ack + awk is.

15:00 chouser: Hah, that's my kind of solution

15:00 pjstadig: sure you could use that

15:01 KirinDave: chouser: Reflect on a package in a macro?

15:01 chouser: (import* com.banksimple.accounting.schema) ; THIS IS ABOUT TO HAPPEN.

15:01 kjeldahl: What's the recommended way to force a clojure lein project to use specific versions of jars from another project that I also work on? Symlink into lib?

15:02 hiredman: put the versions you want in the project.clj

15:02 chouser: KirinDave: oh, you really can't name just the short name of the classes you're going to import?

15:02 KirinDave: chouser: ?

15:02 chouser: I'm not sure I understand.

15:02 kjeldahl: hiredman: But the version is under development. If it gets copied into lib, updates will not be catched. Or maybe they will if I add -SNAPSHOT?

15:03 KirinDave: chouser: There are like 30 ORM classes from squeryl in this package. I want them all available for use.

15:03 kjeldahl: (assuming leiningen does things similar to maven...)

15:04 cemerick: KirinDave: I think chouser means (import [package.name ClassName1 …]).

15:04 chouser: KirinDave: I just mean that I really hate reading code that has names dropped into it from no observable place.

15:05 cemerick: and I'm almost certain someone wrote an import* already, posted it to the ML

15:05 hiredman: kjeldahl: look up checkout depedencies in the lein readme

15:05 KirinDave: chouser: Normally I agree.

15:05 kjeldahl: hiredman: Thanks.

15:05 KirinDave: cemerick: I do not read the ml. There is too much mail and not enough me time as it is.

15:05 chouser: perhaps instead of ORMClass1 you could say (mymacroresolver ORMClass1)

15:05 cemerick: chouser: ooh, I'll bookmark that msg of yours for prior art on my arguments against an automatic make-Foo factory fn for records! ;-)

15:06 KirinDave: chouser: I understand that concern. I'm not doing that without reservation.

15:06 chouser: ORM schema mappings are one of the rare cases where I think it makes sense.

15:06 cemerick: KirinDave: Sure, I meant just searching for the topic. It's been around the block a couple dozen times.

15:06 KirinDave: chouser: You probably need all the nouns to make even basic coherent conversations about this.

15:07 dnolen: anybody ever tried to make their own version of Cons?

15:09 cemerick: dnolen: just out of lambdas? Long time ago…

15:09 joshua__: How do I grab the current time in clojure? Sorry for being so noobie.

15:09 cemerick: ,(System/currentTimeMillis)

15:09 clojurebot: 1291147791868

15:09 KirinDave: joshua__: If you're using clj-time you can use (now)

15:09 cemerick: joshua__: ^^

15:10 joshua__: Thanks cemerick!

15:10 KirinDave: joshua__: If you're working with time you probably want to use clj-time, even if it's basic stuff. Java's time support is pretty rudimentary without some helper libraries.

15:10 joshua__: I'm making a rate limiting function so really I'm just looking for something that I can turn into seconds.

15:10 It 'looks' like (System/currentTimeMillis) would be fine for that.

15:11 arohner: KirinDave: OT, but how happy are you using squeryl in clojure? imports aside...

15:11 dnolen: cemerick: no I mean in Clojure. Cons in clojure expects the right hand side to be a seq. I'm interesting in something that allow anything on the right hand side, like Scheme. At the same time I'd like to some aspect of seqs, but I'm wondering what the pitfalls are ...

15:11 KirinDave: arohner: I have no idea.

15:11 dnolen: planning on go over the abstractions in detail of course, but helpful to hear of other experiences.

15:11 cemerick: dnolen: hrm, that's called a dotted pair in CL, right?

15:11 dnolen: cemerick: yup.

15:11 arohner: KirinDave: that sounds like a good blog article, once you've formed an opinion. I'd certainly be interested

15:12 KirinDave: arohner: Yeah.

15:12 cemerick: dnolen: I guess I'd wonder what the advantage would be over just [a b]

15:12 (unless this is an academic exercise)

15:12 * KirinDave grumbles

15:12 dnolen: cemerick: Prolog I believe expects a traditional cons (as does miniKanren)

15:13 chouser: but you don't get the seq abstraction unless you assume the cdr is itself a dotted pair, right?

15:13 KirinDave: People talk about clojure being a difficult peer in cross-language discipline

15:13 chouser: I mean, it doesn't make sense.

15:13 KirinDave: but man is scala unfriendly sometimes

15:13 dnolen: cemerick: this make cons a relationship, allowing relational operators that can "grow" lists

15:13 KirinDave: "Oh sorry, these collections... they are not real"

15:13 dnolen: chouser: In my case I only need to support twoo cases. A logic var or a real Seq.

15:15 cemerick: dnolen: I guess I'd say that if you're looking to do real work with this thing, make a protocol and model it out properly (as opposed to thinking about some specialized concrete impl).

15:16 dnolen: cemerick: that's what I'm doing.

15:16 joshua__: How do I turn a ratio into a decimal?

15:16 chouser: dnolen: (deftype pair [a b] clojure.lang.ISeq (first [_] a) (more [_] b) (next [_] b) (seq [this] this) (equiv [this that] false))

15:16 cemerick: oh; well, then those two cases should be straightforward?

15:16 chouser: (pair. 1 (pair. 2 (pair. 3 nil))) ;=> (1 2 3)

15:16 joshua__: (.Decimal 1232/232)?

15:16 chouser: don't tell rhickey I said that

15:16 * cemerick is probably missing something given low bandwidth on irc.

15:17 joshua__: A double rather

15:17 cemerick: chouser: (equiv [this that] false) << LOL

15:17 whoa, that'll end up as an example for deftype on clojuredocs!

15:17 chouser: equality is hard to get right. that's my best effort.

15:18 tonyl: joshua__: have you try ##(double (/ 12 34))

15:18 sexpbot: ⟹ 0.3529411764705882

15:18 dnolen: chouser: heh, I've already gotten that. that causes - ClassCastException clojure.lang.Symbol cannot be cast to clojure.lang.ISeq

15:18 joshua__: that works thanks

15:18 dnolen: that far.

15:18 joshua__: tonyl: that worked, thanks!

15:19 tonyl: joshua__: np

15:19 chouser: dnolen: because ISeq promises that rest returns an ISeq, but dotted pairs explicitly break that

15:19 so ... what did you want again?

15:19 dnolen: chouser: some thing that can handle some other than nil on right side for the terminator.

15:20 chouser: for example, how should map behave given a chain of dotted pairs that ends with a logic var?

15:20 rhickey: CL is full of special cases and hand-waving due to dotted pairs

15:21 dnolen: chouser: this isn't for maps , or vectors, I've already thought about that. supporting them is intractable.

15:21 rhickey: not worth it

15:21 chouser: so what

15:21 so what "aspect of seqs" are you trying to keep?

15:23 dnolen: a new type LCons which can hold a logic var on the right hand side, which also function properly when printed at the REPL. LCons can be chained together and traversed like seqs. But during unification if we get to a logic var, we can suck in another seq into it's place.

15:24 chouser: but not traversed using map, filter, etc?

15:25 dnolen: you'll be using relational operators, little need for that. LCons is just special kind of sequence for relational operations. Not useful outside.

15:27 mefesto: deftype supports java annotations. does gen-class also?

15:28 dnolen: I hacked something together and realized I need something like LCons to keep it clean, otherwise unification on Prolog style append is bunch of crazy hacks.

15:28 cemerick: mefesto: yes, in the gen-class declaration in ns

15:30 Chousuke: Hmm, IFn specification is pretty scary. :P

15:30 mefesto: cemerick: something like (ns ^{MyAnnotation true} my.namespace) ?

15:31 cemerick: mefesto: I'm not sure off the top of my head whether the class-level annotations can go on the namespace symbol itself or if you need to put it on a :name symbol in the gen-class form

15:31 mefesto: cemerick: or (gen-class :name ^{Blah true} my.class.Name)

15:32 cemerick: ok i'll mess around with it, thanks!

15:32 cemerick: mefesto: the latter is what's demonstrated in the tests, FWIW: https://github.com/clojure/clojure/blob/master/test/clojure/test_clojure/genclass/examples.clj

15:53 dnolen: chouser: well that was helpful, I think I may have figured out a workaround, LCons implements IPair and ISeq. Might be issues with that but at least I can learn along the way. Really this is just so that people can play around with standard miniKanren operators in Clojure.

15:57 * dnolen agrees that dotted pairs are a lot of trouble

16:01 dmart_: I've been trying to find an example of rebinding *in* to a reader, but I'm not having any luck

16:03 fogus`: dnolen: are you unifying with &rest?

16:04 dnolen: fogus`: that's already working and pretty easy.

16:04 fogus`: much harder is (== (cons 'a logic-var) '(a))

16:04 fogus`: dnolen: Then I will probably steal that from you. ;-)

16:05 dnolen: fogus`: :D

16:06 (== (conj logic-var 'a) ['a]) also presents some interesting challenges. == is unify.

16:15 jweiss: I don't understand this lein compile error: https://gist.github.com/722420

16:16 it's complaining about line 1, but something about println?

16:16 clizzin: does clojure have a function that's like python's strip? i.e. if given no arguments, it does what trim does, but if given a string, it will trim not whitespace but the set of characters in the string

16:16 or is this in any contrib package?

16:17 brehaut: ,(.trim " hello ")

16:17 clojurebot: "hello"

16:18 brehaut: str-utils2 in contrib might have a function version?

16:18 dmart_: something like (with-open (clojure.lang.LineNumberingPushbackReader. (java.io.FileReader f)) I guess?

16:18 clizzin: brehaut: no, what i want is something like (trim "abtokenbaa" "ab") -> "token"

16:18 dmart_: hmm

16:18 brehaut: oh right, my bad

16:18 Chousuke: I think String supports a regex replace

16:19 look up the javadoc :)

16:20 mefesto: clizzin: clojure.string/replace might work for you

16:20 clizzin: java has a replace for charsequences, but doesn't allow you to specify that the chars to be replaced must be at the start/end of a string. it also has a replace for regexes, but i was hoping to avoid the hassle of translating a string into a regex for the chars, dealing with escaping and everything.

16:20 mefesto: clizzin: (clojure.string/replace "abtokenbaa" #"a|b" "")

16:21 ah

16:21 clizzin: mefesto: yeah, i'll probably use that and write a function on top of that which translates other structures into a regex

16:21 brehaut: you want to anchor the character set at each end

16:22 tonyl: dmart_: have you tried (binding [*in* my-reader] ...)

16:22 dmart_: tonyl: yeah, I did, but I was using a BufferedReader which wouldn't work

16:22 so it was more the step prior to that

16:22 but I've got that I think

16:22 clizzin: brehaut: what do you mean by anchoring? is it possible to have an object that implements charsequence but also requires being at the start/end of a string?

16:23 brehaut: the example above the regex should be #"^[ab]*|[ab]*$" shouldnt it?

16:23 clizzin: brehaut: yes

16:24 brehaut: hmm, might want groups

16:24 rlb: I noticed that string split suppresses trailing empty fields, but not leading ones -- assuming that's intentional, it might be worth a mention in (doc split).

16:29 mefesto: brehaut: yeah sorry that example wasn't thought through

16:29 brehaut: mefesto: no worries

16:51 raek: I declared autodoc 0.7.1 as a dev-dependency for my project that uses clojure 1.2, and now lein deps tries to download org.clojure:clojure:jar:1.3.0-alpha3...

16:51 what do I do?

16:52 LauJensen: try cake? :)

16:53 cemerick: anyone have a link to Stu H's slides from the conj? #lazyirc

16:53 the google has failed me somehow

16:53 LauJensen: cemerick: the ones on protocols?

16:53 brehaut: cemerick: https://github.com/downloads/stuarthalloway/clojure-presentations/Clojure-Simplicity.pdf ?

16:53 cemerick: brehaut: cheers, thanks :-D

16:54 brehaut: no worries :) i knew AR tagging of links would pay off one day

16:55 freakazoid: AR?

16:55 clojurebot: tar pit is http://web.mac.com/ben_moseley/frp/paper-v1_01.pdf

16:55 brehaut: anal retentive

16:56 freakazoid: damn I thought it was some bookmark service

16:56 brehaut: oh, no sorry

16:56 freakazoid: I haven't found a good bookmark workflow other than chrome bookmarks and instapaper for stuff I want to read later

16:56 brehaut: i havent either, so i built my own

16:57 freakazoid: a searchable, complete, immutable browser history with starring would be sufficient

16:57 i don't even need tagging

16:57 but a full gmail-like interface to it would be awesome

17:00 hiredman: ~delicious

17:00 clojurebot: delicious is http://delicious.com/clojurebot

17:02 freakazoid: eh

17:02 KirinDave: Clojure interop to scala is weird.

17:02 freakazoid: that seems more focused on socialness than usability

17:02 brehaut: hiredman: that is very cool

17:02 KirinDave: Scala interop into clojure? Extra weird.

17:02 freakazoid: I mean, delicious is

17:02 THAT is very cool.

17:04 tonyl: KirinDave: never tried it. now you made me curious

17:06 lancepantz: KirinDave: have any impressions of scala vs clojure so far? is there anything a clojure programmer could get out of it?

17:06 KirinDave: lancepantz: Oh Scala seems very cool

17:06 lancepantz: aside from say, a job :)

17:06 KirinDave: As cool as CLojure, if you're into the world of statically typed programs

17:07 lancepantz: the shootout numbers for scala v clojure v java caught my attention

17:07 joshua__: Wait so clojure can interop to java, but there are other languages on the JVM like python for instance.. so you could interop to python from clojure.. theoretically?

17:07 lancepantz: some have said the clojure wasn't optimal, but what really stuck out is that scala is faster than java on some, albeit very slightly

17:07 brehaut: joshua__: theoretically. clj->jython interop was a bit hairy last time i tried it

17:08 KirinDave: joshua__: Absolutely

17:08 But i think that it's something you have to be very deliberate about

17:08 When i was writing clothesline, I definitely was careful

17:08 lancepantz: joshua__: i've seen examples of jruby and clojure interop that looked relatively clean as well

17:08 KirinDave: to make it scala friendly. For example, no making people rely on thread locals.

17:08 Otherwise the code just gets extremely painful to work with

17:09 God, the web developers I work with are such badasses

17:09 We just launched our new promo site (not live product), and even that they made a badass html5 app

17:09 https://www.banksimple.com/

17:11 joshua__: KirinDave: Which are you in the pictures of the team (6)?

17:12 KirinDave: joshua__: The joke response is "the one with the beard"

17:12 brehaut: KirinDave: complete with the html5 approved museo typeface

17:12 KirinDave: joshua__: The real response is, "The one with the epic sideburns."

17:12 joshua__: (upper right)

17:14 joshua__: KirinDave: =) thanks and yea the site is nice

17:14 KirinDave: joshua__: Part of why I like the site is how crazy they did it.

17:14 For example, that guilloche pattern behind the card?

17:14 It's procedurally generated

17:18 tonyl: that is an awesome website KirinDave. I always get excited about the BankSimple initiative and hopefully soon services

17:18 KirinDave: tonyl: :)

17:19 lancepantz: KirinDave: i imagine you guys are pretty excited about this wikileaks bank of america stuff too :P

17:22 KirinDave: lancepantz: We're ambivalent.

17:22 It's not like suddenly people are going to be more pissed at banks. ;)

17:23 joshua__: What command am I looking for to do a few commands and than return the last thing I do?

17:23 do itself is returning nil =/

17:23 chouser: & (do 1 2 3 4)

17:23 sexpbot: ⟹ 4

17:24 lancepantz: very true

17:26 dale: cemerick: You around? I wanted to give you a heads up that I was taking a swing at implementing the SLIME (Swank) protocol atop nREPL.

17:28 cemerick: dale: I am, but only for another 5 minutes.

17:28 dale: That's great though. I am at your disposal to answer questions and make changes to nREPL if necessary to ease the way.

17:29 dale: cemerick: No worries, just wanted to put it on your radar. Hugo Duncan was doing some work on swank-clojure but I gather that tapered off as he realized nREPL had more momentum.

17:30 cemerick: I've been meaning to claim a spot on dev.clojure.org's confluence for nREPL, so having some external collaborators will make that happen finally. :-)

17:30 dale: cemerick: I'm just getting started but only modifications I've made so far are breaking nrepl/read- and write-message out as arguments in a few places. I'm hoping that nREPL and swank-clojure are similar enough that I can just swap out the protocol (then implement/copy all the Swank backend functions).

17:31 cemerick: dale: I'm not sure that nREPL should necessarily impact hugod's swank-clojure work, at least not yet ;-)

17:31 in any case, yes, I hope that they're fundamentally similar enough

17:32 or, rather, that nREPL's protocol is simple enough to effectively superset what swank provides

17:32 dale: cemerick: At some point I'll push my nREPL changes up to Github for your review. Is that OK?

17:41 technomancy: dale: good to hear you're tackling this; I can try to help if you have swank questions, though I'm not actually that familiar with the codebase.

17:42 cemerick: dale: that's fine for review -- just make sure you have a CA lodged so I can take your patches

17:45 dale: cemerick: Ooh, OK, didn't think of that.

17:45 technomancy: Cool, thanks.

18:48 seancorfield: cemerick: do you know who approves clojure-dev group membership?

18:49 cemerick: seancorfield: I think rhickey and chouser are the admins on the lists?

18:49 seancorfield: 'k thanx... i applied ages ago and i'm still pending :(

18:49 cemerick: surely an oversight :-(

18:50 seancorfield: but rhickey has my CA and i'm listed on the contributors page (although my surname is misspelt with an 'n') so most of the process has gone thru :)

19:02 rhickey: seancorfield: you should be all set now

19:50 seancorfield: thanx rhickey !!

20:19 technomancy: ,(= 4)

20:19 clojurebot: true

20:20 technomancy: thanks, clojurebot.

20:26 Lajla: &(=)

20:26 sexpbot: java.lang.IllegalArgumentException: Wrong number of args (0) passed to: core$-EQ-

20:26 Lajla: Hmm

Logging service provided by n01se.net