#clojure log - Dec 20 2009

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

0:05 scottj: Is there a function that inverts a tree? Not sure if that's the right name, but I want to convert (a (b 1)) to (b (a) 1)

0:28 alexyk: how do we do optional parameters?

0:29 scottj: &

0:29 _ato: (defn foo [x & [y z]] ...) y and z are optional (they'll be nil if not specified)

0:30 or (defn foo [x & options] ...) if you want any number of optional arguments (options will be a list of them)

1:09 tolstoy: So, I'm going to assume you can just 'export CLASSPATH="my-tons-o-jars" emacs' and be able to use Slime with code that depends on those jars. Right? ;)

1:10 efarrar: sounds reasonable tolstoy

1:10 that's what i've experienced in the vim equivalent of slime

1:10 tolstoy: There doesn't happen to be a way to, say, (load "random-jar-file") right from the repl, is there?

1:11 efarrar: yes, but it doesn't always work for everything

1:11 tolstoy: I keep thinking about the ASDF stuff people have hacked up with Common Lisp.

1:11 Ah, okay.

1:11 I'm using Aquamacs, and it has a cool "server" mode, so I can start emacs from the command line pretty easily.

1:12 scottj: tolstoy: you can run M-x swank-clojure-project, tell it the dir of your project, and it will look in lib dirs and put all the jars on the classpath and start slime

1:12 ,swank-clojure-project

1:12 clojurebot: java.lang.Exception: Unable to resolve symbol: swank-clojure-project in this context

1:12 tolstoy: Hm. I think I better take notes.

1:33 When you do a git fetch on, say, the 1.0.x branch. How do you diff what you just fetched? git diff HEAD 1.0.x? Something like that?

1:41 Which branch of clojure-contrib matches up with clojure 1.1-rc1?

1:53 ambient: hmm, i have a problem with clojure-project in emacs/swank-clojure where it doesn't find clojure.main, even when it's in my classpath. seems emacs overwrites that.

1:54 when I try and do M-x clojure-project on the project root

2:01 tolstoy: Hm. Swank doesn't seem to have used my CLASSPATH from when I started emacs.

2:02 At least if you go by (System/getProperty "java.class.path").

2:04 arbscht: tolstoy: you probably want to set swank-clojure-classpath

2:05 tolstoy: Where do I set that?

2:05 arbscht: in emacs

2:05 tolstoy: Oy.

2:06 Hm. That command doesn't exist. Or do you mean set something in .emacs?

2:09 ambient: When I run swank-clojure-project, I got some sort of hang on "polling" and nothing happens except a prompt for slime-abort-connection.

2:09 arbscht: tolstoy: try swank-clojure-extra-classpaths

2:10 tolstoy: arbscht: Are you talking M-x swank.... ? Cause there's nothing but the project thing.

2:11 arbscht: tolstoy: it's a variable in emacs -- do C-h v swank-clojure-extra-classpaths for info

2:12 tolstoy: So, you mean you have to edit your .emacs file whenever you switch projects and so on? Yikes.

2:13 arbscht: tolstoy: you could update its value at runtime too. depends what you want to do

2:14 ambient: tolstoy: yes, that's my problem too

2:15 tolstoy: Here I thought I was going to write some code, and now I have to figure out how to set a variable in emacs lisp. I never seem to get that sort of thing right.

2:15 Bitch bitch moan. I know it'll pay off in the end.

2:18 ssideris: writing code > setting up coding environment

2:18 much much more preferable

2:20 tolstoy: Do I just put a string in there?

2:22 arbscht: tolstoy: a list of strings

2:22 tolstoy: So, I do the C-h v swank-clojure-classpath, and I see a (swank-clojure-classpath) in the flip-down. Do I just replace that with a stirng? Do I type in (setq swank-clojure-classpath '("patha", "pathb"))? I see no docs anywhere.

2:23 (setq swank-clojure-extra-classpaths (list "/class/path/1" .... ))

2:24 ambient: http://www.thibault.org/adder/ clojure on python, :P

2:29 talios: clojure on python is just wrong :P

2:29 clojure on jython is where its at :)

2:30 ambient: just another layer of abstraction...

2:30 talios: Much like my polyglot maven/clojure work.

2:30 _ato: nice

2:30 that's something I

2:30 ve much thought about

2:30 a compiler to python/ruby/perl bytecode

2:30 for scripting etc

2:30 talios: abstractions on abstractions, abstracting the abstraction with yet more abstractions

2:32 ambient: it's cool how clojure is much more portable, lisp designed to sit on oop platform

2:42 tolstoy: Ah, man. I thought I'd just start-up swank-clojure as part of my app and then hook to it with emacs, but you can't even build it without maven, it seems. I so don't want to download Maven.

2:42 Maybe netbeans is the way to go for interactive dev.

2:44 _ato: tolstoy: http://clojars.org/repo/swank-clojure/swank-clojure/1.1.0-SNAPSHOT/swank-clojure-1.1.0-20091121.091400-2.jar

2:44 and it's built with leiningen not maven

2:45 tolstoy: Ah. I saw pom.xml and had to fight off the nitemares from a few years ago.... well, it wasn't that bad, I guess.

2:47 _ato: yeah, I understand. I've worked with it a while and I still find Maven frightening.

2:48 tolstoy: Yeah, it's like, "Cool! A neat little project!" Then, three hours of macports + downloading massive repos later, I get my simple little lib to play with.

2:49 _ato: yep... and no matter how many pom files I write, I still have to look up the syntax for even the most basic things. Same for the mvn command-line

2:50 tolstoy: I know people hate including jar files in your source tree, but, sheesh. It's sooooo much simpler. ;)

2:52 Okay. I've been complaining. Really, I worked all this out with CL a few years ago, and loved it. It's the damn CLASSPATH thing that gets me after a while.

2:52 BUT, I just started swank in a shell repl, and connected via emacs, and I LOVE IT!

2:52 _ato: :)

2:53 tolstoy: I can make a nice little shell script to get me started without having to mess with .emacs. Joy! ;)

2:55 talios: _ato - I'm working on maven polyglot support for clojure. no XML in site.

2:57 _ato: talios: yeah, I've been following. It's definitely an improvement, but XML is just the tip of the iceberg when it comes to Maven's horror. I integrated Maven into Clojars (for the repository deployment), using the Maven API directly and boy was that complex. The amount of hoops that Plexus (the auto-injector frameworky thing) makes you jump through to do anything is insane

2:58 tolstoy: How do you cleanly shutdown a swank server?

2:59 _ato: tolstoy: (System/exit 0) maybe?

2:59 I just Ctrl-C it normally :-P

2:59 tolstoy: Heh. swank.swank doesn't export a stop-server. ;)

2:59 _ato: there's a M-x slime-quit-lisp or something

2:59 talios: _ato: thankfully plexus is on the way out with maven 3 - guice baby guice :)

2:59 _ato: which I think just sends System/exit

3:00 johnmn3: g'day

3:00 tolstoy: M-x slime-repl-sayoonara does it, too.

3:01 _ato: talios: ah. I haven't looked at Guice, just Spring and now Plexus. So far I've got a rather negative opinion of dependency injection frameworks in general, but maybe it's just the ones (or the uses of them) I've been exposed to

3:02 johnmn3: I'm trying to build a simple swing repl. I'd like to somehow bind *out* and *err* to a JTextArea and *in* to a JTextField, but neither have a .getInputStream or something similar. How would you guys accomplish this?

3:06 _ato: you'd probably want to capture input/output for java code called from Clojure as well, so I'd probably use (System/setIn) with a PipedInputStream

3:06 and similar for output

3:07 you can override *in* for Clojure code just by doing (binding [*in* something] ...)

3:07 also see:

3:07 johnmn3: I was thinking of using a buffer and having another thread constantly flushing any content to the JTextArea, but I'd like to find a simpler solution... one where simply pressing enter (like at the regular repl) puts the code into to *in*, gets evaled, and automatically goes from *out* to the JTextArea

3:07 _ato: ,(doc with-out-str)

3:07 clojurebot: "([& body]); Evaluates exprs in a context in which *out* is bound to a fresh StringWriter. Returns the string created by any nested printing calls."

3:08 johnmn3: ah

3:09 So I need to somehow wrap the JTextArea in a StringWriter and then bind that to *out*

3:11 _ato: the part where you said, "for the java code called from clojure," that would be covered by rebinding *in* and *out* right?

3:11 _ato: I don't think so

3:11 ,(doc *in*)

3:11 clojurebot: "; A java.io.Reader object representing standard input for read operations. Defaults to System/in, wrapped in a LineNumberingPushbackReader"

3:11 _ato: cause java code would be using System/in and System/out directly

3:12 ,System/out

3:12 clojurebot: #<PrintStream java.io.PrintStream@161daed>

3:12 _ato: ,(.println System/out "hello")

3:12 clojurebot: nil

3:12 johnmn3: by java code, you mind like (.toUpperCase "hi")?

3:12 _ato: oh that's fine.. it's just if the java code has a print in it

3:13 if you don't care about threads/asynchronous output then just something like this might do the trick: (->> (.getText input-text-area) (read-str) (eval) (with-out-str) (.append output-text-area))

3:13 or whatever the appropriate swing calls are (I haven't used swing in years)

3:14 johnmn3: sounds about right... but what is with-out-str doing right here?

3:14 _ato: it's rebinding *out* for you

3:14 and turning the results into a string

3:15 ,(with-out-str (println "hello world"))

3:15 clojurebot: "hello world\n"

3:15 johnmn3: ok, so we get a string and eval it.. then we take that string and make it the destination of the results, coming from *out*, then append it?

3:17 , (let [a "hi"] (with-out-str (println (let [a "123"]) a))))

3:17 clojurebot: "nil hi\n"

3:17 _ato: yeah, so we get a string, read it into clojure data structures with (read-string), then eval it like: (with-out-str (eval form)) so with-out-str returns a string of our output which we then add to the output text area

3:18 (reverse (with-out-str (println "hello")))

3:18 ,(reverse (with-out-str (println "hello")))

3:18 clojurebot: (\newline \o \l \l \e \h)

3:18 johnmn3: whereas

3:18 ,(reverse (println "hello"))

3:18 clojurebot: ()

3:18 hello

3:18 _ato: right

3:19 talios: mm, for some reason the repl isn't printing stacktraces, is that an option I can turn on

3:19 ?

3:19 _ato: talios: hmm.. it should normally popup a new slime buffer thing with the stack trace

3:20 talios: bah - who uses slime ;p

3:20 _ato: oh you mean the repl directly?

3:20 that's weird then

3:20 talios: apparantly its a new feature to limit useless stacktraces ;:)

3:20 _ato: could try: (.printStackTrace *e)

3:20 talios: just did

3:21 _ato: hmm dunno then. I don't use a direct repl very often

3:21 talios: nah thats ok - as long as I know that its clojure supressing them by default, I'm ok with that

3:22 sadly the trace didn't actually help thou

3:22 johnmn3: ,(with-out-str (println (with*err*?)))

3:22 clojurebot: java.lang.Exception: Unable to resolve symbol: with*err*? in this context

3:22 johnmn3: ,(println (with*err*?))

3:22 clojurebot: java.lang.Exception: Unable to resolve symbol: with*err*? in this context

3:22 talios: annoyingly - my macro throws a ClassCastException, but if I run its steps manually - its fine

3:22 _ato: johnmn3: yeah, you'll have to catch exceptions and do whatever you want to do with their stack trace

3:23 johnmn3: I'd like to do what the repl does, and just append them into the JTextArea

3:24 (doc with-err-string)

3:24 clojurebot: excusez-moi

3:24 johnmn3: ,(doc with-err-string)

3:24 clojurebot: I don't understand.

3:24 _ato: ~def with-out-str

3:30 * johnmn3 tests

3:32 johnmn3: works good

3:39 talios: 'lo headius

3:39 headius: oh hai

3:41 johnmn3: does anyone know of an buffer kind of object I can get to automatically call (.append myJTextArea ), which I can use to .getOutputStream, for the purposes of binding *err* and *out* to?

3:41 * talios grrs at an elusive macro issue in his code :( sometimes clojure makes me scream

3:42 johnmn3: with the new protocols, I wonder if I could extend some existing java queue or stream to do that.

3:46 vegai: are there any mechanisms for making a high availibility solution a la Erlang? With supervisors t al

3:47 tolstoy: vegai: I don't think so. Not built in.

3:47 talios: johnmn3: you could do that now with (proxy) and create out own OutputStream that appends to a JTextArea

3:49 johnmn3: hmm.. How do I explore the interface of OutputStream? does (show OutputStream) show me the methods I need to over-ride?

3:50 show shows it has three .write signatures

3:50 [12] write : void (byte[])

3:50 [13] write : void (byte[],int,int)

3:50 [14] write : void (int)

3:51 PrintWriter has a write : void (String)

3:52 can any class be extended like that?

3:53 talios: (proxy) just implements an Interface, it's not extending anything

3:54 johnmn3: I mean, are OutputStream or PrintWriter interfaces? Aren't they concrete classes (or whatever)? Do I need to find their interface counterparts?

3:58 talios: Mmm your right, they're classes. For some reason I was thinking they were interfaces.

3:58 In that case I don't think (proxy) will help.

3:58 johnmn3: is there a command to message clojurebot with code, and he'll post it to lisppaste?

4:00 yea, something like a IPrinterWriter

4:02 * talios w00ts as he spots his macro bug. gah - twas a 2 line macro and yet took an hour to locate :(

4:03 _ato: johnmn3:

4:03 http://java.sun.com/j2se/1.5.0/docs/api/java/io/PrintWriter.html

4:04 wrapping a PipedOutputStream in a PrintWriter would be an alternative to using proxy

4:05 http://java.sun.com/j2se/1.5.0/docs/api/java/io/PipedOutputStream.html

4:10 talios: bah, that w00t was premature

4:12 johnmn3: ah'kkhaa

4:12 PrintWriter out = new PrintWriter(new TextAreaWriter(myTextArea));

4:14 ah, he's actually defining TextAreaWriter in the example.. I'll see if I can use proxy to create a TextAreaWriter

4:46 I'm trying to subclass Writer but I'm getting a ctor exception on String, with the relevant code as:

4:46 (write [cbuf off len]

4:46 (.append text-area (String. cbuf off len)))

4:47 Do I need to type hint here or something?

5:16 LauJensen: johnmn3: Best way to answer that question is (set! *warn-on-reflection* true) and compile the code

5:16 johnmn3: LauJensen: ok, will try that.

6:21 LauJensen: Blogged about the Arc challenge: http://www.bestinclass.dk/index.php/2009/12/beating-the-arc-challenge-in-clojure/

7:03 ambient: LauJensen: just by rapid reading, that really doesn't look like a solution to a challenge, but a trivial problem :)

7:05 _ato: LauJensen: it says in the "challenge" description: the value entered in the input field must not be passed in the url

7:05 LauJensen: really?

7:06 _ato: yep.. in the blockquoted bit

7:06 LauJensen: aah

7:06 Thanks :)

7:15 _ato: that "challenge" just seems to be saying hey arc ships with a continuation/closure based web framework in the standard library. Which I guess is okay, but not really very interesting if you've seen one before

7:18 LauJensen: True

7:18 But I think Compojure is suffiently elegant to want to show it to people

7:18 And now I get to show of the session middle-ware as well :)

7:19 _ato: hehe :)

7:23 eek

7:23 I'm looking at the Haskell version: http://gist.github.com/260052

7:24 I guess I must already be forgetting most of the Haskell of learnt

7:24 LauJensen: Its pretty complex

7:24 Go is kinda nice

7:24 Ruby looked nice, until I saw the custom library the guy made in order to make it nice :)

7:27 _ato: the Go version cheats to look nice, it uses mutable global state, so it'll break if two people access it simultaneously ;-)

7:27 though I dunno maybe Go has a nice sessions library

7:29 the ruby one is strange, dunno why he's using html strings for that, I thought sinatra had helpers for that

7:29 oh right

7:29 he says it doesn't hmm.. maybe I'm just think of rails / haml

7:31 LauJensen: _ato: link to your Wide Finder blog post plz?

7:32 _ato: LauJensen: you mean this link? http://meshy.org/2009/12/13/widefinder-2-with-clojure.html

7:35 LauJensen: thats the one

7:36 I linked that to your name, article now updated with session middleware instead of URL trick

7:43 _ato: actually, yeah you're right. With the sessions, that is quite a nice demo of all the basic bits of Compojure

7:43 certainly beats a usual hello world example

7:47 LauJensen: Glad you like it

7:51 _ato: I wonder if I should adopt your disclaimer from the top of your WideFinder article "This code can be reproduced in Java, which can be reproduced in C++, which can be reproduced in C, which can be reproduced in ASM, which can be reproduced in a Hex-Editor: Source code here" :)

7:54 _ato: hehe, the turing-completeness disclaimer. :-)

7:56 Yeah, I mainly added that cause I knew I'd get a swarm of comments saying... but you can do the same thing in language X. Which is beside the point.

7:57 arbscht: I believe the official designation was "Clojurian", not "Clojurist"

7:57 LauJensen: arbscht: correct

7:57 _ato: Did you succeed?

7:58 _ato: LauJensen: succeed at preventing the swarm of comments? seems so. :-)

7:58 LauJensen: I've tried to avoid certain types on comments in every post I've done - the only thing which works for sure is moderation :) When you speaking of a n-level language, I'd say anything you can do in N, you can also do in N-1. But nothing everything makes sense doing in N-1, so the important this is: Can you do it in N ? ... cryptic - but makes sense?

7:58 Luyt: Why is there need for vectors in Clojure? Can't lists do what vectors do?

7:59 LauJensen: Luyt: They cant have the same performance characteristics

7:59 _ato: Luyt: vectors allow fast indexed lookup. lists are slower for indexed lookup as they have to be traversed

7:59 Luyt: I see.

7:59 LauJensen: Ah thats a shame alex, too slow :)

7:59 hiredman: Luyt: you are asked if linked lists can offer constant time indexed access?

7:59 asking

8:00 Luyt: I am reading the book and just wondered why there were both vectors and lists, but now that's clear to me.

8:00 I thought maybe the one was immutable and the other not, like you have in Python (tuples vs. lists)

8:01 _ato: yeah, they're both immutable in Clojure

8:02 arbscht: there are also useful differences in semantics and syntax

8:02 ,(conj [1 2 3] 4)

8:02 clojurebot: [1 2 3 4]

8:02 arbscht: ,(conj '(1 2 3) 4)

8:02 clojurebot: (4 1 2 3)

8:02 Luyt: ,(into [1 2 3] 4)

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

8:03 Luyt: ,(into [1 2 3] [4])

8:03 clojurebot: [1 2 3 4]

8:03 Luyt: ,(into '(1 2 3) '(4))

8:03 clojurebot: (4 1 2 3)

8:03 _ato: lists have the advantage that you can stick them on the front of other seqs, like lazy sequences or vectors, and adding them to the front of such objcets is really fast

8:04 where with a vector you'd have to convert the whole seq to a vector

8:04 hiredman: generally you don't into a list

8:04 you just call seq

8:05 Luyt: That was my next question: why is there an 'into' if you already have 'conj' ?

8:05 hiredman: (which is not the same, but close enough for most cases)

8:05 _ato: ,(into [1 2 3] [4 5 6])

8:05 clojurebot: [1 2 3 4 5 6]

8:05 LauJensen: ,(reduce conj '() [1 2 3 4])

8:05 clojurebot: (4 3 2 1)

8:05 _ato: into is for conjing multiple things at once

8:05 hiredman: why have multiple instructions when a processor only needs one?

8:08 I imagine rhickey found himself writing (reduce conj x y) so he packaged it up into (har) clojure.core

8:09 LauJensen: hehe

8:10 _ato: yeah, since it's such a common thing to do, it's worth naming even just for readability. "into" gives you a much better idea of the intent than "reduce conj" which requires more thinking about

8:11 and of course later on it turned out to be handy since, into can add transients

8:12 Luyt: Ah, I see, (conj [1 2] [3 4]) vs. (reduce conj [1 2] [3 4]) and (into [1 2] [3 4])

8:14 hiredman: ,(conj [1 2] [3 4])

8:14 clojurebot: [1 2 [3 4]]

8:14 hiredman: very different

8:14 Luyt: Yes, (reduce conj [1 2] [3 4]) and (into [1 2] [3 4]) both return [1 2 3 4]

8:16 Well, with that mystery solved I get another cup of coffee ;-)

8:16 LauJensen: Btw, for the rest of your bloggers who have had some difficulty getting good source highlighting for your Clojure-code. I made a little macro that works with htmlize, so to get code on my blog I mark the region and hit M-x blog, and its in my clipboard ready to be pasted in html :)

8:20 _ato: LauJensen: cool. htmlize is very handy. I'm currently using markdown with pygments for the highlighting, which looks like this: http://meshy.org/~ato/tmp/2009-12-13-widefinder-2-with-clojure.markdown.txt

8:21 LauJensen: Nothing is highlighted?

8:21 I think CGrand is also using some modified version of Pygments

8:22 _ato: I mean that's the source code

8:22 the highlighted output is in my blog post http://meshy.org/2009/12/13/widefinder-2-with-clojure.html

8:22 LauJensen: aah, gotcha

8:22 _ato: How did you set it up ?

8:23 _ato: LauJensen: using Jekyll: http://wiki.github.com/mojombo/jekyll

8:24 LauJensen: Ok - Maybe Htmlize is good enough after all :)

8:24 _ato: oh yeah, htmlize is fine, I use that quite a lot too. I just hate hand-writing long HTML pages

8:25 LauJensen: Yea, which htmlize saves me from - the only problem is if I need to edit, I usually just re-paste the whole thing

8:26 _ato: yeah, that's what I was finding too.

8:29 LauJensen: This was one of my first posts and I've received several emails (as late as earlier this week) asking me about the setup, how did I get it to look like that, which OS etc, http://www.bestinclass.dk/index.php/2009/09/layout-emacs-etc/

8:31 _ato: Sounds like you wrote this http://arclanguage.org/item?id=1521

8:34 _ato: hehe, nope. I like the BASIC version though. It really shows how complicated a "basic" app is these days compared to what it used to be. So much stuff (HTML, sessions, urls) you have to worry about that you didn't used to

8:34 on the other hand it's much easier to get images and different font sizes and such up in a webapp than it would be in basic. ;-)

8:37 LauJensen: So generally, would you say that you have a tendency to over-think things? :)

8:41 _ato: totally. simplicity is hard, and it just seems to keep getting harder the more technologies that are invented.

8:49 chouser: Hi, I'd like to discuss something that just hasn't received enough attention in quite a while.

8:49 parenthesis!

8:50 _ato: :O

8:50 liebke: haha, I've got this great idea for reducing the number of parentheses in Clojure!!! ;-)

8:50 _ato: the taboo word!

8:50 the-kenny: liebke: No! We need more of them.

8:51 liebke: :)

8:51 chouser: obviously parenthesis are ignorable and "disappear" over time

8:51 obviously parenthesis are the core and essence of a lisp

8:53 liebke: I do think people's perceived problem with parentheses is actually caused by deep nesting of function calls. I think more liberal use of 'let' is a solution to their problem, not reducing the number of parens

8:54 rhickey: There are several problems with parens, they need to be separated in order to talk about them

8:54 first and foremost if the familiarity issue

8:55 is the

8:55 code as data is different from code using syntax

8:55 so, first reactions are "I can't read that"

8:56 an incorrect extension is "that is unreadable"

8:56 just like someone who knows only Japanese might find English unreadable, but would be wrong to declare it generally so

8:56 Chousuke: depends on who's writing it :)

8:57 LauJensen: (.replaceAll rhickey "\n" ",")

8:58 I can't believe I'm not getting more love on HackerNewz, between me and Go I'm the only one who solved the problem

9:03 aldebrn: LauJensen, I just read your post on 1d automata and J, I wish more people withstood their impulse to badmouth something they find on the internet that they don't understand and don't like :P

9:03 _ato: mmm. Probably the functional thing is probably the larger stumbling block for people with an solely-imperative background. Trying to read Clojure without understanding functional programming is a pretty hard task. You're likely to come off thinking it's just gibberish and then not realising that's why it structurally looks so different blame the parens

9:05 I remember when I first encountered functional programming (Haskell) it took some time to wrap my head around. It felt like Haskell was totally unreadable at first.

9:06 LauJensen: aldebrn: Who badmouthed?

9:07 aldebrn: LauJensen, I meant, your comment ' I was planning to let him know, that only the writer of such hideous looking code could read it, but then I tripped over his blog...' You rock, I wish more people stopped to learn more about things like you did instead of just commenting negatively and forgetting :)

9:08 LauJensen: aaah, thanks - yea I'm glad I did, J is a good helper and truely a REPL language

9:09 aldebrn: I'm paranoid about my own ignorance but it took me a while to learn that others were less so, and I should assign internet comments very little weight. So many people have prejudices against Lisps, or anything-not-C#, etc..

9:10 J looks really cool, and it maps into Clojure well

9:10 LauJensen: True.

9:11 And yea, I hope to hook J into Clojure, calling the j.dll directly from a j macro, but I haven't got the prototype running yet

9:11 One thing you noticed quickly about J, is that its blazingly fast

9:12 s/you/I

9:15 aldebrn: j.dll faster than Clojure? Would it be worthwhile to have a Clojure-to-J compiler for speed?

9:17 chouser: I do think most lisps have a weakness around parens in that they can mean so many different things when used in code.

9:17 this is not a new statement from me. :-)

9:18 rhickey: chouser: exactly - it ends up that 'everything is a list' is not in fact the simplest

9:18 due to this overloading

9:18 that incidental complexity thing again

9:19 chouser: humans find visual hints to be very useful. {} meaning code blocks or hashes (usually formatted quite differently) is nice, to differentiate from (foo) as grouping and foo() as calling

9:20 rhickey: chouser: right, but taken farther that's the argument for syntax

9:20 chouser: foo(bar, baz) { bing(); bang(); } conveys some vauge but useful meaning even without knowing the meaning of the words.

9:20 rhickey: yes

9:20 (foo ((bar) (baz)) ((bing) (bang))) conveys almost no meaning at all.

9:21 (foo [bar baz] (bing) (bang)) is an interesting middle ground.

9:21 rhickey: so, why not syntax?

9:22 LauJensen: aldebrn: No, that would be a bad way to go. But for some things, mathematical expressions etc, a J interface would be nice, because at those things its much faster than Clojure I think

9:22 hiredman: chouser: it conveys no meaning because you are using nonsense words

9:23 chouser: homoiconicity buys simpler macros, simpler compiler, simpler debates about new feature syntax.

9:23 patrkris: is it correct to say that the STM in Clojure is dynamic?

9:24 chouser: hiredman: this is how code looks to people unfamilier with the vocabulary.

9:24 hiredman: chouser: algo syntax is just as uncomprehendable to people why haven't written code before

9:25 lisp has syntax, it is expressed in words (symbols) rather than brackets and what not

9:27 Chousuke: I think vectors an maps give clojure enough syntax elements so that you can avoid overloading parentheses.

9:27 rhickey: chouser: those are downstream benefits. More syntax means more syntax rules, and thus more to understand., so more complexity up front. This might be amortized over a lifetime of use of a single language and thus might be a net gain. Once you learn more languages, there is less amortization and the per-language up front costs seem higher.

9:27 Chousuke: without having to have a "full" syntax like most languages.

9:28 hiredman: (defn f [x] x) vs. defn f (x) x end

9:28 what's the difference? where is the syntax?

9:29 chouser: I don't think Clojure syntax would be harder to understand for first-time programmers than other languages. But relatively few people in that position are entering these discussions.

9:29 Chousuke: well, in the lisp case, the syntax is the macro mini language. ie. how it interprets the code elements

9:29 rhickey: hiredman: there is a huge difference. the structure, parens, always delimit, whereas you have to know end/; etc delimit

9:29 Chousuke: but the generic "structural" syntax is uniform

9:30 rhickey: and what matches with end

9:30 hiredman: rhickey: so not only does lisp have syntax but is has a more regular syntax

9:30 chouser: On the other hand, C, C++, Java, JavaScript, lua, etc. have similar enough syntax that once you've learned one or two, the work necessary to understand a lisp is higher than to understand another from the "C-like" category.

9:31 rhickey: hiredman: it has syntax for a very few data structures, at that point, you brain can organize code. AScribing it meaning goes to the words, but that's true in langs with syntax too. In langs with syntax, elaborate rules must be used to discern the structure before other things come into play. We've just internalized many of those elaborate rules

9:32 hiredman: actually I just finished watching some presentation of norvigs where he gives his reason for more or less jumping to python from lisp

9:32 students reading the ai book couldn't seem to figure out how to map from the pseudo code in the book to lisp, but the pseudo code was almost an exact map to python

9:33 rhickey: a key question is, how much different a language can one learn if they are unwilling to have different syntax? Lisps want code-as-data for macros, Haskell wants juxtaposition as application (as big a leap from C-derivees) for its functional style

9:33 does setting up an arbitrary limit on difference-from-what-I-know determine a hard limit for what you can know?

9:34 chouser: bbl

9:35 hiredman: I wonder what could be achieved if all the effort into lisp without parens went into, you know, doing something cool with lisp

9:35 rhickey: hiredman: but what about Norvig's point?

9:35 seems somewhat valid

9:35 hiredman: rhickey: "you can't fight reality"

9:36 the talk was actually about scientific computing with python and this just an antidote in the intro

9:36 fliebel: How can I dynamically add a jar to the classpath? add-classpath is deprecated, which most of the time means there is a better way.

9:36 Chousuke: well, the pseudocode was probably significantly more pythonlike in structure, so it was easier to associate with python.

9:37 hiredman: not having read the book (and not knowing common lisp) I cannot comment

9:38 Chousuke: but in doing so, the studetds may have relied too much on the "physical" structure of the code, rather than the logical structure.

9:38 hiredman: fliebel: I'd appreciate it if you could give http://gist.github.com/255766 a try

9:39 if you run it as a clojure script it will create a cl.jar file and print out usage instructions

9:41 fliebel: hiredman: huh? I don't want to create a jar, I want a Java library accessible at the repl.

9:43 hiredman: fliebel: the clojure file generates a classloader that is then used to replace the system classloader

9:43 the replacement classloader has a an "add" method

9:44 fliebel: ah...

9:46 hiredman: gah, typo, should be getSystemClassLoader

9:49 liebke: hiredman: I'd like to give your class loader a try. Can you give a usage example of adding a class/jar within a running repl? I'm not quite getting it from the usage message at the end of the gist.

9:51 hiredman: (.add (ClassLoader/getSystemClassLoader) (URL. "file:///some.jar"))

9:51 (.add (ClassLoader/getSystemClassLoader) MyMagicalClassLoader)

9:54 liebke: hiredman: okay, so the URL points to a jar, I see. I really don't understand Java ClassLoaders, so the second example isn't clear, but the first one makes sense now. Thanks.

9:55 hiredman: the second example means you can make your own classloader that does magical things (bytecode on the fly?) and add that to be searched for classes

9:55 aldebrn: hiredman, rhickey, I'm a refugee from Python (too inflexible for very complicated things). My view is, if people think Python is more useful and easier than Lisp, fine, but I think they're wrong and I'm putting my money where my mouth is by working in and on Clojure

9:56 hiredman: :P

9:56 ~python

9:56 clojurebot: python is ugly

9:56 liebke: hiredman: cool, I'll leave the development of magical class loaders to you though :-)

9:57 aldebrn: I think someone here was commenting earlier that they thought Ruby was elegant until they saw the backend code that allowed for that elegance. I don't know ruby but I think that's a good description for Python too, all the nice elegant things in the language are unmalleable

9:58 hiredman: liebke: I don't know much about classloaders myself, this is just sort of a rough cut of a solution for adding classes during developement

9:59 liebke: hiredman: yeah, I think it can be very useful

10:08 fliebel: Is there a place to get a nice overview of the workings of all those different include, use, require, etc...

10:09 I try to do something simple like including a clj file from the repl living in the working directory.

10:10 arj_: I'm having trouble bending 'some' to find a struct with a specific field in my sequence, any hints?

10:11 hiredman: ,(some :foo [{:bar 1} {:foo 1}])

10:11 clojurebot: 1

10:11 hiredman: ,((comp first filter) :foo [{:bar 1} {:foo 1}])

10:11 clojurebot: {:foo 1}

10:12 arj_: aha nice

10:13 so that last one will all stop after finding the element?

10:13 Chousuke: yeah.

10:14 arj_: cool :-)

10:14 thanks

10:14 fliebel: I'm on the repl running in a directory where a few clj files are laying around, how can I use these?

10:15 import and friend only seem to work with cp and java stuff

10:16 _ato: fliebel: maybe (load "somefile.clj")

10:16 but best would be to just add "." to the classpath

10:17 fliebel: like this? -classpath /opt/local/share/java/clojure/lib/*:.

10:17 _ato: yup

10:18 hiredman: fliebel: there is always load-file

10:18 fliebel: hiredman: I think that is easier than fiddling with cp…

10:19 is there a :load thing for the ns macro?

10:19 hiredman: nope

10:20 I highly recomend you get your classpath worked out and use the ns macro's :use and :require over relying on load-file

10:22 fliebel: hiredman: but after adding . to the cp I still can't get it to work… I got to get a clear image how Clojure works together with java.

10:23 hiredman: well, while "just add . to your classpath" is good advice, it doesn't take in to account the possibility that you don't have your namespaces/directory tree laid out well

10:24 namespaces?

10:24 clojurebot: namespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it

10:25 lisppaste8: johnmn3 pasted "JTextArea *out* *err*" at http://paste.lisp.org/display/92391

10:25 fliebel: hiredman: that'll be the problem. I'm trying to run a file with a strange ns in the current dir, so I think that's why It's not working

10:25 johnmn3: can someone check that out? I can't figure out what the correct way to set the proxy up for Writer is.

10:26 I've found lots of guides online for socket-repls, but not swing repls

10:26 hiredman: johnmn3: you are missing implementations for write that take less then three args

10:26 and that is not how you hint a character array

10:27 and that is not how you hint ints

10:29 johnmn3: ah.. but the javadoc on writer states that you only override the three parameter write, I think. But I tried writing aritys from 1 to 4 parameters.. though I never had all 4 write methods written in the proxy.

10:29 * johnmn3 looks up how to write hints

10:30 hiredman: johnmn3: proxy overides by name, so if you provide an implementation for .write, it needs to handle all possible aritys for methods named write

10:31 I would just toss out the hints

10:31 johnmn3: so do I do a method for each? (write [buf] ... (write [buf myint] ... etc. ?

10:31 yea, I probably don't need them.

10:32 hiredman: or you can (write ([buf] ...) ([buf int] ...) ...)

10:33 johnmn3: ah, rite

10:33 hiredman: if I recall the single arg .write can take a buffer or an int

10:33 johnmn3: damn, there's 5 write methods :/

10:33 hiredman: so you will need to check that

10:34 johnmn3: int, string, or char[]

10:34 fliebel: Most of the time noobs like me actally do something wrong when they find a bug, but this seems quite strange to me: (line-seq (BufferedReader (FileReader. "/some/file")))

10:34 java.lang.Exception: Expecting var, but BufferedReader is mapped to class java.io.BufferedReader

10:34 johnmn3: missing the dot?

10:34 hiredman: http://gist.github.com/107140

10:35 johnmn3: BufferedReader_._

10:36 fliebel: johnmn3: hmm, you're right *ashamed*

10:36 johnmn3: fliebel: I just did that a few minutes ago

10:37 hiredman: so you've had that hanging around.. this is what I've been working on all day.

10:37 hiredman: johnmn3: no guarantee that it works or whatever, I haven't touched it in a while, and if I recall it was finicky

10:38 johnmn3: ok

10:40 hiredman: wow, yeah, I recall tearing my hair out over treating jta's as a reader and a writer

10:41 johnmn3: I like that add-ctrl-enter-listener. I was going to add that too.

10:41 so you used an OutputStream instead of a PrintWriter

10:42 hiredman: yeah, I went as low as possible, because there were fewer operations to support

10:43 and then it gets wrapped in an OutputStreamWriter and then a PrintWriter

10:45 johnmn3: I'm probably just going to use your code as a base.

10:45 hiredman: by all means

10:48 johnmn3: npe.. I'll hack on it and try to find it.

10:52 hiredman: huh

10:52 yeah, it runs, but I could some kind of npe

10:53 oh, right, you have to select what you want to run, then hit C-<RET>

10:53 johnmn3: ah, you have to highlight the code to ctrl-enter. with nothing highlited...

10:53 right

10:55 I was thinking of doing some kind of tokenizer, to eval whatever expression is within the matching parens to the left of the caret.

10:55 like (+ (+ 1 2) 3)| <ctrl+enter> evals to 6

10:56 cemerick: I didn't check my clojure list inbox for a couple days, and then return to find a bunch of pissing-into-the-wind about eliminating parens.

10:56 hiredman: right, not wanting to do that, I went for the easy fix

10:56 * cemerick grumbles

10:58 benji: I'm a newby and don't understand why the highlighted line in http://pastebin.com/d24a97957 doesn't seem to have any effect.

10:59 johnmn3: what are the right terms I want to be using to find examples of doing that? clojure tokenizer ?

10:59 the-kenny: benji: map is *lazy*

10:59 benji: Wrap the map-thing in a (doall (map ...))

11:00 hiredman: johnmn3: I doubt you will find examples

11:00 benji: !!

11:00 gotcha

11:00 hiredman: but I think you just need to count parens

11:00 (basically)

11:00 the-kenny: benji: map applies the function when needed. If you do (take 3 (map ...)), it only creates the first 3 elements

11:01 hiredman: the-kenny: take is *lazy*

11:01 benji: thanks the-kenny; got it working

11:01 the-kenny: hiredman: Oh.. bad example ;)

11:01 hiredman: :P

11:03 tolstoy: Is there a way to get the (println ...) output of another thread to show up in the emacs / slime buffer?

11:03 the-kenny: tolstoy: It shows up in the *inferior lisp* buffer

11:04 tolstoy: the-kenny: Yeah, I'm seeing that. Is that pretty much all we got?

11:04 the-kenny: hm.. I'm not sure if it's possible

11:07 aking: tolstoy: (add-hook 'slime-connected-hook 'slime-redirect-inferior-output)

11:08 tolstoy: aking: Cool, thanks!

11:10 Examining hiredman's hack to get setName working on PircBot....

11:36 hiredman: tolstoy: it's in contrib now, towards the end of java-utils

11:53 the-kenny: Looks like the docstring for c.c.math is broken - It ends with: "[...] the floor of the square root and the ".

11:55 http://richhickey.github.com/clojure-contrib/math-api.html

13:31 johnmn3: which do you think would be preferable for a text editor that can evaluate code when the caret is next to the expression... in front of the expression or behind the expression?

13:32 I was thinking behind, because you could write the expression, then immediately evaluate it, without having to move the caret back to the front of the expression.

13:32 or is there a better idiom all together.

13:32 ?

13:33 the-kenny: johnmn3: I think all three are possible in emacs.

13:33 JonSmith: i think emacs does 'evaluate last expression'

13:35 johnmn3: well, if we had (+ 2 3 )<caret>(- 2 3) and we hit the evaluate keys, which would get evaled?

13:36 I suppose shift+ctrl+enter could be the opposite of ctrl+enter

13:39 if evaluating to the right of the caret in the following expr: (let [a 3] <caret>(+ 1 a)) would emacs error with a being undefined?

13:40 cark: emacs evals top-level or after caret on same line or toplevel before caret on same line

13:41 at least that's how i picture it

13:41 so you're stuck at doing it all =D

13:42 johnmn3: also, if using paredit, if getting the caret to the right of the closing parens is a pain, people will rather eval from the opening parens

13:44 scottj: Is there something in contrib that will invert a tree (is there a better name for this?), like turn (a (b _ 1) 2) to (b (a _ 2) 1) ?

13:45 johnmn3: not sure what you mean by "or toplevel before the caret on the same line".. do you mean, wherever a caret is on a given line, it will scope from the outermost expression on that line and all subexpressions on the following lines that belong to that outer scope (which started on the line the caret was on)?

13:46 scottj: does the _ have to stay in the inner expr?

13:47 scottj: johnmn3: yeah, but I'd be interested if there's a solution when it doesn't.

13:49 cark: johnmn3 : you should install emacs with clojure-mode and make some tests

13:49 it does the right thing

13:50 johnmn3: scottj: I don't know of something that automatically inverts a tree like that in contrib.. but you might be able to do it easily. depends on how you want to deal with unbalanced trees, I think.

13:51 cark: yea, I should.

13:52 scottj: johnmn3: for the example I gave (3 elements in each list), can you give me a hint on how you'd solve it?

13:57 johnmn3: I'd split the list down the center. For cases where the list had an odd number of elements, I'd put the extra element on the right side I guess. I think it'd be more interesting with a list like this: (a (b (c d e) f g) (h I) (j k (l ( n (o p)))))

13:59 maybe tagging each element with a "nest-level" and then rebuild a list from left to right but flipping the nest-level for each element.

14:00 it looks like (o p) are the deepest level, at 5. So an inverted list might look more like (((((a) b) c d e (f ... etc.

14:02 scottj: cool, thanks for the ideas. One place this can be used is if you want to generate a bunch of unit conversion functions, but only define the relationship one way. For fahrenheit to celsius you'd write (/ (* (- % 32) 5) 9) then you could easily generate the inverse. I'm hoping to use this to define a few unit relationships and then generate a bunch of unit conversion functions that combine them.

14:03 johnmn3: hmm

14:04 scottj: (of course you also have to invert the operations)

14:04 johnmn3: that'd be cool.. I don't think my last example would be what you want then.

14:18 lisppaste8: johnmn3 pasted "get-expr" at http://paste.lisp.org/display/92397

14:19 johnmn3: theres my get-expr function... grabs expression from it's matching paren, starting from the paren on the right.

14:19 kinda ugly.. feel free to pretty it up.

14:21 also, it's not yet smart enough to detect ")(" or \( \)

14:25 It's a little naive.. will be hard to add that smartness to it without some kind of smarter parsing mechanism.. I thought I remember someone already wrote some kind of parsing library for clojure.

14:29 perhaps using a cond instead will allow for more flexibility and extension.

14:37 rads: if I'm adding something to a vector and I don't care about the order, does it matter if I use cons or conj?

14:38 devlinsf: rads: I think conj is more idiomatic

14:38 JonSmith: i thought cons returns a seq

14:39 yup

14:39 ,(cons 1 [2 3 4 5])

14:39 devlinsf: ,(class (cons :a [:b]))

14:39 JonSmith: hmm

14:39 no clojurebot :-(

14:39 devlinsf: ,(class (conj [:b] :a))

14:39 Ah!!!!

14:40 Well, I just ran mine at a REPL

14:40 JonSmith: api says so, if you trust it

14:40 devlinsf: a cons returns a clojure.lang.Cons object

14:40 conj returned a clojure.lang.PersistentVector

14:41 If you are expecting a vector back, you must use conj

15:37 tolstoy: Folks, how to you matchup clojure-contrib with any given branch of clojure? For instance, which clojure-contrib goes with clojure 1.1?

15:38 devlinsf: tolstoy: We're working on freezing a branch w/ 1.1

15:38 tolstoy: for now, use master

15:38 tolstoy: Okay.

15:39 Good enough for me. ;)

16:10 johnmn3: does anyone know how clojure's repl implements it's ability to not eval until a closing parens is matched to the opening one?

16:11 I'm reading the source for main/repl and I"m not seeing it.

16:16 chouser: johnmn3: do you mean how pressing <enter> early still doesn't cause it to eval?

16:16 johnmn3: right

16:17 I'd think it counts parens, but it knows not to count escaped parens from strings or characters

16:17 chouser: the 'read' function reads from a stream until it has read a whole form or eof

16:17 at the repl, the input stream blocks until you type something and press <enter>, so while it's blocked, so is 'read'

16:18 'eval' isn't called until after 'read' returns.

16:19 johnmn3: I want to implement the ability into a gui repl, where you can eval a form with a ctrl+enter..

16:20 so I'll need to feed-read a character stream from the caret of the JTextArea into read, and it'll know when to eval?

16:21 It'll just keep reading until EOF and spit out for extra characters like: java.lang.Exception: Unmatched delimiter: )

16:23 making get-expr to get a desired form, while accounting for all the escaped parens is proving difficult :)

16:25 chouser: yeah, I wouldn't try to parse it yourself. that's what 'read' is for.

16:27 What I did was feed 'read' a StringReader. If it threw an "EOF while reading" exception, I knew the input was incomplete. :-)

16:27 AWizzArd: Hi guys, what‘s new? :)

16:27 johnmn3: but read can't tell me when a given function ends in the middle of a lot of functions in a JTextArea, can it?

16:28 AWizzArd: not much

16:28 devlinsf: johnmn3: Use read-string

16:28 combine and actionlistener on a JTextField & read-string

16:29 johnmn3: devlinsf: what do you mean?

16:30 devlinsf: Well, JTextArea fires a ActionEvent when you press enter

16:30 So, I'd make my action listener list this

16:30 (read-string (. getText my-j-text-area))

16:31 johnmn3: yea, but I don't want to eval the whole document.. just the form next to the caret

16:31 devlinsf: OH

16:31 :(

16:32 I thought you were trying to use a command line input

16:32 * chouser once wrote a perl script to parse C code backwards, starting from a cursor position

16:33 johnmn3: I've got a function that counts parens (if open-paren (inc parens)) (if close-paren (dec parens), more or less, which works...

16:34 AWizzArd: does the Master branch on github now include everything from the NEW branch?

16:34 devlinsf: AWizzArd: for core?

16:34 johnmn3: but I need to account for all the cases in which parens are loose or escaped, where the reader doesn't normally count them.

16:34 AWizzArd: devlinsf: yes

16:34 devlinsf: AWizzArd: No. In fact, this is the point of releasing 1.1

16:35 johnmn3: and I don't even know what all the cases are.

16:35 devlinsf: AWizzArd: most of new is going to wait for 1.2

16:35 AWizzArd: I used NEW in the past weeks, since the first checkins of deftype, but now see this 1.1.x and Master and New and don't know which is for me.

16:35 devlinsf: AWizzArd: new has the deftype stuff. 1.1 explicitly does not

16:36 AWizzArd: So, is New still mostly a superset of 1.1.x and Master?

16:36 devlinsf: johnmn3: You could split the body by lines, and add them one at a time

16:36 AWizzArd: Yeah, new is a superset

16:37 AWizzArd: k, thx

16:37 johnmn3: devlinsf: what do you mean?

16:38 devlinsf: johnmn3: Assume the body of your document is split by #"[\r\n]"

16:38 johnmn3: separate toplevel functions by whitespace?

16:39 devlinsf: johnmn3: Start taking lines one at a time

16:39 johnmn3: Yeah

16:39 It's ugly, but it might work

16:39 johnmn3: yea.. the programmer must adhere to that convention.

16:40 well, are there cases I'd need to account for other than ")" "(" /) and /( that' I'd need to drop from my counting?

16:41 devlinsf: Well, depends

16:41 That might cover 99.9% of stuff

16:41 johnmn3: if there are few enough cases, I'll just hack out a gnarly cond until it works.

16:41 devlinsf: Are you willing to frustrate your user at .1%?

16:42 johnmn3: do defmacros allow for a an unbalance paren?

16:42 devlinsf: Sometimes .1% wrong is acceptable

16:42 johnmn3: no, I wouldn't want it to be broken for even a small percent.

16:42 devlinsf: Okay. Spend some extra time test then

16:43 Sounds like you've got a good direction to go now

16:43 johnmn3: yea.

16:44 are there any quoting things, ~ @ # ` ' or any others that clojure makes floating (un-paired) parens accepted?

16:45 devlinsf: Not that I'm aware of

16:46 johnmn3: testing the get-expr fn against all the fns in core would probably do the trick, eh?

16:46 devlinsf: The reader treats ~ and company as a character

16:46 Look at clojure.lang.LispReader.java for more info

16:47 johnmn3: ok

17:03 AWizzArd: Why is long producing an overflow without an exception, while incing a long might throw one?

17:03 ,(long 9223372036854775808)

17:04 ,(inc (long 9223372036854775807))

17:05 qed: ,(unchecked-inc (long 9223372036854775807))

17:10 AWizzArd: also interesting behaviour: starting from 64x the same digit, it produces funny outputs, for example -1 for (long 9999999999999999999999999999999999999999999999999999999999999999). But I can add some 9's and it will always stay -1.

17:10 When I add in some different digits then the output will change

17:11 Licenser: AWizzArd: I'd guess it is because it's an cast which thinks 'the user will know what they do when forcing this to be a long)

17:14 AWizzArd: I just would not expect from testing (long 62*digit '5') that (long 64*digit '5') or (long 69*digit '5') will always produce 4099276460824344803.

17:17 hiredman: ping?

17:17 johnmn3: pong

17:18 hey, thanks for the help yall. later

17:19 hiredman: AWizzArd: 9999999999999999999999999999999999999999999999999999999999999999 is a bigint with out the cast to long

17:19 so you get a different combination of ops from c.l.Numbers

17:19 grrr

17:20 * hiredman whacks pircbot

17:21 AWizzArd: hiredman: ah, interesting, thanks for the info.

17:22 hiredman: huh

17:22 people don't waste anytime, clojurebot isn't even back in channel yet and it is already getting privmsg'ed stuff

17:23 ping?

17:23 clojurebot: hello?

17:23 clojurebot: BUENOS DING DONG DIDDLY DIOS, fRaUline hiredman

17:23 hiredman: clojurebot: ping

17:23 clojurebot: PONG!

17:25 hiredman: , (type 9999999999999999999999999999999999999999999999999999999999999999)

17:25 clojurebot: java.lang.ExceptionInInitializerError

17:25 hiredman: :(

17:25 ,(type 9999999999999999999999999999999999999999999999999999999999999999)

17:25 clojurebot: java.lang.ExceptionInInitializerError

17:25 hiredman: huh, worked at my repl

17:26 qed: works here too

17:26 hiredman: works at clojurebot's repl

17:26 ,(type 9999999999999999999999999999999999999999999999999999)

17:26 clojurebot: java.lang.ExceptionInInitializerError

17:26 hiredman: ,(type 9999999999999999999999999999999999)

17:26 clojurebot: java.lang.ExceptionInInitializerError

17:26 hiredman: ,(type 9)

17:26 clojurebot: java.lang.Integer

17:26 qed: ,(type (bigint 9999999999999999999999999999999999999999999999999999999999999999))

17:26 clojurebot: java.lang.ExceptionInInitializerError

17:26 hiredman: interesting

17:26 ~clojurebot

17:26 clojurebot: clojurebot has a lot of features

18:15 AWizzArd: Is there a hook for implementing my own printing behaviour (in the repl) for my deftypes?

18:18 liebke: AWizzArd: you should be able to use print-method for that

18:19 AWizzArd: ok, this is what i thought, but i was not sure if there is already another way for doing this

18:20 liebke: I haven't heard of a new way, but here's an example of the print-method for Matrices in Incanter, https://gist.github.com/96a1b26706acd55ea0e2

18:51 AWizzArd: I remember I read something about a keyword-let or with-keywords thing. Is it already decided if this will go into Clojure?

19:01 devlinsf: Hey, anybody here run OS X.6 ?

19:02 the-kenny: devlinsf: Me

19:02 10.6.2

19:02 devlinsf: the-kenny: The bundled JVM works?

19:02 the-kenny: devlinsf: Yes

19:03 But I think you can change the default jvm in some settings program, wait

19:03 Java SE 6 64 Bt is my default jvm.

19:04 devlinsf: Okay. I run 10.5 now, I'm probably gonna make the upgrade over the Holidays

19:05 the-kenny: Thanks for answering my questions

19:05 boyd: /Applications/Utilities/Java Preferences but on snow leopard I think you only get Java SE 6

19:05 the-kenny: The update is trivial. I had not a single problem

19:05 boyd: Yes, SE6 is the only available option, but there's one with 32 and one with 64 bit

19:06 boyd: Agreed

19:06 devlinsf: good to know

19:07 the-kenny: compilation of programs is a bit tricky because the gcc wants to create code for ppc, i386 and x86_64 by default.

19:41 Luyt: devlinsf: What I did: I just replaced the harddisk in my macmini and installed snowleopard on it. If it wouldn't work well, I could always swap my old HD in.

19:41 devlinsf: I think installation on an external HD works as well, to try things out.

19:42 devlinsf: Luyt: I've got a macbook pro, so I can't do that :(

19:42 Luyt: Well, an external HD then.

19:42 devlinsf: Oh, external??

19:42 Hmmm...

19:42 Luyt: Yes, you can perform an install of snowleopard on an external HD, and even boot from it too ;-)

19:45 But I just decided to put an Intel X25 SSD into my macmini, put Snowleopard on it, then transfered over my important files from the old harddisk (which I hooked up with a SATA to USB kit)

19:52 the-kenny: Yeah, I've done it a step more: I cloned my internal hd onto an external and upgraded sl on the external to check everything out

19:52 as everything was fine, I upgraded my internal hd after that :)

20:12 tolstoy: Before I go and write something, is there a function that tells me if any member in a given list A is somewhere in list B?

20:12 _ato: ,(some #{4} [1 2 3 3 4 5 6 6])

20:12 clojurebot: 4

20:13 _ato: ,(some #{42} [1 2 3 3 4 5 6 6])

20:13 clojurebot: nil

20:13 tolstoy: ,(some '(a b) '(1 2 3 4 a c))

20:13 clojurebot: java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn

20:13 _ato: ,(some #{'a 'b} '(1 2 3 4 a c))

20:13 clojurebot: a

20:14 _ato: ,(doc some)

20:14 clojurebot: "([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return true if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"

20:14 tolstoy: Is there somewhere that groups related core functions rather than just presents them in a big list?

20:15 _ato: http://clojure.org/sequences

20:15 tolstoy: Ah, right!

20:15 _ato: also: http://clojure.org/cheatsheet

20:15 tolstoy: I need to start book marking those subject pages. Thanks.

21:09 ztellman: is there any way to pull javadoc strings off of a method at runtime?

21:10 chouser: I don't think there's any javadoc stored in the runtime

21:10 but clojure.contrib.repl-utils has a 'javadoc' fn that will launch a browser pointing at whatever class you mane.

21:11 ztellman: hmm, I was hoping it was saved with the reflection information

21:11 oh well

21:20 interferon: flatten seems to completely flatten a list, is there a way to simply flatten the highest level?

21:23 chouser: ,(apply concat [[1 2 3] [4 5] [6 7 [8 9]]])

21:23 clojurebot: (1 2 3 4 5 6 7 [8 9])

21:24 interferon: makes sense

21:24 thanks

21:31 tolstoy: error: java.lang.IllegalStateException: repeat already refers to: #'clojure.core/repeat in namespace

21:31 Hm. str-utils2 not playing nice with core?

21:34 _ato: tolstoy: you're supposed to import str-utils2 with an alias. eg (:require [clojure.contrib.str-utils2 :as str])

21:34 and then to str/join or whatever

21:34 tolstoy: Yeah, I did that, but it's not working. Maybe I've slimed on repl too many.

21:36 KirinDave: Does anyone know whats the mystic invocation to get leiningen to pull down the 1.1.0-RC1?

21:36 tolstoy: Something wrong with (ns (:use [clojure.contrib.str-utils2 :str str]))?

21:36 Oops. I meant :as.

21:43 Nope. Aliasing str-utils2 doesn't seem to work.

21:53 chouser: tolstoy: add :only [] to your :use clause.

21:53 dublindan: I'm trying to redirect where the repl gets its input from, im trying to do something like this: (binding [*in* my-in] (clojure.main/repl))

21:53 but i cant seem to figure out how to implement my-in

21:53 tolstoy: chouser: Thanks. I've relented and gone that route. Works! ;)

21:54 dublindan: I just want to be able to return a string, but proxying clojure.lang.LineNumberingPushbackReader makes me have to create Readers and such, which seems like a lot of work to simply return a string

21:56 chouser: dublindan: you want repl to read from a string?

21:56 hiredman: ,(read-string "foo")

21:56 clojurebot: foo

21:56 hiredman: ?

21:57 dublindan: chouser: I want the repl to read its input from an external source, so i was trying to implement readLine and such to return the string read from elsewhere

21:58 chouser: dublindan: socket? file? string?

21:58 hiredman: http://gist.github.com/107140

21:58 dublindan: chouser: a java.util.concurrent.LinkedBlockingQueue

21:59 hiredman: read doesn't need neading a LNPBR

21:59 dublindan: hiredman: thanks, that looks like it might do what I want

22:01 alexyk: some cross-language fun: tried to see what a workflow would look like in Haskell. Now Haskell has no built-in maps. There's a module for it, and calls look like: M.insert x y m. So here scripting languages with built-in hashes really make it look better.

22:02 KirinDave: Man, I love the way constantly reads.

22:02 Seriously good name for a function.

22:03 alexyk: ,(doc constantly)

22:03 clojurebot: "([x]); Returns a function that takes any number of arguments and returns x."

22:03 KirinDave: In hiredman's code:" :need-prompt (constantly false)"

22:03 good stuff

22:04 alexyk: ,(constantly [1 2 {:a 1}])

22:04 clojurebot: #<core$constantly__4953$fn__4955 clojure.core$constantly__4953$fn__4955@1c7510d>

22:04 alexyk: ,(constantly 3 [1 2 {:a 1}])

22:04 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$constantly

22:04 alexyk: ah

22:04 KirinDave: (constantly true) and (constantly false) are popular.

22:05 alexyk: ,(let [fc (constantly [1 2 {:a 1}])] (constantly 5))

22:05 clojurebot: #<core$constantly__4953$fn__4955 clojure.core$constantly__4953$fn__4955@13638d4>

22:05 alexyk: ,(let [fc (constantly [1 2 {:a 1}])] (fc 5))

22:05 clojurebot: [1 2 {:a 1}]

22:05 alexyk: there

22:06 from the stupid dog tricks dept. :)

22:06 is (iterate inc 0) the shortest way to create infinite integer stream?

22:06 Haskell has [1..] or something.

22:10 * alexyk wonders if mentioning haskell here is like shopping shirtless in walmart

22:10 dublindan: hiredman: thanks, that worked perfectly!

22:11 * alexyk or rather driving a lamborghini to walmart :)

22:17 AWizzArd: Is there a foo for which (foo :my.namespace/kw) ==> ::kw ?

22:24 JonSmith: alexyk: a lot of the haskell material really helps to read to understand clojure stuff

22:25 tomoj: AWizzArd: isn't ::kw just a shortcut for :my.namespace/kw ?

22:26 alexyk: JonSmith: funny thing, I used OCaml for a while and looked at Haskell several times, but the lack of built-in maps makes them look paler for data mining. Hashtbl.insert or Map.insert ... is not flowing. But FP is pretty much the same.

22:26 AWizzArd: tomoj: there is a reader macro which transforms ::kw into :my.namespace/kw. I look for a function which goes the other way around.

22:26 alexyk: strangely sexps look nicer now. You don't have to ponder parenthesizing.

22:26 you just do it.

22:27 (just (do it))

22:27 JonSmith: yup

22:27 i've never gotten the argument against sexps

22:27 * alexyk lays dibs on the above slogan

22:28 JonSmith: although

22:28 (if (you (do (it (alot)))))

22:28 tomoj: AWizzArd: I guess..

22:28 ,(keyword (str ":" (name :my.namespace/foo)))

22:28 clojurebot: ::foo

22:28 tomoj: ?

22:29 alexyk: there should be a magic Closing Bracket. (you (do (it (a (lot} ; } closes all

22:30 JonSmith: i forget what that is called

22:30 one of the lisps had that

22:30 alexyk: the opening parens are usually clear. The closing chunk is an orgy of closing.

22:30 JonSmith: hyperparen or something

22:30 alexyk: btw a friend of mine can't understand why clojure needed to pollute lispiness with ugly []s

22:30 JonSmith: although, its not like you are going through trying to figure out how they match up :-)

22:30 alexyk: he's like, [wtf?]

22:30 JonSmith: I do! I blink them all

22:31 AWizzArd: tomoj: yes, this works. I just thought there may be something else already in it.

22:32 alexyk: are []s for vectors, and thence fun params? why couldn't we do without them?

22:32 JonSmith: i think of clojure as a datastruture programming language rather than list processesing

22:32 alexyk: why are they needed in let, for, doseq?

22:32 JonSmith: exactly

22:33 I dig []s for vectors, but why is fun params, doseq, let, not clear

22:33 JonSmith: i think its just for differentiation of binding forms

22:33 alexyk: ah

22:34 JonSmith: like in CL you have (let ((var 1) (var 2)) (+ 1 2))

22:34 AWizzArd: Gives your eyes more substance to perceive.

22:34 JonSmith: and that lets you differentiate the different variables with an extra set of parens

22:34 clojure just uses different brackets

22:34 alexyk: AWizzArd: or more irregularity to stumble on

22:35 AWizzArd: if you think so, then don't use an editor with paren highlightning

22:35 alexyk: AWizzArd: my editor is rlwrap

22:36 AWizzArd: you can have small irregularity by writing programs via 0 and 1 :-)

22:36 JonSmith: it is a bit of a pain for certain macros (there is an extra step for binding forms), but otherwise I'm kind of neutral on it

22:37 AWizzArd: I did CL 6 years before I discovered Clojure. I prefer the Clojure style, using []s.

22:38 alexyk: you can write your own let which will behave like CLs if you wish.

22:38 tomoj: alexyk: why insist on rlwrap?

22:38 AWizzArd: n8

22:39 alexyk: well I enjoy Clojure, that's just what my friend asks :)

22:39 tomoj: simple for remote server

22:39 tomoj: ah

22:39 actually..

22:39 how?

22:39 sounds more complicated to me

22:40 alexyk: tomoj: works for now, my lein has rlwrap java ... in it. technomancy added it for me. :)

22:41 tomoj: oh, but you're not editing files on the remote server?

22:41 alexyk: rlwrap stores history locally, is searcheable, beats jline hands down.

22:41 tomoj: my TextMate has a command to send a selection to the term where the repl is.

22:42 tomoj: yeah, but I think I've heard you here more than once complaining about the different ways that clojure is hard to write :)

22:42 tolstoy: alexyk: Oh, cool. Do you just start up a swank server and TextMate sends to it?

22:42 alexyk: but most often I do one-ling-liners in repl and paste them back locally if they're worth it. I don't use swank at all.

22:42 tolstoy: Ah.

22:42 alexyk: TextMate sends either the current line, or selection if present, to the tab of iTerm called "Clojure".

22:42 tomoj: meanwhile I have paredit in my repl, so.. not very sympathetic :P

22:43 alexyk: tomoj: that's the part of clojure-mode for emacs?

22:43 tomoj: no paredit is separate

22:43 alexyk: is there a single .el I can drop into .emacs and be uber-clojure-emacs-geek?

22:44 tomoj: I don't think so

22:44 alexyk: or a couple... is there a fixed agreed upon clojure-mode?

22:44 JonSmith: that's a good idea though

22:44 there is clojure-mode and paredit

22:44 slime is nice too

22:44 tomoj: and swank-clojure

22:44 JonSmith: yeah

22:44 alexyk: is slime orthogonal to swank-clojure?

22:44 JonSmith: you know, i don't think i even use slime with clojure

22:45 liebke: I wrote about setting up emacs, slime, swank, and paredit today: http://incanter-blog.org/2009/12/20/getting-started/

22:45 tomoj: I think package.el can install them all

22:45 JonSmith: yup

22:45 tomoj: liebke: cool

22:46 alexyk: liebke: you da man again!

22:47 liebke: :)

22:47 tomoj: I think there are some tweaks to paredit needed

22:47 alexyk: liebke: you bowed before the magesty of maven, too! :)

22:48 liebke: ah, I've resigned myself to it for Incanter, but I wouldn't recommend it to smaller projects. I just need Leiningen to work correctly on the Mac again

22:49 alexyk: liebke: I think mvn is a safe bet, especially for cross-platform stuff with Java and (performant) Scala.

22:50 but nothing prevents pom.xml and project.clj from coexisting

22:50 liebke: true. and when talios has got polyglot support for clojure-based config files, I think it will be fine.

22:55 alexyk: liebke: I'm surprised how well sexps work for data-mining. You can have a long one-liner which does a clearly defined job, and is well-bounded. OCaml or Haskell would have multi-liners, harder for repls and copy-pasting.

22:56 and built-in maps are the killer

22:56 liebke: I agree, sexps are great on a repl, much better than any other syntax I'm familiar with

22:57 alexyk: I'm pondering things like joins of maps on keys for graphing. That's a generalization of my typical EDAs. Combine one x with various y's.

22:57 When data is in Mongo, that joining can be done selectively quering the database.

22:58 liebke: very cool, i'm hoping you'll write about your set up some time

23:00 alexyk: liebke: yep, after the submission deadline for a paper is done with...

23:00 liebke: great

Logging service provided by n01se.net