#clojure log - Jun 05 2010

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

0:21 lancepantz: does anyone know how you would go about creating an ant task that launches a repl?

0:22 i expect to be able to use the Java task, but jline.ConsoleRunner as my class with the clojure.main argument

0:22 i can get a repl task, but it just exits after showing the prompt

0:23 tomoj: is there a good reason we can't make protocols which 'extends' interfaces?

0:23 maybe that doesn't make any sense

0:25 I was thinking I wanted implementers of my protocol to be required to implement Seqable

0:48 defn: http://uwnews.org/article.asp?articleID=45255

0:48 woops

1:37 _brian2_: noob question > trying to use contrib string utils, this doesn't work -> (require '[clojure.contrib.string :as s]) , java.io.FileNotFoundException

2:20 defn: noob mistake: leaving the channel before you get an answer

3:27 i have a serialized structure that i want to allow people to query with JSON or something -- id like to create an API i suppose

6:24 bsteuber: I've got a weird issue while trying a non-ELPA swank setup

6:24 everything works without errors in

6:24 *inferior-lisp

6:24 *

6:24 argh

6:24 but still, I don't get a *slime-REPL* buffer

6:24 any ideas?

6:59 kensanata: Hi all. I'm a Clojure & Swing newbie and I have trouble writing a MouseListener for my app. Its mouseClicked method appears to not get called. What's wrong with my (proxy [JFrame MouseListener] (mouseClicked [e] (println e)))? My 37 line app is here: http://www.emacswiki.org/alex/2010-06-05_Clojure_Mouse_Listener

7:05 Chousuke: are you using slime or something?

7:05 the output might go to the *inferior-lisp* buffer

7:06 but hm, shouldn't you normally do listeners by using the .addListener method for frames etc?

7:06 _mst: kensanata: I think the only thing you're missing is that your MouseListener won't do anything until you register it with the jframe

7:06 Licenser: kensanata: for me it sounds odd to proxy a frame and a listener in one thing

7:06 _mst: yep, that :)

7:07 Licenser: <advertisement>look at clj-swing for how do do swing & clojure it has grown quite a bit now :) </advertisement note="It is open source so don't worry">

7:08 kensanata: Hehe

7:08 Licenser: kensanata: you might actually enjoy clj-swing a lot :) I gladly support you with it to when I'm around since having someone use the library is the best way to get the edges off it

7:09 Chousuke: Licenser: don't attributes go into the opening tag? :P

7:09 Licenser: Chousuke: that is XML 2.0 :P

7:09 kensanata: Ok, I'll try using addListener. I got the idea from http://java.ociweb.com/mark/clojure/article.html#DesktopApps where they use an ActionListener.

7:09 _mst: reverse polish xml ;)

7:10 Licenser: also since when do I care for well working XML, I hate it just the same, next time I'll use clojure syntax [:advertisement {:note "It's open sourece"} "..."]

7:10 kensanata: Licenser: I'll take a look at clj-swing once I have the very basics. :)

7:11 Licenser: kensanata: cool just drop me a query here my PC is usually on even if I'm not and I'll get back to you. Also if you got some stuff done I'll gladly look over your stuff and see how to best encoperate it with clj-swing (since it is by far not done)

7:12 kensanata: Licenser: Hehe, just read your README on github. I had to get rid of Stuart Sierra's macro because it didn't work for what I needed and I didn't know how to adapt it.

7:12 Licenser: kensanata: well it was just a base, mine can do a bit more by now :P

7:29 nirly: how can I write a string as unicode data into a file?

7:33 Chousuke: I'm not sure what you mean with "unicode data", but http://java.sun.com/javase/6/docs/api/java/io/FileWriter.html should help

7:35 It seems you'll need to use an OutputStreamWriter directly if you want to specify the encoding though.

7:36 kensanata: Thank you to all that suggested the addFooListener. It turned out that I needed a MouseListener because addActionListener did not exist; and it turned out that I needed to implement the entire interface, ie. (proxy [MouseListener] [] (mouseClicked [e] (edit-grid e)) (mouseEntered [e]) (mouseExited [e]) (mousePressed [e]) (mouseReleased [e])) -- but now it works. :)

7:50 raek: strings in java (and thus in clojure) are sequences of unicode characters (not bytes)

7:51 OutputStream and InputStream are abstract classes for writing and reading streams of bytes

7:51 OutputStreamWriter and InputStreamWriter are abstract classes for writing and reading streams of characters

7:52 when you open a file, you get a FileOutputStream

7:53 (correction: *Writer are not abstract classes)

7:54 the constructor of OutputStreamWriter takes an OutputStream and the name of the character encoding (character to byte mapping)

7:55 if you want to be able to encode all unicode characters, you'll need to use an encoding in the UTF family

7:56 UTF-8 is convenient, since it's backwards compatible with ASCII (that is, all bytes with a zero in the 8th bit are ASCII)

7:57 ISO 8859-1 is less good, because it can only code the first 256 characters, unlike UTF-8 which can code more than 100000 characters

7:59 hope this was useful... :)

8:01 Lajla: ,(car ''x)

8:01 clojurebot: java.lang.Exception: Unable to resolve symbol: car in this context

8:02 Lajla: ,(car (list 1 2 3))

8:02 clojurebot: java.lang.Exception: Unable to resolve symbol: car in this context

8:02 Lajla: So, if I get this straight, clojure has no car and cdr?

8:02 Ohhh, first.

8:02 ,(first ''x)

8:02 clojurebot: quote

8:02 Lajla: Yeah

8:03 raek: :)

8:03 Lajla: WAs just checkin', bro.

8:03 I think first, second, third et cetera are ugly names for car, cadr et cetera.

8:04 I personally use ((string->accessor "caddddddddr") lst)

8:05 nirly: thanks raek, Chousuke

8:06 raek: (first (drop 8 lst))

8:06 pretty readable too, IMHO

8:07 Chousuke: "ugly" :P

8:07 at least they're descriptive

8:07 raek: or simply (nth lst 7)

8:09 s/7/8/

8:09 sexpbot: or simply (nth lst 8)

8:16 Lajla: Chousuke, I think caaddaadr like combinations are much more descriptive.

8:16 At least, don't know about clojure, but in most lisps, 'fourth' is really just a composition of car, cdr, cdr, cdr.

8:16 Ehh + cdr.

8:16 Licenser: yea but what if you don#t have a drivers licens and can't use car?

8:17 Lajla: And applying fourth to a three element list will result into a cdr-based error.

8:17 Chousuke: Lajla: I can

8:17 Lajla: Also, what if you apply cadddr to a binary tree that is not a list, but an even branched tree?

8:17 Chousuke: Lajla: I can't even read that

8:18 Lajla: the combinations of cdr and car are not descriptive in the least unless you've actually learned to read them

8:18 Lajla: Names like 'fourth' are only 'descriptive' for one of the most common conceptual uses of using car and cdr.

8:18 Licenser: I think it is good that clojure uses first, next, rest pposite to c[ad]+r

8:18 Lajla: Chousuke, well, they describe transparently the operation you perform.

8:18 Chousuke: whenever I see something like that I need to think what it means.

8:18 Licenser: Lajla: on lists yes on vectors no

8:19 Chousuke: whereas first and second are immediately obvious

8:19 raek: mustn't the cdr part of a cons be a sequence in clojure?

8:19 Licenser: nth too

8:19 raek: ,(cons :a :b)

8:19 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword

8:19 Lajla: Chousuke, well, maybe you think too much in 'ists' and not enough in 'right branching pairs that end on ()'

8:19 Chousuke: I don't understand that at all.

8:19 how does the structure of the list matter?

8:19 it's still a lsit

8:19 list

8:20 Lajla: Chousuke, well, lists are ad hoc in lisp.

8:20 THey aren't primitives.

8:20 THey're constructed from pairs and ().

8:20 Chousuke: yes, but they're still lists.

8:20 Lajla: Chousuke, they're lists the same way a struct in C that can be used to model a date is a 'date'.

8:20 It's ad hoc.

8:20 Chousuke: the cdr/car thing is a vestigial leftover from the early days

8:21 Lajla: Well, first and second would work just as well.

8:21 Chousuke: it makes no sense unless you're actually already used to it.

8:21 Lajla: But car and cdr can be easily composed unto each other in a simple readable form.

8:21 raek: (get-in [[[:a :b] [:c :d]] [[:e :f] [:g :h]]] [0 1 0])

8:21 ,(get-in [[[:a :b] [:c :d]] [[:e :f] [:g :h]]] [0 1 0])

8:21 clojurebot: :c

8:21 Licenser: Lajla: I don't agree, caaddaadr is not readable :P

8:21 Lajla: Well, it makes sense if you see lists for what they are, pairs composed unto each other.

8:21 Chousuke: that's the thing, I don't consider them readable at all :P

8:21 Lajla: All you then need to know is that car revers to the first element in a pair, and cdr to the second.

8:22 Chousuke, well, I guess you see a list as 'an ordered collection of data' uppose to 'a nesting of pairs'

8:22 Licenser: caaddaadr looks like a klingon war cry to me

8:22 hoeck: Lajla: note that there is ffirst and fnext too in clojure )

8:22 Licenser: Lajla: but aren't lists (at least in clojure) ordered collections of data?

8:22 Lajla: It looks like 'get the first of the first of the second of the second of the first of the first of the second element of a pair' for me.

8:23 licenser, I think clojure does not implement lists as lisps traditionally do no, targeting the JVM and all.

8:23 Traditionally in lisp, lists were just 'a binary tree'

8:23 The one restriction is that the rightmost leave is '().

8:23 Licenser: Lajla: point is, while I can imagine caaddaadr is quite effective for a versatile lisp programmer, forst, second, nth and friends make it easyer for the rest of the world

8:24 what I like in clojure is that it lowers the entry level to a lisp dialect to a place where it is acutally woth to get used to all the oddness of prefix notation and lists

8:24 Lajla: (((a . b) . 3) . ( a . ( ( x . y) . (2 . () ) ) ) is a list.

8:24 licenser, well I guess clojure puts more emphasis on the functional programming that scheme brought to lisp.

8:25 while the defining feature of most lisps is still the interchangeability of code and data.

8:25 And that your program IS such a binary tree.

8:25 Licenser: as far as I understood that works great in clojure too

8:25 Chousuke: I've rarely had a need for anything more complex than a caddr maybe

8:25 Licenser: you're justnot forced to write caaddaadr

8:26 Lajla: Well, I sometimes see myself using ((string->accessor "caaddaadr") ... ) in liue of ((compose car car cdr cdr car car cdr) ... ) because it's shorted.

8:26 But I guess in clojure, one doesn't use homo-iconicity that much.

8:26 Chousuke: huh?

8:26 Lajla: The fact that source code is not static, but dynamic.

8:26 Chousuke: it's used all the time :P

8:27 Lajla: Chousuke, how?

8:27 Chousuke: um, in every macro?

8:27 Licenser: Lajla: you can easiely write a function that is shorter then string->accessor

8:27 Lajla: In homo-iconicity, you'll find yourself dissassembling and assembling your source code a lot with car and cdr.

8:27 Chousuke: nah

8:27 Lajla: licenser what do you eman?

8:27 Chousuke, also, macros are static, not dynamic.

8:27 Licenser: Lajla: if you want string->accessor

8:28 you can write it yourself

8:28 Lajla: They are performed at compile time.

8:28 licenser, that function have written myself.

8:28 Licenser: ah

8:28 Lajla: you can use a macro too

8:28 Lajla: It takes a string of the form c[ad]+r and produces an accessor.

8:29 Licenser: *nods* as saied you can do that in clojure too ;)

8:29 just replace car with first and cdr with second

8:29 Chousuke: Lajla: when do you actually modify code at runtime in lisp?

8:30 Lajla: licenser, ah, there you're wrong.

8:30 second is cadr.

8:30 Chousuke: Lajla: that's very rare

8:30 Licenser: ah well what is cdr then?

8:30 Lajla: Chousuke, no, that's lisp.

8:30 licenser, cdr applies on pairs.

8:30 Chousuke: I have to disagree

8:30 I've never seen it

8:30 Lajla: It's rest, when done on lists, though.

8:30 Chousuke, what do you think CLOS does all the time?

8:31 It changes the state of objects by manipulating their code.

8:31 Licenser: well Lajla I still think yo can do the same in clojure I just don't understand what you do :P

8:31 Lajla: licenser, well a pair is not a list of two elements.

8:31 A list of two elements is a pair (a . (b . () )

8:32 A list (a b c d) is (a . (b . (c . (d . () ) ) ) ), you know that, right?

8:32 Car accesses the first element of a pair, cdr the second, not of a list.

8:32 Licenser: yes I can imagine that

8:32 ah so cdr is rest (next) and car is first?

8:33 Lajla: Which of course means that cdr also accesses the conceptual 'rest' of a list. The main differences is that car and cdr are mainly operations on pairs, not on lists, lists are just composed of pairs.

8:33 licenser, yeah, that's the general idea.

8:33 Chousuke: Lajla: I don't think mutating code is what makes lisp what it is. :P

8:34 Lajla: a CLOS-like system would be possible to create with immutable data as well

8:34 Lajla: Except that car and cdr are shorter, and cadadr like compositions can't easily be made from 'first' and 'rest' that are also that easy to read.

8:34 Chousuke, well, why hasn't it then?

8:34 CLOS is easily the most powerful object system around.

8:34 Chousuke: Lajla: because no-one actually wants objects :P

8:34 Lajla: Chousuke, you think it's a coincidence that lisps object system is that powerful?

8:35 Chousuke: they're all about encapsulating mutable state and that's not very clojurey

8:35 Lajla: Lisp was the first, and still the only significant homo-iconic language, and an instigator for many things that found their way into other languages that just follow from lisps homo-iconicity.

8:35 Licenser: so (map #(get {\a first \d next} %) (second (re-find #"^c([da]+)r" string-stuff))) something like that?

8:35 Chousuke: Bu Clojure is homoiconic too, being a lisp :/

8:35 Lajla: Chousuke, yap, I can imagine that. But that's also while clojure is not that homo-iconic, your program is data and can manipulate itself.

8:36 Chousuke, sure, but it favours a more functional style.

8:36 Though, a limited form of homo-iconicity is the apply operator of course.

8:36 but, how would you define the factorial function?

8:36 Chousuke: see, that's what I don't get. How is homoiconicity in clojure "limited" in any way?

8:37 Lajla: Chousuke, I never said it was.

8:37 I mean, it's all possible, I'm just saying it was more designed towards a functional style.

8:37 Chousuke: That's true.

8:37 I guess I don't see what your point is, anymore :P

8:38 Lajla: Chousuke, but would you define the factorial the typical way with if or would you use (apply * (cons 1 (range 2 n)))

8:38 Chousuke: either would work? :/

8:38 Lajla: Chousuke, sure, but that one is charactaristically lisp like, and a lot more performance efficient.

8:47 Borkdude: Is there something like this already in core/contrib? (defn update-map [m f & args]

8:47 (reduce #(apply update-in %1 (vector %2) f args) m (keys m)))

8:47 so you can do: (update-map {:a 1 :b 2} inc) => {:a 2 :b 3} ?

8:49 or: (update-map {:a 1 :b 2} + 2), {:a 3, :b 4}

8:50 or is this how you would use zipmap?

8:50 Licenser: hmm Borkdude I have a function that I think would allow that

8:51 http://github.com/Licenser/clj-sandbox/blob/master/src/net/licenser/sandbox.clj#L14 look at that perhaps it helps you

8:51 Borkdude: (zipmap (keys m) (map inc (vals m))) would also work maybe

8:53 Licenser: tnx

8:54 Licenser: but it might not be what you want but it might help ;)

8:54 Borkdude: Licenser: can you give an example of how you would use it on a simple map?

8:55 Licenser: hmm http://github.com/Licenser/clj-sandbox/blob/master/src/net/licenser/sandbox.clj#L103

8:55 it replaces . in code with dot

8:57 do you want this to be nested?

8:58 Borkdude: Licenser: actually what I was simply searching for was a map that worked on map values

8:58 non-recursive

8:59 Licenser: ah okay then just use map?

8:59 Borkdude: Licenser: you mean with zipmap?

8:59 Licenser: no map map

8:59 or reduce, even easier

9:01 (defn hash-map-map [f m] (reduce (fn [r [k v]] (assoc r k (f v))) {} m))

9:02 do you want it map like or update like?

9:03 because map won't take + 2

9:03 Borkdude: Licenser: that hashmap-map looks fine

9:03 and I could improve it to take some args

9:04 Licenser: (update-map {\a 1 \b 2 \c 3 \d 4} + 2) works with (defn update-map [m f & args] (reduce (fn [r [k v]] (assoc r k (apply f v args))) {} m))

9:05 kotarak: (zipmap (keys m) (map #(apply f %1 args) (vals m)))

9:05 Borkdude: Licenser: that's ok enough. now let me check how that destructuring works

9:06 Licenser: ^^

9:07 Borkdude: kotarak: I also thought of that one, maybe it also would be more efficient?

9:08 kotarak: Borkdude: dunno

9:09 I would expect reduce to be faster due to InternalReduce. But maybe zipmap works similar internally? ...

9:12 Borkdude: ,(letfn [f [x [y z]] (+ x y z)] (f 1 [2 3]))

9:12 clojurebot: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol

9:14 Borkdude: ,(letfn [(f [x [y z]] (+ x y z))] (f 1 [2 3]))

9:14 clojurebot: 6

9:15 Borkdude: wouldn't it be an idea to leave outer parens out... it seems like overkill to me ;)

9:15 kotarak: Where? in letfn?

9:17 candera: Perhaps the issue is how one would bind more than one function at a time.

9:18 Borkdude: candera: it's triples, name args and body

9:18 candera: Body can be more than one expression, yes?

9:19 Borkdude: hmhm.. makes sense

9:19 candera: I mean, I'm with you: I thought the extra grouping looks weird. But Rich is smarter than I am. :)

10:16 lypanov: any interest in riak from clojure community?

10:17 or translation: anyone know of any libraries?

10:21 Borkdude: Does dotrace support recursive functions

10:23 Or maybe Clojure 1.2 does some secret optimization with recursion?

10:25 This only shows one call of my function: http://gist.github.com/426665

10:27 gtg... maybe later

11:30 arkh: anyone know off the top of their head how to take from a lazy sequence until you read nil ?

11:33 shoover: arkh: check out take-while. you can pass identity as the pred

11:34 arkh: shoover: excellent, thank you

12:35 replaca: lypanov: I know the sonian guys (like technomancy and tim dysinger) are using Riak extensively

12:37 lypanov: replaca: ah, awesome. will ping them to see what they're using whenever i get the time to transition to clojure.

12:37 (

12:37 (stuck on ruby)

13:24 secleinteer: hi, are there any arch linux users here? i've been trying to set up clojure on arch, and i'm having issues with both the 'clojure' and 'clojure-git' PKGBUILDs in the AUR

13:24 i asked in #archlinux, but no one could help

13:32 Jevgeni: hi, is it possible not to print namespaces when using macroexpand?

13:33 bsteuber: Jevgeni: namespaces are already there after reading in the code

13:34 so the answer is: only by walking the code yourself

13:34 Jevgeni: bsteuber: what do you mean by walking the code myself?

13:36 bsteuber: (maybe the statement with read is wrong, though)

13:36 well

13:36 you could iterate over the code yourself and just read the name of each symbol

13:36 ,`defn

13:36 clojurebot: clojure.core/defn

13:37 bsteuber: ,(name `defn)

13:37 clojurebot: "defn"

13:37 Jevgeni: ok, just stripping the part after /

13:37 ahha, I see, thanks

13:42 stuarthalloway: ,`~'defn

13:42 clojurebot: defn

14:32 secleinteer: hi, can anyone help me out, i can't get clojure to work

14:32 i'm getting "Could not find the main class: clojure.main. Program will exit." on a hello world

14:33 hamza: probably clojure.jar is not on your classpath

14:33 jdmmmmm: How are you attempting to invoke clojure? Could you paste the script in a pastie?

14:34 secleinteer: jdmmmmm: i'm running arch linux. i'm using the 'clojure' PKGBUILD from AUR. when i manually downloaded and installed clojure, it worked fine

14:34 i'll pastebin the bash script

14:35 nvm, it's available from the AUR: http://aur.archlinux.org/packages/clojure/clojure/clj

14:36 jdmmmmm: Does this mean the problem is gone or that you don't need a pastebin?

14:38 One idea is to just run the following and see if those env variables get set up properly: source /etc/profile

14:40 secleinteer: jdmmmmm: source /etc/profile did it, thanks a lot!

14:40 jdmmmmm: secleinteer: np

14:44 bartj: I am quite a code-style zealot but, I am finding following the Lisp code style mentioned here (http://mumble.net/~campbell/scheme/style.txt) extremely unclear

14:44 any pointers?

14:45 secleinteer: jdmmmmm: should i add "source /etc/profile" to ~/.bashrc to have it always run?

14:48 bartj: "Rationale: The parentheses grow lonely if their closing brackets are all kept separated and segregated." <-- are you sure this is supposed to be taken seriously :/

14:49 jdmmmmm: secleinteer: No, whenever you start a shell "source /etc/profile" will be implicitly run. Wwhen files are added/modified in /etc/profile.d/, (which is what I assume happens in arch linux) you'll may to run that on currently open shell windows. A newly opened shell window should work fine.

14:49 secleinteer: jdmmmmm: it didn't work for me, that was the problem

14:49 i had to explicitly add 'source /etc/profile' to .bashrc

14:49 the files are indeed in /etc/profile.d/

14:51 jdmmmmm: secleinteer: Maybe you need to log out and log back in? If that doesn't do the trick, then I think your linux config is broken.

14:51 secleinteer: jdmmmmm: i logged out and in already as well

14:52 it must be something to do with my config files

14:52 i just created a new user and it works fine under that user

14:53 jdmmmmm: secleinteer: I would post something on the arch linux forums explaining the problem. That behavior is counter to other distros I've worked with. That said, I've never used arch.

14:53 secleinteer: ok

14:53 bartj: secleinteer: I thought that was to be taken with a huge pinch of salt? :)

14:53 secleinteer: bartj: haha ok

14:54 jdmmmmm: secleinteer: I think this may explain the problem: http://bbs.archlinux.org/viewtopic.php?id=64364

14:56 secleinteer: jdmmmmm: ok, thanks for the link

14:57 i've distrohopped a lot, and never cleaned out my config files, so there's probably a lot of crap built up

14:57 bartj: can anyone help me with indenting code on emacs (a complete emacs n00b here)

14:58 from the above link: Run `C-M-q'(indent-sexp) on any code to ensure that it is indented correctly

14:58 I mean Clojure code of course

14:59 when I press Control and Alt and q character as mentioned above,

14:59 I get C-M-q is undefined

14:59 what gives?

14:59 jdmmmmm: bartj: I use indent-region: C-M-\

15:00 First, you can mark-whole-buffer: C-x h

15:01 Then, intent-region and everything in the buffer is indented.

15:04 bartj: jdmmmmm: when I do C-x h , I get a mark set ->possibly indicating that the buffer start position is recorded

15:04 how do I indicate that the buffer end position?

15:04 go to the close bracket and indicate it? if yes, how?

15:05 jdmmmmm: Do you have transient-mark-mode on? If you did you would see the whole buffer is "highlighted"

15:07 bartj: not sure...how to do I have it on?

15:08 jdmmmmm: Let's move to a private chat if possible. It's beyond the scope of clojure.

15:09 hsjunnesson: I have a hierarchical collection of java objects I want to turn into a map. Some of these java objects responds to .getChildren. I then want to extract a few values on each node in the tree such as the class of the object.

15:10 Can someone point me in the right direction here, I was looking at zippers, and I can create a zipper which maps to the java hierarchy fine but I don't really get how to recursively construct a new map from that.

15:22 lpetit: stuarthalloway: hello, do you know whether the second patch of cgrand in issue #358 has been applied to master ? I think not, but I may have overlooked my clojure commits inbo

15:22 x

15:23 stuarthalloway: waiting Rich's review, should be applied by Monday

15:23 lpetit: stuarthalloway: ok, great thanks !

15:43 neoashaman: Hi, I'm trying to learn clojure - but am having some trouble with leiningen. Given the minimal project.clj (that only introduces dependencies on clojure and clojure-contrib) I get a huge backtrace when trying to do 'lein deps'

15:43 See: http://gist.github.com/426936

15:44 Anyone know what I'm doing wrong?

15:46 Raynes: That's weird.

15:47 neoashaman: Indeed

15:48 Raynes: Looks like it can't find the 1.1.0 jar.

15:49 neoashaman: Yep, but the repo it says it's looking in (http://build.clojure.org/releases) appears to contain it, which is why I'm confused

15:49 I've tried both the leiningen I can get from 'macports' and the standalone script, with the same results

17:05 cschreiner: neoashaman: sudo?

17:18 hiredman: http://www.infoq.com/presentations/Towards-a-Universal-VM <-- "just do waht rich says"

17:59 arkh: that's a cool video - is there anywhere Rich's JVM thoughts/wishes have been recorded?

18:01 one thing I've heard him say is he doesn't want them to change a thing (in the JVM) because "everything works" right now, but I'm sure there'd be some things to take advantage of with tail call optimization, other invokedynamic stuff, etc.

18:02 (Rich's statement about a desire for no change being somewhat tongue-in-cheek, then)

18:08 dsantiago: Here's an ancient email where he says Clojure will implement TCO when the JVM has it. http://osdir.com/ml/java.clojure.user/2008-08/msg00225.html

18:17 arkh: the choice quote hiredman pointed out re: Rich in the above url is at 00:43:00 (43 minutes) into the video ;-)

18:21 dsantiago: thanks

18:21 dsantiago: Sure.

18:21 Who knows if that's changed or anything.

18:21 The guy in that video says at one point that tail calls will probably make it into the JVM.

18:24 arkh: yeah, pretty cool. In fact, the whole idea of having the JVM truly accommodate non-Java languages (not just superficially) and the mechanics involved is a world I didn't know about before

18:28 hiredman: he's mentioned fixnums a few times

18:29 a lot of benchmarks are numeric in nature, so most dynamic languages on the jvm would do better on benchmarks if they had fixnums

18:29 * arkh googles fixnum ...

18:31 arkh: nice (fixnum) [ http://bit.ly/d62Lfl ]

18:33 hiredman: http://blogs.sun.com/jrose/entry/fixnums_in_the_vm

18:39 arkh: if a cpu runs 64-bit, is it still important for "headerless objects" to fit in a single machine word of 32bits?

18:39 sorry, nvm. The article gets to that ...

18:52 hiredman: thanks! great article

19:08 Lajla: TWEY

19:08 Twey: o/


19:09 Sulla on vain haskel, lisp on minun, itse on minun.

19:10 Twey: No, I claim them all.

19:10 :)

19:11 Lajla: Twey, to be honest, I'm less enthusiastic about closure than I originally was.

19:12 A lot of things are strange to me in the end, such as that (set "abcde

19:12 ")

19:12 returns a set of five characters.

19:12 tetron: makes sense to me ;-)

19:12 Lajla: Also, licenser here actually didn't know what the difference between second and cdr was. =(

19:13 They think in 'lists' here, not in 'binary trees of cons cells'.

19:16 tetron: I haven't gotten very far with clojure, but one key realization I had was that it isn't a intended to be a pure language, it is a pragmatic language, which means among other things you tend to use the java standard librray a lot for bread-and-butter operatinons like string manipulation

19:17 _brian2_: Hi, I'm trying to use print-dup to write a lazy sequence of clojure types (clojure.lang.PersistentArrayMap) , but seems to fail http://www.clojure.pastebin.com/YgM9xVfr

19:19 Lajla : could you explain t a beginner why that makes a difference?

19:20 Lajla: _brian2_, well, (second x) is identical to (car (cdr x))

19:20 That's all.

19:20 cdr accesses the second item of a pair.

19:20 A pair is different from a list of two elements.

19:20 A list (a b) is (a . (b . ()))

19:22 _brian2_: I take it thats more how lisp people think?

19:22 Lajla: _brian2_, I thought so, until today.

19:22 _brian2_, clojure seems to treat a list a 'just an ordered colletion of elements'

19:23 I personally use things like cadadr, short for (car (cdr (car (cdr ...

19:23 THey use second, or third.

19:23 I realize today that they think in reverse, they think 'I have to get the fourth element of the list, hmm, let's think, that would be the car of the cdr of the cdr of the cdr'

19:24 I'm more 'I have to get the car of the cdr of the cdr of the cdr of the pair, hmm, that would be uuhhmm, the fourth element of the list.'

19:24 tetron: well, clojure treats lists as a particular type of sequence, most things operate on sequences instead of lists

19:24 raek: the sequence library, which is a big part of clojure, assumes car=first and cdr=rest

19:25 of what I have seen, the binary tree usage is simply not very common

19:25 in clojure, that is

19:25 hoeck: ,(nnext [1 2 3])

19:25 clojurebot: (3)

19:25 Lajla: raek, yap, but in Scheme it is.

19:25 I find myself using (cddaar x) a lot.

19:26 So deep does it go at times that I've written a string->accessor function so that I can (string->accessor "cddaadddaaddadadaar") to get

19:26 the right composition

19:26 Raynes: I think cdr is 'next', not rest.

19:26 I think that's what The Joy of Clojure told me, anyway.

19:27 raek: hrm, yes. that's probably more accurate.

19:28 in clojure, there's more data structures to choose from

19:28 tetron: Lajla: using constructions like (cddaadddaaddadadaar x) seems unmaintainable

19:28 Lajla: raek, quite true, so to adress all this, naturally, I'm designing my own langauge.

19:28 raek: so one could use vectors of size 2 as pairs

19:28 Lajla: tetron, well, that one is extremely deep.

19:28 But readable.

19:28 Just pay attention to the d's and the a's.

19:28 a is first, d is second.

19:28 tetron: also clojure has destructuring which is relatively clearer

19:29 Lajla: of pairs, that is.

19:29 ceptorial: is anyone using viper mode with emacs? i have (setq viper-mode t) in my init.el but anytime i start the repl or do debugging it switches back to emacs mode. does anyone know how to permanently turn on viper mode across all buffers?

19:29 Lajla: raek, well, the idea is that lisp syntax itself is made up of pairs and '()

19:29 _brian2_: Any congomongo users out there who can tell me how to save a collection to a file and read into a clojure program?

19:30 hiredman: clojure doesn't have (exposed) pairs

19:30 e.g. cons doesn't return a pair

19:30 Lajla: hiredman, well, I guess.

19:30 same in haskell.

19:31 This is one of the reasons I decided not to switch to clojure, despite it being promising at first.

19:31 But encorporate the good parts into my own design.

19:31 hiredman: Lajla: so why are you here?

19:31 Lajla: hiredman, well A: helping people. B: checking if twey didn't follow me. C: off topic. D: talking finnish. E: autojoin, actually, it was THAT promising.

19:32 hiredman, I have actually amassed some clojure knowledge while I tried to learn it.

19:32 hiredman: helping people?

19:33 Twey: Lajla: cdr is called ‘rest’

19:33 Lajla: hiredman, sure, when people join and ask some things that even I know.

19:33 Twey, next actually.

19:33 hiredman: all I see is evidence of D

19:33 _brian2_: hiredman : I think it might be good to have people with different points of view

19:33 Lajla: But there are no pairs, they only work on lists.

19:33 hiredman: it's fine, it's just annoying to have someone going on and on about caddadaddaadr

19:34 Twey: Lajla: What's the difference between ‘rest’ and ‘next’, then?

19:34 Lajla: hiredman, well, I did already explain the difference between cdr and second to some-one, that's a real pitfall to people trying to work with linked lists, many don't realize at first that a pair is different from a list of two elements.

19:34 Twey: Lack of car/cdr creeps me out a bit, too :þ

19:34 Lajla: Twey, that rest doesn't exist, I think.

19:34 Or let me see

19:34 hiredman: ,(doc rest)

19:34 clojurebot: "([coll]); Returns a possibly empty seq of the items after the first. Calls seq on its argument."

19:34 Lajla: ,(rest '( 1 2 3))

19:34 clojurebot: (2 3)

19:34 Lajla: Ahh, okay, alias.

19:34 Twey: Ooh, bot.

19:34 Lajla: I learnt it with next

19:34 hiredman: no

19:34 Lajla: Yeah, but.

19:34 Twey: ,(doc next)

19:34 clojurebot: "([coll]); Returns a seq of the items after the first. Calls seq on its argument. If there are no more items, returns nil."

19:34 tetron: ,(doc next)

19:34 clojurebot: "([coll]); Returns a seq of the items after the first. Calls seq on its argument. If there are no more items, returns nil."

19:34 hiredman: next is not the same as rest

19:34 Twey: Somewhat different

19:34 Lajla: Yeah, I see.

19:35 next is truly cdr, except that pairs don't exist.

19:35 Twey: ,(next '(1))

19:35 clojurebot: nil

19:35 Twey: ,(rest '(1))

19:35 clojurebot: ()

19:35 Lajla: Or ehh

19:35 rest is cdr.

19:35 Twey: They can both be said to be cdr

19:35 raek: I think the motivation for rest/next is lazy sequences

19:35 Lajla: nil is different from ()

19:35 Twey: Because () isn't nil, yeah

19:35 Lajla: Twey, nil is null.

19:35 void

19:35 A thing I took over to my own design, I like it.

19:36 hiredman: before rich made seqs lazier than they used to be, there used to be no such thing as an empty seq

19:36 raek: rest yields something that might not have decided if it's gonna be nil or not

19:36 hiredman: there were seqs with things in them, and there was nil

19:36 raek: calling seq on it forces it to make up its mind

19:37 (next sequence) is equal to (seq (rest sequence))

19:38 Twey: ,(seq (rest '(1)))

19:38 clojurebot: nil

19:38 Twey: Interesting

19:38 So you consider () to be a sort of future?

19:38 hiredman: no

19:38 but it might not be

19:39 if you have X and X is a lazyseq

19:39 raek: first and rest operate on various implementations

19:39 conses is one of them

19:40 hiredman: ,(cons 1 2) ;in, say, scheme, this would return (1 . 2)

19:40 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer

19:40 tetron: well there is a difference between () [] {} and nil, which isn't the case in classic lisp since you only have () as a first class type

19:40 Twey: Hmmm

19:40 Lajla:

19:40 hiredman: tetron: classic lisp?

19:40 Twey: ,(cons 1 (cons 2 nil))

19:40 clojurebot: (1 2)

19:41 raek: ,(lazy-seq (if (zero? (rand-int 2)) nil (list :foo)))

19:41 tetron: I'm thinking common lisp

19:41 clojurebot: (:foo)

19:41 raek: (lazy-seq (if (zero? (rand-int 2)) nil (list :foo)))

19:41 ,(lazy-seq (if (zero? (rand-int 2)) nil (list :foo)))

19:41 clojurebot: (:foo)

19:41 hiredman: tetron: lisp has been a plurality for a long time, and many lisps treat these things differently

19:42 infact it was a huge debate in the process of standardizing cl

19:42 Lajla: Twey, this is what I also think is annoying about haskell,t hat cons only works on lists.

19:42 tetron: hiredman: fair enough :-) my experience is limited to common lisp, elisp and a bit of scheme

19:42 Lajla: I don't like 'restrictions'.

19:42 Twey: Lajla: That's… not really an accurate description

19:43 hiredman: Twey: that works because in many cases nil is still treated as a empty seq

19:43 Twey: ,(cons 1 (cons 2 ()))

19:43 clojurebot: (1 2)

19:43 Twey: hiredman: I see

19:43 hiredman: ,(into nil '(1 2 3))

19:43 clojurebot: (3 2 1)

19:43 Twey: Lajla: Consing doesn't only work on lists. Consing *is* lists.

19:43 hiredman: ,(into #{} '(1 2 3))

19:43 clojurebot: #{1 2 3}

19:43 Lajla: Twey, explain?

19:43 Twey: (and it wouldn't make sense to have it work on anything else)

19:43 Lajla: Well, maybe in #haskell

19:43 Lajla: Twey, that's the point

19:44 'makes no sense'.

19:44 I want to make up my own sense.

19:44 hiredman: in haskell I believe the implementation of cons is the way it is because of the type system

19:44 Lajla: Where people see 'addition', I see a shifting of bits, it's all about interpretation.

19:45 hiredman: the type of cons cells says they have two slots, a slot that holds a thing of a type X and a thing of a type List (or cons cell)

19:45 so the only thing you can cons onto is a list/cons cell

19:45 Twey: Lajla: It's all about specification. ;)

19:46 hiredman: It's not really to do with typing… more to do with data-types.

19:46 Lajla: Twey, I disagree, a processor stores natural numbers and has some operations on them, that's it.

19:46 hiredman: Twey: I don't know much haskell, but from what I have seen I would say there is no real difference

19:46 datatypes are constructed from types

19:47 Lajla: However, you can also interpreted 2^32 - 1 as -1, if ytou like.

19:47 Twey: Lajla: Sure, but if you're limiting yourself to the capabilities of the processor, you're missing out and should go back to ‘coding’ by bashing wires together. :þ

19:48 Lajla: Twey, I'm talking about C style langauges right now.

19:48 dnolen: (cons 'a {:foo 'bar})

19:48 Lajla: C is ugly, C-- is awesome.

19:48 dnolen: ,(cons 'a {:foo 'bar})

19:48 clojurebot: (a [:foo bar])

19:48 hiredman: ,(cons 'a (seq {:foo :bar}))

19:48 clojurebot: (a [:foo :bar])

19:48 hiredman: ,(seq {:foo :bar})

19:48 clojurebot: ([:foo :bar])

19:50 Raynes: Lajla: Clojure isn't Common Lisp or Scheme, and I don't think it's necessary to assume that all Clojure programmers are also Scheme or Common Lisp programmers, and would know the difference between cdr, cre, cklgnerjergi or whatever other cryptic names those languages use.

19:50 In Licenser's defense, that is.

19:50 The only reason I know the difference is because I worked on a toy Lisp that programble was writing a while back.

19:51 programble: car and cdr make sense

19:51 btw

19:51 when explained as a linked list

19:51 hiredman: *shrug*

19:52 Lajla: Raynes, yeah, probably, I stand corrected

19:52 Clojures lists are probably not 'linked'

19:52 hiredman: the names are from registers that machines people are using these days don't even have

19:52 they are

19:52 the nodes just aren't exposed for direct manipulation

19:52 lists and seqs are not the same thing

19:52 programble: car is like linkedlistnode->data

19:53 cdr is like linkedlistnode->next

19:53 hiredman: lists just happen to be their own seqs

19:53 Raynes: Car is what I drove home 30 minutes ago.

19:53 rfg: heh

19:53 hiredman: programble: I think everyone is familar with what linked lists are, and the needed operations to traverse them

19:53 programble: Raynes: it means something, an acronym

19:53 Twey: ‘My other car is a cdr’

19:53 programble: something register

19:54 hiredman: right

19:54 Twey: http://en.wikipedia.org/wiki/CAR_and_CDR

19:54 hiredman: it's named after register in a machine no one uses

19:54 clojurebot: lisp machine?

19:54 clojurebot: my lisp machine is the jvm

19:54 dnolen: ,(first (first {:foo 'bar}))

19:54 clojurebot: :foo

19:54 raek: (defn cons [a d] (fn [f] (f a b)))

19:55 (def car [c] (c (fn [a d] a)))

19:55 (def car [c] (c (fn [a d] d)))

19:55 s/car/cdr/

19:55 sexpbot: (def cdr [c] (c (fn [a d] d)))

19:56 programble: blurgh

19:57 raek: apparently, I cannot type. I'm aware of the typos. :)

19:58 hiredman: ~scala {((x: Any, y: Any) => (f: Function2[Any, Any, Any]) => f(x, y))(1, 2)((x: Any, y: Any) => x)}

19:58 clojurebot: Any = 1

19:59 dnolen: foldr and foldr considered harmful: http://research.sun.com/projects/plrg/Publications/ICFPAugust2009Steele.pdf, the days of cons are over. hello conc.

19:59 raek: scala, I really should look more into that language soon

19:59 dnolen: foldl and foldr i mean

20:01 hiredman: raek: why?

20:01 raek: ah, I see. this is related to why there is no 'preduce' in clojure

20:01 curiosity, mostly

20:01 chouser: but clojure vectors are trees, not unlike Steele's structures there

20:02 hiredman: http://github.com/richhickey/clojure/commits/par

20:02 raek: ah, misinterpreted

20:02 chouser: so they could support efficient parallel operations.

20:02 raek: every reduce step is dependent on the previous

20:02 chouser: regular reduce on a seq, yes.

20:03 raek: even though + is associative, reduce cannot assume it

20:03 hiredman: raek: it can, it will just be up to the programmer to make sure they use associative functions

20:04 chouser: hm... subvec gives efficient access to slices of vectors. I wonder if it's overhead is low enough to build parallel ops on top of.

21:01 ceptorial: hey chouser, did you ever have any luck getting jvi to work with the enclojure repl?

21:02 chouser: Yes, but that was ages ago -- a very different version of enclojure.

21:03 ceptorial: i see.. any thoughts on how to get it working today?

21:05 chouser: no, I haven't looked at it recently.

21:06 let me know if you make any progress on it though.

21:06 ceptorial: alright, thx. did you move to emacs?

21:06 chouser: I need to find some sane way to extend my editor using Clojure.

21:06 nope, vim for me.

21:08 ceptorial: got it... vimclojure/nailgun?

21:09 chouser: ScreenRepl.vim

21:15 http://agriffis.n01se.net/skel.hg/index.cgi/file/fe1c0bdb217b/vim/plugin/ScreenRepl.vim

21:17 ceptorial: how does debugging work?

21:20 chouser: printlns and repl experiments are usually quite sufficient. I've tried to use jswat a couple times to step around.

21:23 ceptorial: i've found it more challenging to figure out where to put println's in clojure vs. imperative language..

21:25 dnolen: nice nonblocking telnet chat server in 11 lines of Clojure, http://github.com/texodus/saturnine

21:26 ceptorial: you put there pretty much in the same places I find

21:26 s/there/them

21:27 hiredman: (doto foo println)

21:27 ceptorial: but does that return foo or nil

21:27 dnolen: ,(println (println "foo"))

21:28 clojurebot: foo nil

21:28 hiredman: it returns foo

21:28 ,(doto :foo println)

21:28 clojurebot: :foo

21:28 :foo

21:28 ceptorial: oh nice

21:28 ok cool

21:28 hiredman: ,(doc doto)

21:28 clojurebot: "([x & forms]); Evaluates x then calls all of the methods and functions with the value of x supplied at the from of the given arguments. The forms are evaluated in order. Returns x. (doto (new java.util.HashMap) (.put \"a\" 1) (.put \"b\" 2))"

21:28 ceptorial: right

21:28 cool

21:29 dnolen: ,(do (println "foo") 5)

21:29 clojurebot: 5

21:29 foo

21:29 dnolen: ,(do (let [x 5] (println "foo") x))

21:29 clojurebot: 5

21:29 foo

21:30 ceptorial: got it

23:53 hiredman: http://www.cufflinks.com/silver-2gb-usb-flash-drive-cufflinks.html

23:53 er, mischan

Logging service provided by n01se.net