#clojure log - Jan 29 2009

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

0:00 hiredman: you appearing to be indicating that you agree with me, but what you are saying seems contradictory to what I am saying

0:00 whidden: hmm eval is not quit the same thing as i understand it.

0:00 pjb3: yeah, I know what happens at the jvm level is stack based

0:01 * whidden thinks about it a bit more.

0:01 pjb3: so in some way, shape or form, when eval happens, the jvm pushs some values onto a stack, and then eventually executes some instruction that pulls values off the stack and maybe puts new ones on

0:01 hiredman: (defn eval "Evaluates the form data structure (not text!) and returns the result." [form] (. clojure.lang.Compiler (eval form)))

0:01 ^- source

0:02 whidden: Sorry just having nightmares with the evils of eval from CL days.

0:03 pjb3: Wow, that's interesting. It recursively calls eval? When does it stop?

0:03 whidden: if you "save" the sequences of evals on forms you will be doing pretty much much load-file does.

0:03 durka42: no, that is calling the eval method on clojure.lang.Compiler

0:03 not recursing

0:03 hiredman: pjb3: eval is a method of clojure.lang.Compiler

0:04 ,(macroexpand '(.foo bar))

0:04 clojurebot: (. bar foo)

0:04 whidden: recursive calls to eval can be done

0:04 hiredman: ,(macroexpand '(.foo bar baz))

0:04 clojurebot: (. bar foo baz)

0:04 knapr: clojurebot: download?

0:04 clojurebot: download is http://code.google.com/p/clojure/downloads/list

0:04 pjb3: ah, didn't realize that

0:05 hiredman: huh

0:05 actually it isn't

0:05 wai

0:05 pjb3: ok, so can we say that compile time and evaluation are roughly the same thing and there's very little distinction between the two?

0:05 hiredman: it is

0:05 I liad

0:06 knapr: how do i build the clojure.jar?

0:06 hiredman: pjb3: clojure compiles everything

0:06 pjb3: Obviously the difference between expansion time and compile/eval time are critical

0:06 hiredman: knapr: with ant

0:06 durka42: or maven

0:06 i know nothing about maven

0:06 hiredman: expansion happens between read and eval

0:06 pjb3: hiredman: Right, but do I really care about at which point clojure is compiling and at which point it's evaluating?

0:07 hiredman: it depends

0:07 knapr: fack why is it compiling to clojure/classes?

0:07 pjb3: hiredman: righ, read the text, expand the macros, then compile/eval

0:07 knapr: (prn *compile-path*)

0:07 hiredman: close enough for me

0:07 pjb3: reader macros happen at read time

0:08 pjb3: I should say, read the text, build the data structures, expand the macros, then compile/eval?

0:08 whidden: dang can't find a good source for recursive evaluation. But its somewhere in the scheme lit.

0:08 durka42: ,(read-string "(.foo bar)")

0:08 clojurebot: (.foo bar)

0:10 hiredman: ,(. clojure.lang.Compiler (eval '(+ 1 2)))

0:10 clojurebot: DENIED

0:10 hiredman: good

0:10 whidden: expand macro's is a bit of tricky thing in clojure, being lispy-ish

0:11 one has to keep in mind that "code" is being created and maybe evaluated before sending on to the compiler.

0:11 hiredman: whidden: evaluated == sent to the compiler

0:12 we just saw, looking at the clojure source, that eval calls the compiler

0:13 Compiler.java has some weird looking formating

0:13 durka42: most of rhickey's java does :)

0:14 pjb3: durka42: Maybe Rich wrote clojure because he couldn't read his own Java code :)

0:14 hiredman: :P

0:16 whidden: where does the fx load come from?

0:17 durka42: hmm?

0:18 whidden: ah.. its in compiler

0:20 and load eventually calls eval - the heart of the compiler interpreter.

0:21 so its a wave and a particle.

0:21 hiredman: ...

0:21 durka42: what is it with clojure and physics analogies

0:22 hiredman: an "interpreter" that emits bytecode is a compiler

0:23 durka42: yes

0:23 although you can play games with calling the JVM an interpreter of bytecode

0:23 whidden: i guess here is where where cross swords as to what is a compiler. :)

0:23 s/where/where we/

0:24 but its really a small small thing

0:24 * durka42 notes that the above regex doesn't work right

0:24 durka42: yeah

0:24 unless one is trying to get clojure to work in an applet or on android

0:24 whidden: so i'll give the point.

0:24 durka42: where bytecode generation is entirely taboo

0:25 whidden: it wold not matter

0:25 hiredman: durka42: is why you, you know, pre-*compile* to bytecode

0:25 whidden: you would just have to do a two step process at most

0:25 durka42: but no eval, right?

0:25 hiredman: durka42: if you say so

0:26 21:26 durka42 : where bytecode generation is entirely taboo

0:26 whidden: eval is built into the clojure, so you could still get away with eval, even if there is only machine code underneath.

0:26 hiredman: *sigh*

0:26 clojuer is on a vm

0:26 there is never just machine code underneath

0:26 whidden: if the jvm is flat on the hardware

0:27 hiredman: it is still a jvm

0:27 whidden: so a jvm instruction is a native hardware instruction

0:27 pjb3: hiredman: it doesn't have to be, you could but hardware that implements the jvm instruction set directly

0:27 whidden: what would you have then?

0:27 pjb3: what he said :)

0:27 whidden: that ajile chip does just that.

0:28 hiredman: whidden: if it was am chien like the one durka42 described where "bytecode generation is entirely taboo" then even then, no eval

0:28 whidden: but you can "compile" on an x86 and run the "byte" code on the ajile chip.

0:28 hiredman: eval generates bytecode

0:29 whidden: yes, i agree, but it need not.

0:29 durka42: wow, cool

0:29 * durka42 looks at ajile

0:29 hiredman: whidden: if we are just making stuff up then why not have puff the magic dragon add up your numbers?

0:29 whidden: on your system you would have to tell eval to generate native.

0:30 that's what all the decent lisps do today.

0:30 hiredman: whidden: you would have to write an entirely new eval

0:30 whidden: only the back end.

0:30 i.e. the emitter

0:31 and if your native code followed the jvm byte code then things would go very fast

0:31 hiredman: the difference between jvm bytecode and x86 asm is huge

0:32 whidden: yep.. if that was my target then I'd use SBCL and call it a day. :)

0:33 but a lot of the RISCs like android have similar characteristics as a JVM byte code.

0:34 you also might get some help from the chip supplier to make a byte-code to native conversion tool for you.

0:34 taking that you could cobble eval to it and have fun.

0:36 of course there is still the compile time semantics and run-time semantics that may crop up. Have not thought all those issues through.

0:37 have a gander at : http://sbcl-internals.cliki.net/Compiler

0:38 that's basiclly what hotspot does for us with the jvm i think.

0:39 * whidden just notices the time.

0:39 * durka42 makes a note to gander when he has time

0:39 * whidden now understands why things are blurry.

0:39 whidden: gtg... have fun

0:40 * whidden tries to find the off button.

0:40 durka42: it's near the on button

2:30 fffej: Is there a Clojure equivalent to sublis in Lisp?

2:33 dhaya: ffailla: I don't know CL. but check out replace, if thats what you want.

2:34 fffej: thanks dhaya, that's near enough!

2:35 dhaya: np

2:39 Lau_of_DK: Top of the morning gents

2:52 replaca: Lau_of_DK: hi!

3:24 tuna-fish: This is a really stupid and basic question from a newbie lisper: What is the proper way to call a function (that takes no arguments) n times and collect the responses into a list.

3:24 map and for both seem to have clumsy syntax for this case.

3:28 hiredman: tuna-fish: you could build a lazy-cons of function calls

3:28 zakwilson: I would use (take n (repeatedly f)), though that gives you a lazy seq instead of a list.

3:28 hiredman: *cough*

3:28 or that

3:28 hoeck: zakwilson: yeah

3:28 tuna-fish: zakwilso: thank you, that seems nice

3:28 Laziness is not a problem.

3:29 zakwilson: This being Clojure, it's probably more idiomatic in most cases to use the lazy seq.

3:42 I'm trying to use the AOT compiler and having fail. (ClassNotFoundException) I can use or require the lib in question and the classes directory exists.

3:45 hoeck: zakwilson: classes directory must also be in classpath

3:46 zakwilson: classes directory is in the same directory as the source file (which I can load by ns name with use or require)

3:48 hiredman: ./classes/ needs to be on the classpath, relative to where you running compile

3:48 not in the same dir as the .clj file

3:50 zakwilson: The working directory is the same dir as the .clj file and contains a classes directory. I also tried setting *compile-path* to the absolute pathname of the classes directory.

3:50 hiredman: zakwilson: that is not right

3:51 the .clj file needs to be in a directory that matches the namespace it uses

3:51 zakwilson: Right... it is.

3:52 * hiredman makes a guess

3:52 hiredman: single segment namespace?

3:52 eg (ns foo)

3:53 hoeck: zakwilson: the classpath must include the wherever/classes/ directory cause it tries to load the compiled stuff from that directory

3:53 hiredman: zakwilson: how are you launching clojure?

3:54 zakwilson: Wait... I think I know what the problem is.

3:54 I'm launching it from emacs with slime.

3:54 hiredman: tell me you aren;t using add-classpath

3:55 Lau_of_DK: im not, dont worry

3:55 zakwilson: No, though I just tried to see if I could fix it that way. One moment.

3:55 hiredman: ~add-classpath

3:55 clojurebot: add-classpath is bad, avoid it. I mean it!

3:59 zakwilson: Ok, fixed. I hadn't had enough caffeine to properly parse what you were saying, hoeck.

4:04 Does working with classpaths ever get less annoying?

4:09 hiredman: ~jar directory

4:09 clojurebot: jar directory is find .jars/ -type f -name \*.jar -print0|xargs -0|sed "s/ /:/g"

4:10 hiredman: I have a directory I put all my jars in,do CP=`that command line`

4:10 and java -cp $CP clojure.main

4:11 swank-clojure seems to add all the jars in ~/.clojure/ to the classpath

4:34 ayrnieu: zakwilson - yeah, it's one of those 'newbie mirage' problems that goes away as you approach it.

4:36 Raynes: In my experiences Classpath never gets less annoying.

4:39 zakwilson: I guess I could have emacs add the working directory and any "classes" directory in it to the classpath before starting slime.

4:40 Come to think of it... ASDF can be annoying too.

4:40 Raynes: I don't actually use Clojure, I just idle in here because all the cool kids are doing it.

4:52 ayrnieu: I have (for x in $HOME/java/lib/*.jar; do CLASSPATH=$CLASSPATH:$x done), and then have makefiles near my projects that ( cd clojure; svn up; ant ). symlinks in the first directory already point to the newly created ifles.

5:53 zakwilson: Is there currently a definative "how to make an executable jar" page? The ones I'm finding seem to be a bit out of date, and my uninformed attempts are producing jars that don't work.

5:57 AWizzArd: ,(def counter (atom 0))

5:57 clojurebot: DENIED

5:58 Raynes: zakwilson: This helps http://groups.google.com/group/clojure/browse_thread/thread/192d9ed627ee4dcb?hl=en

6:00 AWizzArd: ,(time (let [counter (atom 0)] (doseq [i (range 1000000)] (swap! counter inc))))

6:00 clojurebot: "Elapsed time: 756.384 msecs"

6:00 AWizzArd: ,(time (let [counter (atom 0)] (doseq [i (range 1000000)] (swap! counter inc))))

6:00 clojurebot: "Elapsed time: 514.148 msecs"

6:03 zakwilson: Raynes: That's looking a lot like what I'm doing, but I'm getting "can't find main class", even though it looks like it's in the right place when I look inside the jar.

6:05 Raynes: I got that as well, and I gave up because I was sleepy.

6:05 Good luck.

6:06 zakwilson: At least I'm not the only one.

6:08 ayrnieu: http://java.sun.com/docs/books/tutorial/deployment/jar/

6:12 zakwilson: ayrnieu: Thanks. I've looked at the docs and my jar appears to be correct. I suspect the problem is elsewhere, as I get the same error trying to run it on the command line.

6:13 as in "java -cp ./ my.classname" from the classes directory

6:35 Got it working - the problem was that all of clojure wasn't there in the classes folder.

7:53 Holcxjo: Start-up times of such a simple "Hello world" jar are quite sobering... 0.3 sec for a Java hello worlds app, 6.5 sec for a Clojure one... (on my low-power netbook)

7:53 Raynes: That's sickening.

7:53 D'oh well. I'm off to bed.

7:53 * Raynes goes to sleep.

8:06 jdz: Holcxjo: is your app compiled?

8:06 and more importantly, is the Clojure compiled...

8:09 Chouser: I have this on my java command line to shave a few percent off my clojure startup time: -Xbootclasspath/a:clojure.jar

8:12 Holcxjo: jdz: I followed the instructions on http://groups.google.com/group/clojure/browse_thread/thread/192d9ed627ee4dcb?hl=en

8:12 I.e. compile clojure files and clojure.jar unpacked before re-packing into my hello.jar

8:14 classes/clojure/ still contains both the *.clj and the *.class files

8:14 Will clojure pick the pre-compiled class files or load the .clj files?

8:15 zakwilson: clojure will prefer the compilled class file unless the clj is newer.

8:18 Holcxjo: Hmmm. Removed the .clj files and now it takes ~4.6 sec

8:19 Better, but still in the oder of 15x slower than Java

8:20 zakwilson: Clojure's startup time is going to be slower.

8:21 Holcxjo: Yes, I understand that...

8:21 ... was just a bit shocked about the order of difference

8:23 zakwilson: What sort of machine are you on?

8:24 I'm getting 1.4s for a hello-world type jar on a T2300.

9:08 Lau_of_DK: The latest partition-by from contrib breaks on my system, after eating all of my memory - why?

9:34 (partition-by #(> % 5) [1 2 3 4 5 6 7 8 9 10])

9:35 This fries my memory in about 5 minutes - why?

9:36 cgrand: hmm nice bug

9:36 ,(let [s (seq [1 2])] (identical? (rest s) (rest s)))

9:36 clojurebot: false

9:37 cgrand: that's why partion-by fails on vectors

9:37 (or ranges)

9:38 ,(partition-by #(> % 5) (apply list [1 2 3 4 5 6 7 8 9 10]))

9:38 clojurebot: java.lang.Exception: Unable to resolve symbol: partition-by in this context

9:49 Lau_of_DK: hmm

9:49 lisppaste8: cgrand pasted "fixed partition-by: now works with vectors and ranges!" at http://paste.lisp.org/display/74492

9:50 * danlarkin wants regression tests for clojure

9:53 Chouser: danlarkin: people are working on that. you could help!

9:53 * danlarkin scoffs

9:55 Chouser: danlarkin: do you want your json lib to be in contrib?

9:56 danlarkin: if it is do I have to send someone patches to update it?

9:57 Chouser: danlarkin: not if you have commit privs to the svn repo

10:01 danlarkin: Chouser: I guess there's certainly advantages for having it in contrib

10:02 Chouser: there are, though there may also be drawbacks. ...which is why I'm asking. :-)

10:03 The reason I thought to ask is that it may be more "discoverable" in contrib than at github.

10:03 rhickey_: danlarkin: Library authors can get contrib privileges

10:03 danlarkin: what've you got?

10:04 danlarkin: rhickey_: ah, a json lib

10:05 Chouser: I haven't talked to Stuart Sierra yet, but it's possible he knew of your lib but wanted one in contrib (for licensing or dependency reasons)

10:05 or perhaps he didn't know about yours. Either way, including yours in contrib may help solve whatever his problem may be.

10:05 shoover``: danlarkin: what regressions are you concerned about? there are some tests and I'm willing to do more

10:08 danlarkin: shoover``: just worried about the weird small corner cases that see bug fixes but no tests, so that bug (or a related one) can pop up again

10:10 shoover``: I submitted tests for the last 6 or so trunk bug fixes. I will continue to monitor

10:11 danlarkin: shoover``: oh cool very nice

10:11 Chouser: I'll think this over

10:12 rhickey_: danlarkin: I'm definitely interesting in hearing about things that cause people to not contrib

10:12 Chouser: danlarkin: ok. but at the very least you should tell the google group that your lib exists.

10:13 rhickey_: http://groups.google.com/group/clojure/browse_frm/thread/affb08d66c048c7f

10:19 danlarkin: :o now I have no excuses left not to mention it

10:20 Chouser: rhickey_: I just noticed gen-interface is still in contrib. That should go away, right?

10:20 shoover``: clojure, knocking down barriers since 2007

10:21 rhickey_: Chouser: I think so, yes

10:21 fanda: shoover``: i was also monitoring bugs, here they are:

10:21 Bug? overflow check in Numbers.minus

10:21 http://groups.google.com/group/clojure/browse_thread/thread/3db6cb2b71008e73

10:21 Is this boolean behavior intentional?

10:21 http://groups.google.com/group/clojure/browse_thread/thread/d2c7c33d5b1e25aa/81ba3175da9a877c

10:22 Bug (I think): Can't sort collection of vectors containing big integers

10:22 http://groups.google.com/group/clojure/browse_thread/thread/14873f9b1a1f65a8/2ce5be560683f0d2

10:22 Non-numeric characters clarification

10:22 http://groups.google.com/group/clojure/browse_frm/thread/56500dabe531258a

10:22 bug: bean returns the wrong kind of false

10:22 http://groups.google.com/group/clojure/browse_thread/thread/6191b681c669247d#

10:23 shoover``: fanda: are you writing tests for those, or asking me to?

10:24 StartsWithK: lisppaste8: help

10:24 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

10:25 fanda: shoover``: no, I am not writing those tests

10:25 I was writing some sequence tests, but all my finished tests are now as patched in clojure-contrib issues page

10:25 lisppaste8: StartsWithK pasted "untitled" at http://paste.lisp.org/display/74493

10:26 fanda: (fanda = Frantisek = fsodomka)

10:26 StartsWithK: brr.. not title; well, cells system using watchers

10:27 i modeled it after the one posted on mailing list

10:27 shoover``: fanda: ok, those are on my list now

10:28 StartsWithK: so, is it ok to implement IRef in such a way when my Cell class is just a proxy for real Ref?

10:28 fanda: shoover``: thank you!

10:28 shoover``: except the first one... I don't see a fix commit number, so I'll wait for that

10:29 you're welcom

10:29 e

10:29 gnuvince: ,(apply str (take-while #(not= % \u0000) [65 66 67 0 68 69]))

10:29 clojurebot: "65666706869"

10:29 gnuvince: ,(apply str (take-while #(not= % \u0000) (map char [65 66 67 0 68 69])))

10:29 clojurebot: "ABC"

10:32 ayrnieu: ,"hi\0there"

10:32 clojurebot: Eval-in-box threw an exception:Invalid digit: t

10:39 fanda: as discussed earlier:

10:39 (let [s (seq [1 2])] (identical? (rest s) (rest s))) => false

10:39 is this a bug or not?

10:40 whidden: Shoover et. all: thanks for the help yesterday

10:41 Chouser: fanda: I doubt that's a bug. There's not much in clojure that promises identity.

10:41 kefka: Question: if I call a function and it blocks, and I want to exit the function without killing the Repl, how do I do so?

10:42 shoover``: whidden: you're welcome. btw, do you have to press Enter to get a REPL?

10:42 Chouser: kefka: that question applies equally well to Java, and as far as I can tell the answer is "you shouldn't"

10:42 whidden: Shoover: twice

10:43 Chouser: kefka: http://java.sun.com/j2se/1.5.0/docs/guide/misc/threadPrimitiveDeprecation.html

10:43 kefka: Chouser: Got it. However, I'm just testing something at the Repl, not running it in production.

10:44 whidden: shoover: for novices to emacs that might be an issue, right now i shrug and plow ahead.

10:44 shoover``: whidden: right. the point of the Box is 0-click REPL for beginners. I'm not pushing a new version until I figure that out

10:45 Chouser: kefka: well, you could try one of those functions they're warning against. :-)

10:45 whidden: i'd be happy to test and poke around. I had some time this morning while stranded on the train and I couldn't see where to start looking.

10:46 a pointer as to where the problem might be would be helpful, if you knew.. ;)

10:47 its a strange disconnect looking at clojure code in one panel, emacs lisp in another, and CL in a third.

10:47 francois___: Hi all!

10:47 Just wondering what library you use to parse YAML from Clojure

10:47 Or do yo call into Java?

10:47 shoover``: my guess is something with encodings or newline processing. the only clues are double "user>" prompts and that it works correctly on Vista

10:49 * whidden sighs and heads out to look at emacs encodings.

10:49 shoover``: if you search for encoding in slime.el, you'll be busy for weeks

10:49 whidden: lol

10:51 yes i can well imagine that would be the case.

10:52 fanda: shoover``: Are you working on any tests except bugs? I was working on predicates (basically anything with '?' at the end :-) and on sequences. Asking, so that we don't duplicate our effort :-)

10:52 Chouser: identical? is still strange to me. I found it on http://clojure.org/other_functions

10:52 Is there any place where I can look for deeper description?

10:55 knapr: how do I create a script for windows to be run at the command prompt?

10:55 whidden: on a separate, but equally important front for me, is doing serial IO from clojure under Win32 and/or linux. Is javax.comm the only player?

10:57 * whidden looks at his last sentence and notices the word "player" could be very misleading.

10:57 shoover``: fanda: just bugs. I'll post to the group if that changes

10:57 Chouser: fanda: 'identical?' in Clojure is the same as == in Java

10:58 fanda: ouky douky

10:59 shoover``: knapr: you want to run a clojure script from the command prompt? run this and check out the options: java -cp clojure.jar clojure.main --help

11:04 you can make a batch file to doctor the classpath and command line args

11:09 AWizzArd: Clojure basically offers two commonly needed test functions for equality, out of the infinite set of equalities.

11:11 knapr: shoover: iw ant to run a java .class file, but i dont want to fill in all the details every time

11:11 rhickey_: danlarkin: we haver a winner! http://clojure.org/libraries

11:12 danlarkin: it's so lonely :)

11:13 rhickey_: danlarkin: not for long, I'm sure

11:25 fanda: rhickey_: just don't forget to put http://clojure.org/libraries link somewhere on the menu...

11:25 streams are hidden too - what about some group named R&D :-)

11:28 scottj: I have some flat sorted data (vector of strings) and I need to be able to search it quickly by prefix substring. filter isn't quite fast enough. Is there an easy way to turn it into a tree or something that can take advantage of the sort?

11:29 rhickey_: fanda: libraries will go on menu when more populated, streams maybe never

11:29 fanda: rhickey_: ok

11:30 rhickey_: ok, next episode of the name game...

11:30 danlarkin: *sigh*

11:31 fanda: rhickey_: almost thought I was bugging you too much

11:31 ;-)

11:32 rhickey_: I'm working on the lazy branch, where sequences can be fully lazy. Calling seq on some-coll yields nil or an ISeq as always,

11:33 but now a non-nil seq has a first and (name to be determined, code-name "more"), where more is not iseq/nil, but something on which you can call seq

11:34 Chouser: maybe-more

11:34 rhickey_: One option is to change the meaning and type of rest to be more, e.g. (rest aseq) -> seqable

11:34 lots of breakage

11:35 the other is to define (rest aseq) === (seq (more aseq))

11:35 and have a new more fn

11:36 I'm inclined towards the latter, and am looking for a good name for "more"

11:36 should be short

11:37 danlarkin: cdr :)

11:37 rhickey_: danlarkin: it's definitely not cdr, although I haven't decided how far to constrain the type

11:38 meaningful would be good too :)

11:39 Chouser: rest, others, further

11:39 danlarkin: my brainstorm has resulted in: further, additional, extra

11:39 Chouser: I don't know why I said 'rest'. sorry.

11:40 fanda: rest => more, remain, remaining, remainder, tail, leftover, residual :-)

11:40 achim_p_: butfirst :)

11:40 Chouser: after

11:41 fanda: so far 'tail' looks nice to me

11:42 rhickey_: the existence of rest, as well as the need to change lazy code currently using rest, and the possible (likely) confusion between when to use rest and more, makes it possibly desirable to use a rest variant, like lazy-rest, restl, rest-coll etc

11:43 Chouser: I don't love the length, but the meaning of 'lazy-rest' is nice.

11:43 danlarkin: I like lazy-rest the best out of those options, even though it's kinda long

11:43 jkantz: lazy-rest plays well with lazy-cons

11:43 danlarkin: Chouser: get out of my head!

11:43 fanda: + lazy-rest

11:44 Chouser: You'd call 'seq' on it to make it concrete, right? ...either nil or a LazyCons

11:44 lrest might be ok, but I still might prefer lazy-rest.

11:45 It seems likely 'rest' would still be used a good deal more often. lazy-rest would help point out to readers you've being particularly careful about laziness when you use it.

11:45 AWizzArd: is the l prefix already used somewhere else for indicating lazyness?

11:46 jkantz: (with-out-str (map print '(1))) => "" ???

11:47 Chouser: not that I know of

11:47 lisppaste8: rhickey pasted "fully lazy filter" at http://paste.lisp.org/display/74500

11:47 Chouser: jkantz: 'map' is lazy

11:48 ,(with-out-str (dorun (map print '(1))))

11:48 clojurebot: "1"

11:48 rhickey_: the fully lazy filter above is correct in the new model, and free of the current spanning bug

11:48 jkantz: oh ok, I'm still adjusting to laziness

11:48 Chouser: jkantz: the reason you're running into it here is that 'print' has side-effects

11:49 rhickey_: but using lazy- where more goes is not quite right, as no additional laziness is there. more can return nil/iseq for concrete data structures

11:49 Chouser: jkantz: it probably doesn't belong as an argument to 'map', though without seeing your real usage, it's hard to know what else to recommend.

11:51 fanda: can I know which function is lazy or not? is there something like (lazy? map) => true ???

11:51 noidi: what's wrong with "more"?

11:51 jkantz: oh I'm doing this wrong ... trying to flatten a list of strings into one with spaces between

11:52 Chouser: jkantz: I'm guessing you've used other lisps before?

11:52 jkantz: yeah ... this is close (map concat (interleave '("1" "2") (repeat " "))) ... what's concat for strings?

11:52 oh, java fns

11:52 Chouser: jkantz: 'str' builds a string of its arguments

11:52 arbscht: ,(str "a" "b")

11:52 clojurebot: "ab"

11:53 Chouser: ,(apply str (range 10))

11:53 clojurebot: "0123456789"

11:53 fanda: jkantz: http://code.google.com/p/clojure-contrib/source/browse/trunk/src/clojure/contrib/str_utils.clj

11:53 see str-join

11:54 jkantz: thanks fanda

11:54 fanda: you are welcome

11:55 rhickey_: noidi: nothing inherently wrong with more

11:59 noidi: i prefere "more"... it's like saying "more, please" instead of referring directly to the rest of the elements, like "rest" and its variants imply, imo

11:59 -r

11:59 +r-e... can't even fix my typos :)

12:00 rhickey_: noidi: very Oliver Twist-ian interpretation, but I'll take it :)

12:01 noidi: hehe

12:15 fanda: (doc nth)

12:15 clojurebot: Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works for strings, Java arrays, regex Matchers and Lists, and, in O(n) time, for sequences.; arglists ([coll index] [coll index not-found])

12:16 brianh: hi all. I'm trying to wrap my head around all this lazy stuff.

12:16 fanda: nth says that it works on "regex Matchers" - what is it?

12:16 brianh: how would more differ from force?

12:16 fanda: is it #"a*b" etc...

12:17 ayrnieu: ,(nth #"a*b" 1)

12:17 clojurebot: java.lang.UnsupportedOperationException: nth not supported on this type: Pattern

12:17 fanda: exactly

12:18 bitbckt: ,(doc re-find)

12:18 clojurebot: "([m] [re s]); Returns the next regex match, if any, of string to pattern, using java.util.regex.Matcher.find(). Uses re-groups to return the groups."

12:18 bitbckt: (for example)

12:18 fanda: no no, I am questioning nth behavior or its doc

12:19 leafw: any recommended way to capture the output of a program that runs and finishes, in a terminal? Via (.exec (Runtime/getRuntime) "xmms2 list") , for example

12:21 bitbckt: fanda: re-* all operate on regex matchers; to use nth, you could use something like re-matcher to return a matcher

12:21 fanda: ok, I get it now

12:21 thanks

12:21 bitbckt: np

12:21 cooldude127: so is there anyway to make the clojure repl print certain objects differently?

12:22 durka42: you can add methods to the print-method multimethod

12:22 see Chouser's recent patch for ref printing

12:22 ayrnieu: look in src/clj/clojure/core_print.clj

12:23 cooldude127: ayrnieu, durka42: thank you

12:23 durka42: http://clojure.googlecode.com/issues/attachment?aid=3251654005916676481&name=print-iref.patch

12:23 cooldude127: shit that's what i was afraid of, that's not gonna do anything for me

12:24 ayrnieu: why isn't it?

12:24 cooldude127: ayrnieu: i wanted a way to say, print a certain struct differently

12:25 but it looks like it dispatches on class

12:26 yup definitely dispatches on class

12:27 Chouser: cooldude127: I have an unposted unmentioned patch I was playing with to do that.

12:27 ayrnieu: so write a method for all structs and then have it do its own dispatching.

12:27 cooldude127: yeah i just thought about that

12:28 Chouser: care to paste what you got?

12:29 i assume just do a (defmethod print-method clojure.lang.PersistentStructMap

12:30 do structs have something that indicates what type of struct they are?

12:31 Chouser: withuser=> #^{:custom-print (fn [o w] (.write w (format "#<my-map %s>" (pr-str (with-meta o nil)))))} {:a 1}

12:31 #<my-map {:a 1}>

12:33 lisppaste8: Chousear pasted "patch to support :custom-print" at http://paste.lisp.org/display/74507

12:33 cooldude127: Chouser: so if i have a function that creates these for me, i could just attach the metadata there and it would just work

12:33 Chouser: cooldude127: right

12:34 and because meta-data is carried through assoc/dissoc etc., you could tag your empty map with a :custom-print and then as you build and change it, it would print the way you want.

12:35 cooldude127: Chouser: so your patch makes that work for anything, but if i want to do this for just my purposes, i could make a defmethod on just structs, and do essentially the same thing, cuz i don't want to mess with clojure.core

12:38 Chouser: yeah, that ought to work. Though you're messing with the global print-method table, so I'd be careful.

12:38 cooldude127: i'll try it in a little bit, i need to go, we'll see how this works

12:38 Chouser: for example, what happens if somebody else has their own custom defmethod for structs

12:39 I'd much prefer to have :custom-print officially supported -- it composes much better for multiple libs

12:40 cooldude127: Chouser: yeah, i just want something right now, i'll do it your way once it's part of the language

12:40 leafw: how can one pass a character literal to indexOf method of String?

12:40 (.indexOf "that" \h) fails

12:40 ayrnieu: ,(class \a)

12:40 clojurebot: java.lang.Character

12:40 leafw: yes, I know. But (char \h) also fails.

12:41 Chouser: ,(.indexOf "that" (int \h))

12:41 clojurebot: 1

12:41 leafw: int!

12:41 woah

12:41 Chouser: .indexOf actually wants an int. :-P

12:41 ayrnieu: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html

12:42 leafw: indeed. I always passed 'h' on the java side.

12:42 ayrnieu: I guess those are ints the way they are in C.

12:43 (no, they're char.)

12:59 cooldude127: Chouser: i just realized something. if a struct doesn't have custom-print, i need to fallback on the default printing of the map behavior. how do i do that?

13:02 durka42: this might help:

13:02 ,((methods print-method) clojure.lang.IPersistentMap)

13:02 clojurebot: #<core$fn__5324 clojure.core$fn__5324@eb840f>

13:03 durka42: i.e. you could grab the old one before you override it

13:04 ,(((methods print-method) clojure.lang.IPersistentMap) {:a 1} *out*)

13:04 clojurebot: {:a 1}

13:05 durka42: i believe that line of code soundly defeats the purpose of a multimethod

13:07 bitbckt: durka42: you did good, kid. real good.

13:10 durka42: hmm

13:10 hiredman: clojurebot: comp is <reply>use comp for a point free, pointless style

13:10 clojurebot: Ok.

13:10 cooldude127: lol

13:10 durka42: ,(((methods print-method) java.lang.Number) {:a 1} *out*)

13:10 clojurebot: {:a 1}

13:10 durka42: i forgot about comp

13:10 dammit, i overrode clojure.core with a parameter name again

13:14 acieroid: how can I say to clojure that I define methods later in the source code ?

13:15 durka42: declare

13:15 (doc declare)

13:15 clojurebot: defs the supplied var names with no bindings, useful for making forward declarations.; arglists ([& names])

13:16 Peter_anagio1: join #wauk

13:16 acieroid: ok, thanks durka42

13:17 rhickey: Chouser: have you got URLs for the net.n01se libraries? http://clojure.org/libraries

13:19 lisppaste8: knapr pasted "py" at http://paste.lisp.org/display/74512

13:23 * danlarkin wonders if it's time for clojure to get a PyPI

13:26 Chouser: rhickey: net.n01se.clojure-classes is at http://tinyurl.com/clojure-classes

13:26 rhickey: Chouser: and repl-utils?

13:27 durka42: that's in contrib, no?

13:27 Chouser: oh, I posted the wrong namespace for that one

13:27 i'll fix it

13:27 rhickey: Chouser: thanks

13:29 Chouser: done

13:44 Kerris7: Quantity of Stuart Halloway's weekly "Programming Clojure" edit count as an indicator of Clojure volatility :)

13:45 durka42: what is the quantity?

13:47 Kerris7: I'm afraid I don't know, durka42.

13:48 It was a tongue-in-cheek (?) suggestion since I don't know about measuring volatility. :)

13:48 knapr: anyone good with windows batch scripts? i want to have a script than i can just run so i dont have to append allt he class fiels each time

13:49 ayrnieu: knapr: http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started

13:54 cooldude127: ok i got my structs printing correctly. it feels so dirty, but it works

14:01 Chouser: I wonder if individual defmethods should be marked with the namespace where they were defined, so that other namespaces can't replace them.

14:01 eh, I guess that doesn't fully clean up the situation.

14:06 Kerris7: clojurebot: help

14:06 clojurebot: macro help is http://clojure-log.n01se.net/macro.html

14:06 Kerris7: clojurebot: latest

14:06 clojurebot: latest is 1238

14:08 cooldude127: how long has that macro help thing been there?

14:16 Kerris7: cooldude127: no idea, I was just trying to find help for clojurebot

14:16 does anyone here use Clojure installed from MacPorts?

14:17 I also have JLine installed from MacPorts and I'm wondering if there's a convenient way to launch clj-jline

14:17 durka42: i remember someone trying, and running into problems

14:17 trying macports clojure, that is

14:18 Kerris7: durka42: macports clojure does work now, they've included a clj-jline.sh file which doesn't quite work

14:18 ah well, I can live without this

14:19 durka42: hmm, what's the error

14:19 Kerris7: clojurebot: paste?

14:19 clojurebot: lisppaste8, url

14:19 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

14:19 Kerris7 pasted "bash script error" at http://paste.lisp.org/display/74514

14:21 hiredman: Kerris7: looks like jline isn't in your classpath

14:21 durka42: hmm, where does macports put clj-jline.sh?

14:21 Kerris7: durka42: /opt/local/var/macports/sources/rsync.macports.org/release/ports/lang/clojure/files/clj-jline.sh by deafult

14:21 default*

14:22 durka42: oh ok, thought it might be somewhere else too

14:22 maybe a more concise path

14:23 Kerris7: only two instances of that file exists on my computer, the other is the same file cp'd to my home with chmod +x

14:23 hiredman: you're right, I forgot that the macports installation of JLine doesn't place jline into the classpath automagically

14:27 durka42: if you edit the last line in clj-jline.sh to include $CLASSPATH in the -classpath argument to java, and then add jline.jar and clojure.jar to your $CLASSPATH, then it works

14:30 Kerris7: thanks durka42

14:30 durka42: probably clojure-contrib.jar for good measure

14:42 knapr: when i un my scrip runmp3.py it starts the subprocess as it should but the script is still active. can i escape from the pyhonscript and return to the command prompt once the java program is started?

14:45 skillet-thief: if I type (spit "file" (str "12:34:34"))

14:45 and then (with-in-str (slurp "flomp") (read))

14:45 cooldude127: what's the write way to write docstrings, in regards to wrapping and indentation

14:45 *right

14:46 skillet-thief: i get an error "Invalid number: 12:34:34"

14:47 kotarak: cooldude127: "foo\n<space><space>bar", at least this looks nice when printed. Having a reasonable line limit also helps when printed in the terminal

14:47 cooldude127: YMMV

14:47 skillet-thief: why is (str "12:34:34") being treated as a number and not as a string?

14:48 kotarak: skillet-thief: 1:1 user=> (str "12:34:34")

14:48 "12:34:34"

14:48 cooldude127: kotarak: the problem with <space><space> is it's not always two space indentation. like i'm using test-is with (with-test), so all my defns are indented 4 spaces to start

14:48 kotarak: skillet-thief: looks like a string

14:48 cooldude127: I had this case also. Then I still chose two space indent. It looks ugly in the code, but nice when printed.

14:49 cooldude127: skillet-thief: (read) sees 12:34:34, which looks like a number to start, and it tries to parse it as such

14:49 (read) is the clojure reader, so it is trying to parse clojure code

14:49 skillet-thief: cooldude127: that makes sense. So what do I do to serialize correctly?

14:49 cooldude127: not really sure

14:49 ,(pr "str")

14:49 clojurebot: "str"

14:50 cooldude127: ,(print "str")

14:50 clojurebot: str

14:50 cooldude127: that might be a clue

14:50 i have to go

14:50 durka42: read-string?

14:50 cooldude127: i'll be back

14:50 skillet-thief: thanks

14:50 durka42: ,(read-string "\"12:34:34\"")

14:50 clojurebot: "12:34:34"

14:50 kotarak: (pr-str) returns a string. Might be handy.

14:52 skillet-thief: ok, (read-string) would work if that was all I was reading, but "12:34:34" is part of a bigger file I am slurping.

14:52 kotarak: skillet-thief: try (pr-str ...) instead of (str ...) in your original example.

14:53 skillet-thief: kotarak: ok, just a sec

14:53 kotarak: 1:1 user=> (with-in-str (pr-str "12:34:34") (read))

14:53 "12:34:34"

14:54 skillet-thief: yeah, me too

14:55 and in the file, there are quotes. so I need quotes for this to work, but I might need to add them manually before serializing...

14:56 (pr-str "12:34:34") => "\"12:34:34\""

14:56 kotarak: skillet-thief: there is a way to print clojure "things" in a way to read them back in.

14:57 skillet-thief: doesn't work for everything though... eg. fns

14:58 skillet-thief: 1:11 user=> (binding [*print-dup* true] (println (sorted-set 1 2 3) "String"))

14:58 #=(clojure.lang.PersistentTreeSet/create [1 2 3]) "String"

14:59 skillet-thief: kotarak: ok, that looks interesting.

14:59 i guess I thought it would be kind of automagic.

14:59 kotarak: Hmm.. Maybe fns *do* work under certain conditions.

15:00 skillet-thief: yes. you simply print like above and then simply (read) to get stuff back.

15:01 skillet-thief: kotarak: I'm going to try to work through your suggestion with (binding...

15:01 I'll end up learning something anyway.

15:08 lisppaste8: leafw pasted "xmms2 GUI" at http://paste.lisp.org/display/74518

15:08 leafw: just for fun: a trivial GUI front-end to XMMS2 (which is command-line only).

15:11 Chousuke: not really command line only... just multi-client :)

15:12 * Chousuke uses both the CLI interface + some awesome keybindings (my wm is "awesome") and a deskbar plugin for searching and playing specific songs

15:13 leafw: the only tricky part of this simple GUI is knowing how to use the AbstractTableModel, or rather, knowing that JTable has such bizarre way of working.

15:13 cooldude127: JTable = pain

15:14 Chousuke: are there no java bindings for xmms2 though? :/

15:14 I guess the C bindings could be wrapped with JNA

15:16 cooldude127: i just discovered the clojure inspector. that freaked me out a little bit

15:18 knapr: (not (empty? xs)) , is there (not-empty? xs) or soemthing?

15:18 cooldude127: knapr: ,(not-empty [1 2 3])

15:18 ,(not-empty [1 2 3])

15:18 clojurebot: [1 2 3]

15:19 cooldude127: ,(not-empty [])

15:19 clojurebot: nil

15:19 Chousuke: isn't there a line-seq or something for going through lines in a stream?

15:19 cooldude127: knapr: yes there is :)

15:21 Chousuke: ah, right, there is

15:21 (doc line-seq)

15:21 clojurebot: Returns the lines of text from rdr as a lazy sequence of strings. rdr must implement java.io.BufferedReader.; arglists ([rdr])

15:21 Chousuke: knapr: see that :)

15:21 cooldude127: (doc not-empty)

15:21 clojurebot: If coll is empty, returns nil, else coll; arglists ([coll])

15:27 Chouser: It's more normal to use 'seq' instead of 'not-empty', unless you specifically need the original collection object in the not-empty case.

15:28 Cark: chouser : what if rich removes nil punning ?

15:28 or was that scraped ?

15:30 Chouser: even then he was going to keep 'seq' returning nil for empty things

15:30 it was just a matter of 'rest' or other seq functions returning "seq or nil" vs. possibly a stream or other object.

15:30 Cark: ah i see

15:36 StartsWithK: i have a small question about post "Got a Clojure library? ", if my lib contains number of sub-libraries, all for different purpose, should i list them all under one description or divide them in separate descriptions per sublib? (it is cca 10 libs under same repository)

15:36 hiredman: is it possible to compare two symbols disregarding their namespaces?

15:36 StartsWithK: and, there will be no end date to responding? so if new libs are created it is ok to list them later?

15:37 hiredman: well of course it is possible, but, you know, without turning them into strings or keywords

15:37 cooldude127: why doesn't (assert ...) have some sort of message argument? it would be nice to explain these sometimes

15:38 StartsWithK: also, what counts as library.. like, i have a web framework/lib, and another project with generic web componets using that lib, should i list them too?

15:43 danlarkin: hiredman: use (name) on them both perhaps?

15:44 cooldude127: i think he wanted to avoid that, but i don't think theres another way

15:45 danlarkin: StartsWithK: whatever you want/think is justified to be listed on clojure.org/libraries

15:45 cooldude127: re: assert, I know! I wrote a "my-assert"

15:46 cooldude127: danlarkin: code?

15:46 danlarkin: cooldude127: I just copy&pasted the assert macro and added another arg and had it print that out

15:47 cooldude127: lol that works

15:48 StartsWithK: danlarkin: and listink dependencies, is it ok to just list organisation artifact and version of dependency as specified in ibiblio maven repository?

15:49 hiredman: danlarkin: :(

15:49 I guess that'll do

15:50 Chouser: ,(apply = (map name '(foo/bar baz/bar)))

15:50 clojurebot: true

15:53 danlarkin: StartsWithK: I'm sure just the name of the dependency and a revision number if need be is fine

15:54 StartsWithK: danlarkin: thanks

15:56 hiredman: I think clojure.zip needs a find-replace function, that takes a zipper, a predicate, and a fn, nexts through the zipper and if the predicate is true for any next, it applies the fn

15:56 cooldude127: does the with-test macro in test-is work on defmethods?

15:57 red_fish: how can I implement a persistent linkedblockedqueue

15:57 ?

15:57 hiredman: lisppaste8: url?

15:57 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

15:58 hiredman pasted "pointlessly pointful" at http://paste.lisp.org/display/74521

16:02 durka42: interesting

16:02 zippers used to implement infix operators

16:02 lisppaste8: hiredman annotated #74521 with "example usage" at http://paste.lisp.org/display/74521#1

16:04 Chousuke: lisppaste8: generalise that for arbitrary operators.

16:04 eh

16:04 hiredman: !

16:04 hiredman: Chousuke: !

16:05 so I copied the MIT license from somewhere and just sort of stuck my name in the copyright bit, but you are have done alot with clojurebot so I was wondering if you want to be included in LICENSE?

16:05 Chousuke: I'm fine either way :)

16:06 * durka42 notes that pl is strictly 2-ary

16:06 hiredman: yeah

16:07 well, fix it then :P

16:07 lisppaste8: StartsWithK pasted "Cell system; cells can now depend on normal object properties, like swing widgets" at http://paste.lisp.org/display/74522

16:09 durka42: hey, that could be useful

16:09 so cells are like lazy variables?

16:10 StartsWithK: durka42: yes, they are updated only when there parent are updated

16:10 Chousuke: neat

16:10 StartsWithK: for now parent can be anything you can attach watcher with add-watcher and in this version any object property for who you can provide some sort od listenere

16:10 Chousuke: looks like something that should go into contrib :)

16:11 certainly somewhere other than a lisppaste :P

16:11 StartsWithK: Chousuke: http://bitbucket.org/ksojat/neman/

16:11 hiredman: and lisppaste has not root in which to look for the CPL.txt mentioned in the header

16:13 StartsWithK: so for now its missing object-property -> cell and object-property -> object-property connection types

16:32 AWizzArd: Is it just me or is http://clojure.org/repl_and_main blank for others too? rhickey, should there be something on that page?

16:32 lisppaste8: knapr pasted "unbound variable" at http://paste.lisp.org/display/74526

16:32 knapr: someone can take a look at that?

16:33 Kerris7: AWizzArd: looks blank to me too

16:34 danlarkin: AWizzArd: there was a post on the mailing list about that very page

16:35 AWizzArd: ic

16:35 danlarkin: AWizzArd: Stephen C. Gilardi says he'll have something there in a few days

16:36 durka42: knapr: display-song looks internal the layout function

16:36 so you can't get at it from outside

16:37 scottj: How do you define an alias for a function in a way that the function parameters will still display in slime?

16:37 knapr: durka42: ah ok, ofc

16:37 but then how do I do? then I have to redeisgn the whole thing...

16:38 StartsWithK: knapr: just (def display-song (JLabel.)) outside your layout function (for quick fix)

16:39 knapr: yeah i was thinking that but its ugly no?

16:42 StartsWithK: knapr: you can change play-next so it takes that label as one of the arguments

16:44 durka42: can gen'ed classes have members?

16:45 StartsWithK: durka42: you can declare :state

16:45 AWizzArd: scottj: you would have to write a macro for aliasing, which expends into a defn

16:46 expands

16:47 knapr: StartsWithK: thanks ofc good tip

16:47 StartsWithK: durka42: but i think it will be declared public, so if you declare in gen-class :state state, you can acces it from outside with (.state your-object)

16:52 hiredman: how can I find the arity of a fn?

16:52 is there some function? I looked a little through IFn.java and friends

16:52 AWizzArd: hiredman: (:arglists (meta #'+))

16:53 hiredman: AWizzArd: that is getting it from a var

16:53 what about anonymous functions?

16:53 (fn [a b] [a b])

16:54 if that was handed to you as x, how do you get an arity count for x

16:55 Chouser: I don't think you can

16:55 AWizzArd: with some tricks

16:55 shoover``: Does anyone have examples of clojure apps actually using clojure.contrib.sql or resultset-seq?

16:55 AWizzArd: you could try to call it inside a try/catch block

16:55 and if you land in catch you have a chance to find out more about it :-)

16:56 hiredman: Chouser: :(

16:56 Chouser: the official interface of a fn is that it accepts any number of args

16:56 it's just that calling some of them throws an exception

16:57 hiredman: internally fn throws and Arity exception but that gets caught and a more generic IllegalArgumentException is thrown

16:57 ugh, putting try catch around everything is lame

16:58 Chouser: and since fn's don't take metadata (yet), there's nowhere else to put that kind of info.

16:58 hiredman: maybe I'll wait on auto-partial till fn's can take metadata then

16:59 Chouser: you can require users to pass in a Var

17:29 I just don't understand what people have against (some #{3} '(2 3 4))

17:30 hiredman: *shrug*

17:31 hmm

17:32 cooldude127: wait so sets are functions that indicate if something is in the set?

17:32 Chouser: yep

17:33 cooldude127: i love the way clojure makes functions out of EVERYTHING

17:33 Chouser: except regular expressions

17:34 cooldude127: :(

17:34 Hun: that'd be perlish

17:34 (:

17:35 Chouser: I thought I saw somewhere that a patch for that would be accepted, but it's hard to figure out how to make a final Java class act like a Clojure function.

17:37 cooldude127: can multimethods have multiple arities?

17:37 Chouser: yes

17:37 kotarak: cooldude127: yep

17:37 cooldude127: how does that work out in practice?

17:37 Chouser: frequently the dispatch function ignores all but the first arg

17:38 Holloway's book has a fantastic example, though.

17:38 kotarak: (defmutli foo (fn [x & _] (class x)) (defmethod foo String [x a] ...) (defmethod foo Integer [x a b c & bla] ...)

17:39 cooldude127: cuz i'm writing a library for linear algebra, so i'm doing stuff with adding matrices and numbers and stuff, and so it'd be cool to have the addition and multiplication functions and stuff accept many arguments

17:39 but maybe this is easier to do with multimethods for just the two-arg case and then just use reduce

17:42 hiredman: ,((comp (partial apply some) list) #{3} '(1 2 3))

17:42 clojurebot: 3

17:42 hiredman: hmmm

17:42 no improvement at all

17:45 cads: does anyone here use the enclojure addon for netbeans?

17:51 hiredman: ,(((comp (partial partial (comp (partial apply some) list)) (comp set list)) 3) '(1 2 3))

17:51 clojurebot: 3

17:51 hiredman: ,(((comp (partial partial (comp (partial apply some) list)) (comp set list)) 10) '(1 2 3))

17:51 clojurebot: nil

17:51 * Chouser blinks

17:51 hiredman: partial partial is a bad sign

17:51 cooldude127: oh

17:51 my

17:51 god

17:51 hiredman: what are you trying to achieve here?

17:52 hiredman: point free contains?

17:52 cooldude127: whyyyyy

17:52 lol

17:52 Chouser: "point free"?

17:52 hiredman: point free seems so hip and happening

17:52 cooldude127: hiredman: it is in haskell, but nobody likes it in lisp

17:53 only in the simplest of cases

17:53 hiredman: http://www.haskell.org/haskellwiki/Pointfree

17:53 Chouser: I rewrote ther version of your inits that I have in clojurebot in point free style

17:54 I am pretty sure it still works too

17:54 tons of partial application

17:58 I guess it isn't completely pointless

17:58 ayrnieu: Chouser: I rewrote ther version of your finals that I have in clojurebot in befunge style. I am pretty sure it still works too. Tons of n-dimensional character-based computing.

17:59 hiredman: ayrnieu: I fixed the macroexpand exploding or thing

17:59 ayrnieu: (actually I only used 2 dimensions)

17:59 hiredman: ,(macroexpand '(or 1 1))

17:59 clojurebot: (let* [or__3164__auto__ 1] (if or__3164__auto__ or__3164__auto__ (clojure.core/or 1)))

17:59 ayrnieu: awesome!

18:00 hiredman: turns out it was exploding on the (or 1 1) bit not the macroexpand

18:02 danlarkin: Chouser: the contains? debate lives on!!!!

18:04 Chouser: apparently

18:07 kotarak: Someone (don't remember who) said, that after sufficient time each and every discussion will turn around the definition of words..... Instead of simply writing cool code in clojure, they prefer discussion names...

18:08 ayrnieu: names are hard.

18:08 Chouser: Ah, thank you Mr. Engelberg.

18:08 danlarkin: pah! "in?" is still shorter :)

18:13 hiredman: is there a function that given f and a evaluates to (f a) ?

18:14 Chouser: what's a?

18:14 hiredman: anything

18:14 Chouser: oh, "and a" sorry, I didn't see that.

18:14 (apply f a nil) ;-)

18:15 ayrnieu: no, that's too straightforward.

18:15 Chouser: (.invoke f a)

18:21 Chousuke: why the nil :/

18:21 Chouser: apply is all about a seq for its final arg.

18:21 Chousuke: ah, right.

18:22 rhickey: user=> (.contains [1 2 3] 2)

18:22 true

18:22 user=> (.contains '(1 2 3) 2)

18:22 true

18:22 what contains debate? :)

18:22 ayrnieu: (.contains nil 2)

18:22 ,(.contains nil 2)

18:22 clojurebot: java.lang.NullPointerException

18:27 ayrnieu: is there something like all-ns for the java side, to get java.lang , org.jdom, etc.?

18:27 AWizzArd: what I find a bit strange is:

18:27 ,(.pow 2M (.pow 2M 256))

18:27 clojurebot: 1M

18:27 AWizzArd: instead of 2M one could also use (BigInteger. "2")

18:28 rhickey: ayrnieu: no, java packages are not enumerable through the API

18:28 neither the set of packages nor the members of a package

18:29 keithb: Hi, all...How can I create a multiline comment for a function with defn?

18:29 ayrnieu: just put multiple newlines in your string.

18:29 AWizzArd: shouldn't .pow throw some exception if the resulting numbers would be too big to fit into ram, instead of just returning 1?

18:30 keithb: do you want to make a comment or documentation string?

18:30 ozy`: keithb: strings can span multiple lines

18:30 AWizzArd: if it is just a comment and you don't want to type semicolons over and over again just do (comment anything can be here)

18:31 hiredman: AWizzArd: decent editors have a facility for that sort of thing

18:31 keithb: AWizzArd, sorry, I meant documentation string. I want the doc string to be on several lines so that the reader doesn't have to horizontally scroll to read the whole thing.

18:32 Chousuke: keithb: just add newlines :)

18:34 keithb: Here's a minimal example of it not working...what am I doing wrong?: http://pastie.org/374702

18:34 ayrnieu: you have multiple strings.

18:35 keithb: How do I create a single string spanning multiple lines?

18:35 ayrnieu: "this is

18:35 one long

18:35 string"

18:35 hiredman: keithb: http://code.google.com/p/clojure/source/browse/trunk/src/clj/clojure/core.clj#2706

18:35 ^- example

18:35 dreish: Or "foo\nbar"

18:36 keithb: ayrnieu, That's what I needed. I had no idea it would be that easy. ;)

18:36 Thanks.

18:36 Chousuke: I don't like the fact that multiline docstrings have to be manually aligned though :(

18:37 hiredman: rhickey: so, any plans to expose information on fn arity?

18:37 ayrnieu: you could put (clojure.contrib.fun-util/realign-docstrings) at the end of your module.

18:39 hm, and pass it the namespace.

18:45 Chousuke: oh, such a thing exists now?

18:54 knapr: what does (. obj ...) mean?

18:54 is (.method obj) == (. obj method) ?

18:59 hiredman: knapr: (.method obj) is more like (. obj (method)) if I recall

18:59 (.method obj) is the prefered style

18:59 ,(macroexpand '(.method obj))

18:59 clojurebot: (. obj method)

19:00 hiredman: or not

19:00 ,(macroexpand '(.method obj foo))

19:00 clojurebot: (. obj method foo)

19:00 hiredman: hmmm

19:00 I have been forgeting how . syntax works

19:00 because of using hte new style

19:00 burkelibbey: If anyone's interested, here's a list of dictionary words that work with the clojure / compojure -style s->j munging: http://gist.github.com/54847

19:01 hiredman: I call Xiphojura

19:02 burkelibbey: I think expojure has a nice ring to it, but I don't want to write anything that it would make sense for :P

19:03 hiredman: clojurebot: Xiphojura is <reply>2009:Jan:29:16:03:17 <hiredman> I call Xiphojura

19:03 clojurebot: 'Sea, mhuise.

19:03 hiredman: clojurebot: jure words is <reply>http://gist.github.com/54847

19:03 clojurebot: Ack. Ack.

19:05 Chousuke: conjure is cool

19:05 * Chousuke wonders what kind of a library would suit such a name.

19:06 clojurebot: svn rev 1239; [lazy] added more to ISeq

19:06 hiredman: Chousuke: a library that auto magically turns ((fn [a b] a) a) into (partial (fn [a b] a) a)

19:07 knapr: when I close my mp3player it stills keeps playing(it uses other threads), how do I tell it to kill all threads when the app is closed(by pressing X in the upper right)?

19:07 hiredman: knapr: there is some thing you set on the JFrame that causes the jvm to exit

19:07 Chousuke: hiredman: that's really difficult in a dynamic language :P

19:07 AWizzArd: hiredman: we had this discussion some time ago

19:08 ayrnieu: a dynamic language can do it, actually, but a dynamic language programmer cannot.

19:08 Chousuke: in haskell autocurrying works nicely because every function takes just a single argument

19:08 hiredman: setDefaultCloseOperation

19:08 ayrnieu: cannot reason about programs that make use of this haskell cutesiness.

19:08 hiredman: Chousuke: which is why it would be a real trick if you did it, hence "conjure"

19:09 burkelibbey: Idea: Somebody should make a nicer way to package up clojure code without mucking around with ant, and call it "enclojure".

19:09 Chousuke: I was hoping for something more useful

19:09 hiredman: enclojure is taken isn't it?

19:09 burkelibbey: might be

19:09 hiredman: the netbeans plugin

19:09 burkelibbey: oh right

19:10 Chousuke: wasn't there some clojure-based build system mentioned on the groups once

19:10 ayrnieu: egrep 'user$' /usr/share/dict/words # ooh, trejure

19:11 (treajure. I can think of a use for displeajure.)

19:11 Chousuke - Lancet. That's the one that's in the pragprog book.

19:11 burkelibbey: ah, also good. I didn't think there would be anything good with [^o]sure$

19:12 ayrnieu: [^s]sure is what you really want

19:12 hiredman: Chousuke: lancet?

19:13 knapr: what is standard to use for storing userinfo in a one-user-app. ie not a webapp but a gui that saves some personal stuff like basedirectory etc. .txt files, database, serialzing object?

19:13 all this reajure, conjure, compojure. god it is so ugly

19:13 ayrnieu: knapr - it always is, in every language that people do it in, but they still do it. Names are hard.

19:13 danlarkin: no more -jure program names Puhleeeease

19:14 burkelibbey: Updated

19:14 clojurebot: jure words

19:14 clojurebot: http://gist.github.com/54847

19:14 knapr: does the name have to connect to clojure?

19:14 well in python ot sounds good usually but in clojure...

19:16 Chousuke: clojurebot: naming is <reply>The Clojury says to stop making puns.

19:16 clojurebot: You don't have to tell me twice.

19:19 knapr: clojurebot: namings is?

19:19 clojurebot: naming is?

19:19 clojurebot: naming?

19:19 clojurebot: excusez-moi

19:19 The Clojury says to stop making puns.

19:19 The Clojury says to stop making puns.

19:19 knapr: the Clojury == the clojure community?

19:20 hiredman: Chousuke: two puns don't make a right

19:20 keithb: Does a function defined with defn implement Runnable?

19:20 Chousuke: yes

19:20 knapr: so if i want to do a lot when closing awindow how do i do? because i cant pass a function in stupid-ass java...

19:21 clojurebot: OO?

19:21 clojurebot: OO is to programming what astrology is to astronomy

19:21 Chousuke: I think IFn implements both Runnable and Callable :/

19:22 keithb: knapr, if you're using Swing, check out the WindowListener/WindowAdapter classes. You can catch the window closing event. But there are gotchas...if you're interested I'll try to find a resource that explains it more completely.

19:22 hiredman: knapr: look at the java docs on setDefaultCloseOperation for JFrame

19:22 keithb: definitely, if setDefaultCloseOperation does what you need, it's much simpler than catching the window event.

19:23 hiredman: huh

19:23 Callable

19:24 Chousuke: or whatever the interface was called :p

19:24 hiredman: yeah that is it

19:24 ayrnieu: ,(ancestors (class (fn [] nil)))

19:24 clojurebot: #{java.lang.Object clojure.lang.IObj clojure.lang.AFn java.lang.Runnable clojure.lang.IFn clojure.lang.IMeta clojure.lang.AFunction java.util.concurrent.Callable clojure.lang.Obj java.io.Serializable clojure.lang.Fn java.util.Comparator}

19:25 hiredman: I've just never come across it before

19:26 keithb: Thanks, all. hiredman, my prev msg "definitely..." was directeod to knapr, sorry for any confusion.

19:26 hiredman: keithb: �I wasn't confused?

19:26 keithb: oh, I wasn't sure what your huh was about...

19:27 hiredman: huh, Callable

19:27 keithb: ah, I see, never mind... ;)

19:27 hiredman: I am very liberal with the linebreaks on irc

19:35 keithb: I want to write a function that loops over a range, and for each iteration, adds an item to a list, and then return the list at the end of the function. Is "for" the best approach for this? I'm finding that when I start this function in a thread, the loop doesn't seem to be run.

19:35 hiredman: keithb: for is lazy

19:36 Chouser: what do you intend to do with the list?

19:37 hiredman: there is also dotimes and doseq

19:37 are

19:37 Chouser: usually such a list would be consumed by something, in which case 'for' should work fine.

19:37 knapr: reduce

19:38 keithb: I was hoping to return the list, but come to think of it, that's not really possible from a separate thread, since Thread.run() doesn't return anything (is defined with a return value of void).

19:39 knapr: (let [xs ["a" "b" "c"]] (reduce #(conj %1 (nth xs %2)) [] [0 1 2]))

19:39 > (let [xs ["a" "b" "c"]] (reduce #(conj %1 (nth xs %2)) [] [0 1 2]))

19:40 clojurebot: at home?

19:40 clojurebot: No entiendo

19:40 knapr: > (let [xs ["a" "b" "c"]] (reduce #(conj %1 (nth xs %2)) [] [0 1 2]))

19:40 keithb: knapr, I'm familiar with reduce, but that's not really what I want; the purpose is to do a simple illustration of Clojure concurrency, so I want to increment a shared counter and log its value, time, and thread info.

19:40 knapr: ok

19:40 keithb: I think what I really need to do is increment the counter, and add a log entry to a shared list in a given transaction.

20:00 knapr: so i need to call a clojure-function when i close the window

20:00 (.setDefaultCloseOperation JFrame/DISPOSE_ON_CLOSE)

20:00 can i do that there instead of JFrame/DIS...

20:02 hiredman: knapr: no

20:02 ayrnieu: ,(let [count (ref 0)] (doseq (take 100 (repeatedly #(commute count inc)))) @count)

20:02 clojurebot: java.lang.IllegalArgumentException: doseq requires a vector for its binding

20:02 hiredman: ayrnieu: doall

20:03 ayrnieu: no, not that one.

20:03 the one for accessing refs.

20:03 hiredman: dorun?

20:03 dosync?

20:03 ayrnieu: ,(let [count (ref 0)] (dosync (take 100 (repeatedly #(commute count inc)))) @count)

20:03 clojurebot: 0

20:03 hiredman: erm

20:03 ayrnieu: I guess I do need doall :-)

20:03 ,(let [count (ref 0)] (dosync (doall (take 100 (repeatedly #(commute count inc))))) @count)

20:03 clojurebot: 100

20:03 hiredman: most likely you would want the dosync inside around the commute

20:04 or else it all happens in one transaction

20:04 which is kind of, meh

20:04 ayrnieu: right.

20:07 er, hm.

20:07 ,(let [count (ref 0)] (dosync (doall (take 100 (repeatedly #(commute count inc))))))

20:07 clojurebot: (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100)

20:07 ayrnieu: I don't want that, though.

20:08 ,(let [count (ref 0)] (dosync (dorun (take 100 (repeatedly #(commute count inc))))))

20:08 clojurebot: nil

20:15 ayrnieu: http://gist.github.com/54871 doesn't really demonstrate concurrency.

20:16 knapr: how can I generate a Java-method?

20:16 ayrnieu: proxy

20:16 clojurebot: svn rev 1240; [lazy] added more, made filter and map use lazy-seq, made Delay.Seq implement IPersistentCollection and List

20:18 ayrnieu: it's just refs and commute - with threads. In Erlang I'd make every moving part a process (or few) and then think about how they interrelate. Somebody quoted rich as planning to add something more Erlang-like. Until then, this is just parallel programming; a performance hack and not a way to design programs.

20:24 rhickey: fully-lazy approach using new more + compatible rest seems promising, moved over map and filter and Clojure still runs!

20:25 * rhickey astonished

20:28 lisppaste8: knapr pasted "untitled" at http://paste.lisp.org/display/74548

20:28 * gnuvince_ was just bit in the ass by Clojure :-/

20:28 lisppaste8: knapr annotated #74548 with "untitled" at http://paste.lisp.org/display/74548#1

20:29 ayrnieu: do you mean .addActionListener ?

20:30 baaj: http://paste.lisp.org/display/74548#1

20:30 why cant i do ^^ ?

20:31 cooldude127: baaj: addActionListener is not a function

20:32 ayrnieu: ,(let [x 1] `(1 ~x))

20:32 clojurebot: (1 1)

20:33 baaj: then what is it?

20:33 it is a method

20:33 and i do doto

20:33 ayrnieu: do you mean .addActionListener ?

20:33 cooldude127: baaj: if you want to call a method, you need to prefix it with a .

20:33 baaj: ah wait

20:34 welll illegalargument exception instead

20:59 ayrnieu: ,(let [n (ref 0) adder (agent nil)] (dosync (send adder #(dosync (commute n inc) %)) @n)

20:59 clojurebot: Eval-in-box threw an exception:EOF while reading

21:00 ayrnieu: ,(let [n (ref 0) adder (agent nil)] (dosync (send adder #(dosync (commute n inc) %)) @n))

21:00 clojurebot: 0

21:00 ayrnieu: ,(let [n (ref 0) adder (agent nil)] (dosync (send adder #(dosync (commute n inc) %)) (commute n identity))

21:00 clojurebot: Eval-in-box threw an exception:EOF while reading

21:00 ayrnieu: ,(let [n (ref 0) adder (agent nil)] (dosync (send adder #(dosync (commute n inc) %)) (commute n identity)))

21:00 clojurebot: 0

21:01 ayrnieu: ,(let [n (ref 0) adder (agent nil)] (dosync (send adder #(dosync (commute n inc) %)) (await-for 2000) (commute n identity)))

21:01 clojurebot: java.lang.IllegalStateException: await-for in transaction

21:02 ayrnieu: ,(let [n (ref 0) adder (agent nil)] (send adder #(dosync (commute n inc) %)) (await-for 2000) (dosync (commute n identity)))

21:02 clojurebot: 1

21:02 ayrnieu: I hope that what's going is still clear through all of the stupid errors.

21:13 hiredman: ayrnieu: it sure isn't

21:20 gnuvince_: Have we got a pretty printer yet?

21:21 cooldude127: gnuvince_: i wish

21:21 knapr: isnt is possible to do everything from clojure that you can in Java?

21:21 gnuvince_: cooldude127: thank you

21:22 cooldude127: gnuvince_: why?

21:22 ayrnieu: knapr - what are you trying to do that you think you can't do?

21:22 cooldude127: knapr: in theory, i'm not sure if we get everything

21:23 knapr: when I press X on my swing GUI I want to close a bunch of threads upon exiting but it seems really hard to do this since I must implement an WindowListener class and then somehow pass the running threads to that,

21:23 I mean why cant the jvm just close everything?

21:23 gnuvince_: cooldude127: I'm writing a blog post, and I have a semi-large data structure spilled out by a function. I want to format it properly, but I'm a lazy dog

21:24 cooldude127: gnuvince_: what kind of data structure?

21:24 gnuvince_: map with nested vectors and maps

21:24 cooldude127: gnuvince_: what editor you use?

21:25 hiredman: ayrnieu: (await adder)

21:25 gnuvince_: cooldude127: for Clojure, Emacs.

21:25 cooldude127: gnuvince_: can't emacs fix that up?

21:25 hiredman: ,(let [n (ref 0) adder (agent nil)] (send-off adder #(dosync (commute n inc) % 1)) (await adder) [@n @adder])

21:25 clojurebot: [1 1]

21:26 gnuvince_: cooldude127: I will still need to manually break the lines, won't I?

21:26 cooldude127: gnuvince_: oh yeah probably

21:28 gnuvince_: hmmm

21:28 that took all but 30 secondes

21:28 I must *really* be lazy

21:28 cooldude127: lol

21:32 ayrnieu: OK, I was just confused about a few things earlier, but surely this is weird:

21:32 ,(let [n (ref 0) adder (agent nil)] (send adder #(do % (commute n inc))) (await) [(agent-errors adder) @n]))

21:32 clojurebot: [nil 0]

21:32 hiredman: ayrnieu: also commute and alter return the "in-transaction-value of ref"

21:33 *shrug*

23:27 cooldude127: you know what? fuck matlab, i'm having way more fun with linear algebra in clojure

23:27 maybe it's the joy of writing your own function for a determinant

23:29 clojurebot: seen technomancy?

23:29 clojurebot: technomancy was last seen quiting IRC, 1624 minutes ago

23:29 cooldude127: maybe clojurebot could get a more useful time formatter

23:35 what's a good abbreviation for transformation?

23:38 LordOfTheNoobs: xform?

23:39 cooldude127: LordOfTheNoobs: i like that

23:48 lisppaste8: url?

23:48 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

23:49 cooldude127 pasted "bad macro" at http://paste.lisp.org/display/74556

23:50 cooldude127: anybody want to lend some macro help

23:50 when i evaluate this, i get an unsupportedoperationexception

23:50 ayrnieu: what do you want that to expand to?

23:51 cooldude127: ayrnieu: i think i want it to expand into exactly what it does

23:51 ayrnieu: oh, then it works OK.

23:51 cooldude127: i can't find anything wrong with the expansion

23:51 ayrnieu: bad things happen when i enter that last expression in the repl

23:52 and clojure's error handling is really unfortunate sometimes

23:54 ok the problem is definitely the with-meta part

23:54 the function itself is just fine

23:55 let me guess, functions themselves can't have metadata?

23:56 ayrnieu: 15:55 < Chouser> and since fn's don't take metadata (yet), there's nowhere else to put that kind of info.

23:56 cooldude127: AHHHH

23:56 man that is not cool

23:57 i think i have another way to make it work tho

23:58 ok, a big fat hack: my function will give the definition when called with no args

Logging service provided by n01se.net