#clojure log - Jan 12 2010

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

0:01 G0SUB: ctdean: which version of log4j should I use? 1.3 is obsolete, 2.0 is experimental

0:02 ctdean: G0SUB: I'm using log4j-1.2.14.jar, no idea if that's a good one

0:02 mebaran151: defn, I've built, but it wants a program called makeinfo

0:02 why can't stallman use manpages like the rest of us

0:05 Licenser_: hmmm functional chimney: (reduce #(burn %) '(wood wood wood wood))

0:06 somnium: Licenser_: isn't the smoke and heat side-effecty?

0:06 Licenser_: na we just reduce the wood to ashes

0:07 Raynes: defn: You know you can get Emacs 23 from the Ubuntu repos as far back as Hardy, right?

0:07 emacs-gtk-snapshot

0:07 Licenser_: but somnium you're right

0:08 G0SUB: ctdean: the log file path, does it need to be absolute?

0:08 Licenser_: so lets say: (defn burn [stuff] '(heat ashes smoke))

0:08 ctdean: G0SUB: I don't think so

0:08 somnium: Licenser_: hmm, you may be on to something

0:09 Licenser_: yap

0:10 arohner: hmm, I want a get-in that also does derefs as appropriate...

0:10 (get-in* foo [:a :b @ :c])

0:10 of course, writing that, I want an update-in that does the same thing

0:11 nm, that doesn't make as much sense

0:11 hiredman: get-in is called ->

0:11 arohner: hiredman: good point

0:11 hiredman: ,(-> foo :a :b deref :c)

0:11 clojurebot: java.lang.Exception: Unable to resolve symbol: foo in this context

0:12 somnium: are any of the -$> variants in contrib?

0:12 hiredman: making update-in work on mutable structures and immutable structures would be tricky

0:12 ,(doc -?>)

0:12 clojurebot: "clojure.contrib.core/-?>;[[x form] [x form & forms]]; Same as clojure.core/-> but returns nil as soon as the threaded value is nil itself (thus short-circuiting any pending computation). Examples : (-?> \"foo\" .toUpperCase (.substring 1)) returns \"OO\" (-?> nil .toUpperCase (.substring 1)) returns nil "

0:13 somnium: ah!

0:13 hmm

0:13 arohner: yeah, I realized I don't need [:a :b deref :c] on update-in

0:14 I wish those things had canonical names

0:14 i.e. thread-maybe

0:14 I don't want perlisms in my clojure

0:14 somnium: I meant the ones that move the argument

0:14 arohner: there's ->>

0:14 hiredman: oh, the icky templating stuff?

0:14 *shrug*

0:14 somnium: Ive been using an anti-> for doing (-> x (range) (>> map inc))

0:15 Licenser_: somnium: http://gist.github.com/274938

0:15 somnium: => (->> (-> x range) (map inc))

0:15 but its kind of silly

0:15 mebaran151: alright, I think I got emacs installed

0:15 hiredman: add a doto in there

0:15 mebaran151: and I can get slime

0:15 now how do I get all the goodies

0:16 hiredman: ,(doto :a (-> prn))

0:16 clojurebot: :a

0:16 :a

0:17 hiredman: (doto X (-> ((partial juxt #(.write % stuff) #(.close %)))))

0:18 of course you could just (doto X (.write stuff) .close)

0:20 mebaran151: like the infamous paredit etc

0:20 somnium: hiredman: doto in place of >> / -$> ?

0:20 hiredman: aslong as you are using -> and ->> you might as well also use doto

0:20 somnium: Licenser: =)

0:21 hiredman: (-> 10 range (>> map inc) (nth 5)) with doto?

0:27 mebaran151: rainbow parens etc

0:27 somnium: mebaran151: emacs-starter-kit has some good stuff, incluing elpa

0:28 mebaran151: I've got elpa

0:28 hiredman: there is a rainbox-paren-mode out there

0:28 mebaran151: I've got highlight parens now

0:29 somnium: mebaran151: otherwise just start collecting .el files in your .emacs :)

0:30 mebaran151: alright

0:30 so now I want to setup something like I had in netbeans

0:30 where I would load the contents of a current file and smack it at the repl

0:30 hiredman: http://delicious.com/search?p=rainbow&chk=&context=userposts|clojurebot&fr=del_icio_us&lc=0

0:32 mebaran151: I've got parens

0:36 where's a good guide to swank. like resetting the repl, etc

0:37 loading the current file in repl etc

0:40 somnium: mebaran151: you can install everything from elpa

0:45 mebaran151: will it autoload

0:46 like let's say I always want highlight-parens-mode when I'm editing a clojure file,how would I do this?

0:50 Raynes: There is a rainbow paren mode? Holy shit.

0:50 I want.

0:51 somnium: mebaran151: highlight-parentheses (from elpa) is global, and ez customization can be had via <M-x customize-group> <highlight-parentheses>, which is only a couple with keystrokes with tab

0:53 mebaran151: so everytime I open a clojure file I have to M-x highlight-parentheses?

0:53 somnium: mebaran151: oops, its not global. std way is (add-hook 'clojure-mode-hook 'highlight-parentheses-mode) but may be an option in customize too

0:56 mebaran151: where do I write this?

0:57 Raynes: mebaran151: .emacs

0:57 ~/.emacs

0:57 clojurebot: emacs is best configured for Clojure with instructions at http://technomancy.us/126

0:58 Raynes: The hell with Phil and his canonical instructions.

0:58 !

0:58 :>

0:59 mebaran151: alright let's try this

0:59 how do I switch to the slime buffer

1:00 G0SUB: people, I have this log4j.properties file in my src/ -- http://gist.github.com/274951 even then, when I log an error with c.c.logging it doesn't go into the file.

1:00 somnium: M-x slime

1:00 Raynes: mebaran151: Also, you don't have to close and then reopen emacs everytime you want to load new code in your .emacs file. Just place the cursor in space directly after the last parentheses in the sexp you want to evaluate in and do C-x C-e

1:02 mebaran151: Also, checkout http://www.emacswiki.org/emacs/InteractivelyDoThings

1:02 check out*

1:02 Quite useful.

1:04 G0SUB: OK, I figured what the problem was. c.c.logging uses java logging even when I have log4j in the classpath

1:04 hiredman: sure

1:04 mebaran151: so I want to duplicate this work process

1:04 G0SUB: if I call (log4j-logging) it works fine.

1:04 hiredman: logging decides which logging system to use at compile time

1:04 mebaran151: in Netbeans, I'd type ctrl-shift-n to switch to the name space I'm working in

1:05 then I'd type alt-l to load the file

1:05 then I'd whack at it in the repl

1:06 Raynes: Switch to the namespace you're working on the old fashioned way (ns ..) and then load the file via C-c-C-l or recompile the file via C-c-C-k

1:07 somnium: compile wont work without the classpath setup

1:07 Raynes: ^

1:08 somnium: http://github.com/technomancy/swank-clojure

1:10 mebaran151: I've got swank clojure up and running

1:10 can I get autocomplete

1:10 so ns woudl complete my namespace

1:11 optimizer: is there something like sqlite, but for clojure?

1:11 mebaran151: optimizer, derby?

1:11 hypersonic sql

1:12 optimizer: mebaran151: nice; thanks

1:33 mebaran151: so how would I get this setup

1:33 I want three or four buffers

1:33 one to list directories and files to switch between

1:33 one as the main editor

1:34 one as my project repl

1:34 and maybe one where I could get java and clojure docs

1:35 Raynes: mebaran151: Also, C-x 3-C-x o-C-x 2 :D

1:36 I have 3 'panes' in my set up. 2 square boxes on the right side, and a big one on the left for editing.

1:37 I'll also note that there is an Emacs file manager. M-x dired

2:09 timothypratley: ,(.comparator (sorted-map 1 2 3 4))

2:09 clojurebot: #< clojure.lang.RT$2@f4a444>

2:10 timothypratley: Any ideas what that is?

2:12 I expect it is RT.DEFAULT_COMPARATOR, but I cannot fathom why it is not an IFn

2:16 ah I see why - never mind I figured it out

2:16 a comparator need not be an IFn from java land.

2:21 Raynes: Reading about protocols. Awesome

2:23 timothypratley: Raynes: I thought you were a vim user - have you converted to emacs now?

2:23 (or back)

2:24 Raynes: timothypratley: I played with Vim long enough to find out that I can't work with VimClojure very well.

2:24 timothypratley: Raynes: ah - why is that? The REPL interaction, or editing preference, or project integration?

2:25 Raynes: timothypratley: Mostly the fact that I could never get it to work correctly.

2:25 Not that that is a VimClojure problem.

2:28 timothypratley: Raynes: hehehe yeah I hear you! It takes me an hour to install VimClojure whenever I need it somewhere... the installation instructions require careful attention I find lots of ways to make it not work.

2:41 G0SUB: timothypratley: hey, need some help with c.c.logging

2:42 timothypratley: c.c.logging is picking up util logging even when I have log4j in classpath

2:42 timothypratley: it works when I call (log4j-logging) manually.

3:00 mebaran151: thnaks Ranes

3:00 *Raynes

3:00 I gotta get used to buffers

3:01 Raynes: mebaran151: You're welcome.

3:01 And either I've lost sense of time, or that was extremely delayed. :p

3:03 mebaran151: heh, my Internet went way wonky

3:03 anyway

3:03 how do I open three buffers?

3:03 defn: C-x 3

3:03 C-x 2

3:04 if you want a new frame, C-x 5 2

3:04 Raynes: I told you that a minute ago. >.>

3:05 Well, more than a minute ago.

3:05 mebaran151: ah

3:05 that's what that did

3:05 it looked arcane

3:06 sorry, my internet went way wonky, packets flying and red lights flashing

3:06 I'm getting swank swnak not found

3:06 but it seems to work

3:07 how do I get dired to open the file in a different buffer

3:07 so I'd always have dired in a pane

3:09 Raynes: That's beyond me. I don't use dired.

3:09 mebaran151: I need an emacs manual

3:09 sigh

3:10 Raynes: mebaran151: http://www.gnu.org/software/emacs/manual/emacs.html

3:10 mebaran151: a manual not written by Richard Stallman

3:10 Raynes: Hehe.

3:10 mebaran151: who assumes that we all live in the 70's :)

3:11 Raynes: mebaran151: http://articles.techrepublic.com.com/5100-10878_11-1053058.html

3:11 somnium: mebaran151: C-x 4 d

3:12 Im starting to dig this point free stuff: http://gist.github.com/274994

3:14 Raynes: I thought >> was in core.

3:15 hiredman: ->>

3:15 completely different

3:20 mebaran151: I'm beginning to remember why I wasn't a fan of emacs

3:23 timothypratley: mebaran151: why?

3:24 mebaran151: I'd have my Netbeans setup in less than two minutes

3:24 I'm trying to get a simple setup

3:24 dired pointing at my project

3:24 a main buffer editing a source file

3:24 and a repl with my classpath

3:24 I can't seem to get all these together

3:24 timothypratley: GOSUB: I'll take a closer look

3:27 Raynes: mebaran151: Emacs isn't a plug-n-play kind of thing.

3:27 mebaran151: nope I know

3:27 but I'm not sure what I'm going to get

3:27 :)

3:27 though I do like its parentheses highlighting a little better than Netbeans

3:28 somnium: mebaran151: do you have paredit on?

3:28 mebaran151: I think I do

3:28 I took the sign of my accidentally deleting my home dir as a sign I should learn emacs as penance

3:29 timothypratley: :)

3:30 somnium: Im not sure if paredit can keep your home-dir safe, but it may coax you out of netbeans :)

3:33 mebaran151: oh dired might

3:33 I was rm -r and there was a directly named tilde

3:33 this led to certain death

3:34 how do I get the repl now

3:34 I've got a process

3:35 how do I know if I have paredit on

3:35 timothypratley: G0SUB: timothypratley: c.c.logging is picking up util logging even when I have log4j in classpath <-- do you happen to have a git project I can try (no problem if not, I can try to recreate)

3:36 G0SUB: timothypratley: it's a proprietary codebase, but I can create a minimal setup just for you :)

3:36 timothypratley: just a sec

3:37 timothypratley: GOSUB: thanks!

3:39 vy: mebaran151: In "C-h m" there should appear paredit.

3:40 mebaran151: I don't think so

3:40 how do I enable it

3:41 esj: m-x paredit-mode

3:42 mebaran151: okay

3:42 so what can I do now?

3:43 I'm sorry for being such a total newb

3:43 all the blogposts tell you how to setup emacs, but nobody ever tells you how to use it...

3:43 Raynes: Checkout the paredit cheatsheet.

3:43 I have it set as my desktop background.

3:44 mebaran151: it won't let me type a parens...

3:44 this I feel is intentional

3:45 G0SUB: timothypratley: http://github.com/ghoseb/test-logging

3:45 Raynes: mebaran151: If you started paredit mode with open parens that need closing, you're kind of screwed.

3:45 I think I got around that somehow before though...

3:45 G0SUB: timothypratley: even now it picks up util logging

3:45 esj: Raynes: your background ! That's fantastic.

3:45 timothypratley: GOSUB: thanks for that - I'll see what I can do with it.

3:45 Raynes: esj: It's the place where it's most accessible. :p

3:46 G0SUB: timothypratley: cool

3:48 mebaran151: slime also is constantly telling me its polling

3:48 can I disable this?

3:48 Raynes: Eh, that means Slime never opened, and it means something's wrong.

3:48 Is there a *slime-repl clojure* buffer, or just an *inferior-lisp* buffer?

3:49 If there is just an *inferior-lisp* buffer, you might want to paste what it says.

3:53 esj: mebaran151: you're probably in for a frustrating morning.

3:53 Licenser: hrm I have trouble to understand require and use I think ...

3:53 mebaran151: it's an inferior lisp buffer

3:54 it seems run clojure

3:54 and it picks up my class path

3:54 esj: you also need a *slime-repl clojure* buffer

3:54 which is where you clojure it up

3:54 Licenser: when I've two namespaces that both require a 3rd one, it should be loaded in both right? And they should not confligt?

3:54 mebaran151: Polling "/tmp/slime.6498".. (Abort with `M-x slime-abort-connection'.) [1147 times]Cancelled connection attempt.

3:55 esj: mebaran: Raynes is correct

3:55 Licenser: mebaran151: your problem is likely that slime does not find the clojar jars

3:55 mebaran151: alright

3:55 Licenser: wait a second I dig something up

3:55 mebaran151: let's have slime find them!

3:56 esj: mebaran151: I'm not the guy with the answers to this one. I had endless unhappiness until I did exactly what http://learnclojure.blogspot.com/2009/11/installing-clojure-on-ubuntu-910-karmic.html said to do

3:56 Licenser: you've to adjust your .emacs file

3:57 Raynes: mebaran151: At the beginning of your inferior-lisp buffer, do you see something with RestFn<init> in it?

3:57 Licenser: http://gist.github.com/275037 <- this one did the trick for me

3:57 G0SUB: timothypratley: that's a skeleton lein project. just open a repl with that project and use c.c.logging and check the *impl-name*

3:57 timothypratley: if you call (log4j-logging) it will work fine. just that (or ...) form is not working correctly (don't know why).

3:57 mebaran151: I can just start slime

3:57 there's like a graphic

3:58 M-x slime works

3:58 Licenser: mebaran151: I had the exact same problem this fixed it for me

3:58 slime was working swank-clojure project not

3:58 Raynes: mebaran151: Slime is NOT working unless there is a *slime-repl clojure* buffer.

3:58 java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V to be exact.

3:58 Licenser: what I did was getting the swank-clojure and slime from the git site and put this in my config file

3:59 mebaran151: yep

3:59 I get slime-repl clojure

3:59 jsut not from my project

3:59 Raynes: Oh.

3:59 mebaran151: I have the clojure jars in my project: is this going to cause problems

4:01 does swank works with 1.1

4:01 Licenser: yes but I had the same problem you have with the one from epal or how that thing is called

4:02 somnium: mebaran151: did you read the readme at technomancy's swank-clojure on github?

4:03 mebaran151: oh I need the swank jar

4:08 huzzah

4:08 I've got slime

4:09 and I got it to load a file

4:09 how do I get history in the repl

4:09 Licenser: grrr

4:09 somnium: C-<up>

4:11 mebaran151: now how do I load just one form

4:11 like evaluate a def

4:12 somnium: mebaran151: slime has a lot of commands, do C-h b, to be overwhelmed

4:12 (at the repl buffer)

4:12 mebaran151: alright

4:12 a more featureful repl

4:12 Licenser: so when I have namespace a.b.c1, a.b.c2 and a.b.c3 can I require a.b.c1 in both c2 and c3 without any problem?

4:14 somnium: Licenser: yes, why?

4:14 Licenser: because I keep getting problems like 'Alias modules already exists in namespace net.licenser.epic.modules.cycle, aliasing net.licenser.epic.modules'

4:16 somnium: Licenser: Im guessing theres more requiring going on than just a b and c?

4:17 Licenser: yea :(

4:19 timothypratley: GOSUB: Yeah thanks for the example I can clearly see the behaviour, and calling (or ...) works fine ... but I have a theory why it is not working

4:20 GOSUB: I believe the issue here is that because or is a macro, and so are the XXX-logging calls, it all gets decided at 'compile' time - which for a pre-packaged jar happens before the jar gets made, at which point log4j is not in the classpath

4:21 somnium: Licenser: if the repl's been up for awhile it might be lingering vars

4:21 Licenser: I really get confused

4:21 timothypratley: GOSUB: Whereas when using uncompiled contrib, this behaviour would not happen

4:21 Raynes: mebaran151: C-x C-e with the cursor immediately after the last paren in the sexp you wish to eval.

4:22 Licenser: I geuss I can't require A from B and B from A?

4:22 timothypratley: GOSUB: I could be way off the mark here but I'll experiment a bit more with it.

4:23 somnium: only if you can explain how to the compiler

4:23 Licenser: teehee

4:25 Raynes: Licenser: That is a circle dependency. Those are bad.

4:25 Licenser: :(

4:27 timothypratley: GOSUB: sorry that made no sense hahaha forget what I said just then.

4:28 Licenser: can I entirely flush the repl from everything I 'tought' it?

4:29 Raynes: I believe you would have to restart it for that.

4:30 Licenser: hmm hmm

4:31 esj: on that subject is there an undef ?

4:31 i couldn't find it the other day

4:32 Raynes: (doc ns-unmap)

4:32 clojurebot: "([ns sym]); Removes the mappings for the symbol from the namespace."

4:32 Raynes: Aha.

4:34 kanak: I installed swank-clojure from ELPA (version 1.1.0), and I'm getting this error: "Debugger entered: (("Error in timer" slime-attempt-connection (#<process inferior-lisp> nil 2) (file-error "make client process failed" "connection refused" :name "SLIME Lisp" :buffer nil :host "127.0.0.1" :service 49525)))" when i M-x slime. I'm on a debian system. Does anyone know what the problem could be?

4:34 Raynes: kanak: Did you also install Slime via ELPA?

4:35 fliebel: Good morning!

4:35 Raynes: Morning.

4:35 kanak: Raynes: I only installed swank-clojure from ELPA. I haven't installed slime separately

4:36 Licenser: yap flushing the repl helped

4:36 Raynes: kanak: Check to see if slime and slime-repl are installed in ELPA.

4:36 If not, install them and try again.

4:36 esj: Raynes: hooray. That's a weird name, no ?

4:36 Raynes: esj: I didn't name it. ;)

4:37 esj: the naive might think that would be to do with the map function perhaps ;)

4:37 kanak: Raynes: It says slime 20091016 and slime-repl 20091016 are installed

4:37 Raynes: kanak: In that case, you might need to take this one to the swank-clojure mailing list. :\

4:37 kanak: Raynes: will do. thank you for your help.

4:39 fliebel: Clojure is good a concurrency, right? I thought it would be fun to write a computer vs computer card game of the kind where you have to shout or hit the stack when a certain combination of cards is on the table. How would I do such a thing? All the computer players need to access the stack in parallel, and the one with the best code or the most luck wins.

4:39 Raynes: fliebel: Clojure is awesome at concurrency.

4:40 mebaran151: but I think it's not good for the concurrency fliebel once

4:40 *wants

4:40 as in, it's meant to prevent those kinds of race ocnditions!

4:41 fliebel, you'd probably want to use Thread/sleep with a random value to simulate differences in response time

4:41 fliebel: That is what I was struggling with.

4:41 mebaran151: yeah you want a race condition :)

4:42 fliebel: hmhm, and I don't want to fake it, I want to make different players and test who's the best.

4:42 mebaran151: you could use a ref to moderate which player slaps its cards first

4:42 (whoever reads first wins...)

4:42 and randomized sleep to simulate different reaction times

4:44 fliebel: hmmm… What is I made one stack of cards which can be read by all, maybe via those hooks… The players then append their name to another ref and the first item on that ref is the winner.

4:44 Chousuke: that's not very interesting though.

4:45 essentially, the winner will be decided by luck. :/

4:45 fliebel: Chousuke: How would you do it then?

4:45 Chousuke: I don't know.

4:45 fliebel: The idea is that the winner is decided based on the most efficient way to check the cards.

4:47 There are a lot of combinations that lead to a match, some occur more often than others, so which you check first and how is important I think.

4:47 Chousuke: well, if you arrow direct reads of the stack then that would be most efficient.

4:47 gregh: you could model the actual comparison operations or whatever at a higher level than just clojure code

4:47 fliebel: And, I know for myself that I think the wrong way around with this game, so I'm going to simulate bad players as well

4:48 mebaran151: is there anything in emacs where I can select a bunch of region of text and align the code

4:49 format it based on clojure spec

4:49 Raynes: That would be nice, wouldn't it?

4:50 somnium: M-x indent-region?

4:51 Raynes: Well, there ya go.

4:51 timothypratley: GOSUB: after throwing out my silly theory - I tried the same test without lein - and it says "org.apache.log4j". I'm still digging into why.

4:53 mebaran151: somnium, thanks

4:53 I got emacs almost as nice as netbeans now

4:53 and I can hold side by side buffers which is nice

4:53 slime is a little bit more comfortable than the Netbeans repl

4:53 somnium: almost!? :/

4:55 mebaran151: well dired doesn't quite do what I want

4:55 and I'm still scared whenever I do a buffer command

4:55 I don't know them yet

4:55 somnium: mebaran151: that will pass

4:55 mebaran151: yeah I think it will

4:55 somnium: theres nav if you dont like dired, on elpa

4:56 mebaran151: I was wondering if you could put swank clojure in a production app

4:56 and dial into it if it started acting up

4:56 no dired itself is fine

5:03 Licenser: hmmm okay I noticed something about the REPL, it clogs up after some time and gets all ugly, is that something that is me specific or a general problem?

5:06 gregh: that's a vague explanation :)

5:07 Licenser: yes of cause, I like to put things in vauge words when they confuse me - it's a nice and fluffy feeling inside I'd love to share with the rest of the world

5:08 what I mean is after a while stuffing things in the REPL and requiering and using stuff I seem to be unable to revert it to a clean state by using (remove-ns ...)

5:11 so I wonder if there is a way to keep it clean or at least arranged in a way that makes it easy to remove it again when I change stuff around

5:11 

5:25 mebaran151: how do I make parenmatch highlighting default

5:27 spariev: mebaran151: (show-paren-mode 1) in .emacs

5:29 mebaran151: it's nice

5:29 spariev: mebaran151: btw. have you seen awesome screencast by Lau on slime/emacs http://www.bestinclass.dk/index.php/2009/12/clojure-101-getting-clojure-slime-installed/

5:30 mebaran151: can't watch screencasts: no soundcard :(

5:31 esj: mebaran151: the link I posted earlier works too.

5:31 (he uses Ubuntu, i'm osx with aquamacs and it still works)

5:32 mebaran151: I'm on Ubuntu

5:32 what link?

5:32 spariev: mebaran151: anyway, there is his .emacs in that post with lots of useful emacs-fu

5:32 mebaran151: ah yeah I saw it

5:36 Raynes: Laurent is an Emacs God.

5:37 Licenser: when I do a require :reload will that concatinate to all the require's in the file I require?

5:39 esj: i think its :reload-all ? But I may be imagining.

5:40 Licenser: esj: way thank you!

5:40 esj: np

5:43 Licenser: this is going to save me lots of trouble

5:43 timothypratley: Anyone here know the internals of lein repl? If I delete clojure-contrib from the libs dir... the repl still has access to contrib somehow....

5:44 it must be loading its own version somehow but I'm not sure where to start looking.

5:54 G0SUB: timothypratley: any news?

5:56 timothypratley: GOSUB: I've established that the problem occurs using lein, but not without, but still trying to figure out why.

5:58 GOSUB: I'm a bit stuck because I can't seem to substitute a debug contrib to lein, which I was hoping would provide the clues.

5:59 GOSUB: But I'm sure the answer is not far away :)

6:02 Raynes: What would be a better way to write this: (dosync (alter stack #(cons 2 %)))

6:03 cons' argument list doesn't allow me to just do cons 2.

6:05 G0SUB: timothypratley: cool.

6:07 timothypratley: but why, oh why? everything is in classpath, alright.

6:08 timothypratley: and oh, it happens inside slime repl too. not just lein repl. (using clojure-project)

6:12 timothypratley: GOSUB: That's handy to know!!!

6:12 GOSUB: The test I did with a custom REPL was using latest contrib/clojure

6:13 GOSUB: When I do custom REPL with the jars from lein/lib dir.... problem occurs

6:14 GOSUB: I'm starting to think this is an old bug that got fixed (hence why we couldn't see it in the source)

6:18 Licenser: hmm hmm, when I get a clojure stack trace that and there is not a single of my own functions in the trace does that mean clojure is eating it up or does it mean the error happens outside of the function calls of mine?

6:38 G0SUB: timothypratley: any idea what the bug might be ?

6:43 timothypratley: GOSUB: Nope, I'll post what I've found on the group - but in terms of solving your problem I think you'll have to stick with (log4j-logging) for now

6:44 G0SUB: timothypratley: that fact that it's private makes matters worse

6:47 timothypratley: GOSUB: *nod* yup

6:48 Licenser: hmm I think to think I have some odd bug in the printer o.O

6:50 Raynes: Also, this was the better way: (defn flip [f] (fn [& args] (apply f (reverse args))))

6:51 Followed by, (dosync (alter stack (flip cons) x)))

6:51 Flip is probably already defined in core, but I couldn't find it.

6:52 Chousuke: it's not.

6:53 Licenser: ah I know what it comes from, lazyness :D

6:54 Raynes: Chousuke: Cool, I did something right! :D

6:54 Chousuke: I'm used to using flip in Haskell, so it was the obvious solution here.

7:00 mebaran151: anybody here know the transaction syntax for clojureql?

7:05 hamza: hey guys, is it possible to write a function to file? just like using pr to write objects to a file? I would like to have function modify it a bit then write the new function to a file?

7:09 mebaran151: I don't think it is natively, but I have a coworker that has a macro that almost does it

7:09 as in, what do you mean by write it file: if it's a clojure, the variables might refer to things you wouldn't think of

7:10 hamza: (prn [2 3]) using this with with-out-str would give me string represantation of the vector that i can write to a file and read it back later, i would like to do same for a function.

7:11 mebaran151: but a function isn't simple like a data-structure

7:11 it's variables are bound to its environment

7:11 to really serialize a function, you'd have serialize its environment as well

7:12 if you just want the actual representation, you could write a macro that would take the function forms as a list of symbols and writes them somewhere

7:14 timothypratley: GOSUB: I'm off to bed, have posted about the problem http://groups.google.com/group/clojure/browse_thread/thread/79c609df3632a5d1, hopefully someone will be able to suggest a better solution.

7:15 hamza: yeah i am after the actual represantation..

7:20 optimizer: is RAII possible in clojure?

7:22 somnium: hamza: you could try something like this http://gist.github.com/275149

7:28 hamza: am i missing something? (defn-src atest [] (println "test")) i am getting unable to resolve symbol body?

7:30 somnium: hamza: ah, the tilde is wrong in the gist, updated it

7:31 hamza: somnium: greate thanks a lot just what i was looking for..

7:35 defn: When I add a dependency to leiningen, where does it all pull from?

7:35 I see some people adding things like org.markdownj/markdownj to their project.clj, but it's not in the repo anywhere

7:35 the clojars repo i mean

7:36 * Raynes added a stack implementation to the rosettacode page. :>

7:36 LauJensen: I would guess it checks Maven Central

7:36 Raynes: defn: It pulls from Maven Central, Clojars, and clojure-snapshots as far as I can tell.

7:36 defn: thanks LauJensen -- didnt know what to google on that

7:37 Raynes: defn: clojure-snapshots would be build.clojure.org/snapshots

7:37 defn: hmm, wtf is this markdownj coming from

7:37 [org.markdownj/markdownj "0.3.0-1.0.2b4"]

7:37 it's not in maven2 or in clojars

7:38 Raynes: I'm pretty sure it's in maven central.

7:38 defn: you would think, but i go into maven2/org/...

7:38 and no markdownj

7:40 ah-ha!

7:40 http://code.google.com/p/markdownj/wiki/Maven

7:41 i need to add a repository to markdown as a dependency and then i can get it

7:41 whoa im tired

7:41 Raynes: Add a repository to markdown as a dependency?

7:41 defn: i need to add a repository in my project.clj and then i can get it

7:42 yeah sorry about that, that is just incomprehensible

7:42 Raynes: How do you add a repository to project.clj? ;o

7:42 LauJensen: defn, did you check out my latest blogpost where in I show how to add your own jars to a lein config?

7:43 Raynes: LauJensen: Link pwease.

7:43 LauJensen: www.bestinclass.dk

7:43 defn: LauJensen: i didnt see that but im interested

7:43 LauJensen: click blog - click top post

7:43 defn: leiningen is still a strange mistress to me

7:44 i can do some basics like :dev-dependencies, :dependencies, :main, but havent messed with any others

7:44 Raynes: LauJensen: I referred to you as an Emacs God earlier. Do I get points?

7:44 :p

7:45 LauJensen: No, but because of your good motives I wont slap you for blasphemy

7:45 defn: dude LauJensen ! I stop checking my RSS feeds for 5 days and you manage to put a ton of awesome content up

7:45 also, you are an emacs god, your videos showed me about fuzzy completion in slime

7:45 :)

7:45 LauJensen: Yea the Hadoop stuff is pretty fun

7:45 I hope to do some massive image processing soon :)

7:46 defn: im excited about the enlive stuff

7:46 i read up on it, but im still not 100% on how to use it

7:46 LauJensen: anyway, gotta duck out a little while, will be back in 5 hours or so

7:47 defn: LauJensen: what's clojure-mode-el?

7:47 is it el or clojure-mode-l?

7:47 LauJensen: clojure-mode.el

7:47 The Emacs Lisp file which contains Clojure-mode

7:47 defn: oh -- gotcha

7:49 LauJensen: i had no idea how to do a keyboard macro on a region

7:49 that rules

7:50 ive just been doing C-u 20 C-x e

7:50 or whatever, to do multiple lines

7:51 where i make sure to put a M-x next-line

7:51 and M-x beginning-of-line

7:52 LauJensen: using enlive to get those function is nice and all, but couldn't you just use ns-publics?

7:53 LauJensen: Yes of course - But how would you show off Enlive doing that?

7:53 defn: :D

7:54 LauJensen: i have an odd request for a video

7:54 LauJensen: The important part is the (info ...) - that way you can fix stuff yourself

7:54 Whats the request?

7:54 defn: i want to see 2 hours of emacs + clojure with no particular theme, just you working on "stuff"

7:55 that includes switching windows, looking stuff up, etc.

7:55 LauJensen: Ah

7:55 I don't think I'll do 2 hours, but I might do a compilation of sorts to give an idea of the workflow, a little similar to the webdevelopment video

7:55 defn: yeah that'd be cool

7:55 id also like to know more about *organizing* clojure projects

7:56 like with a webapp im messing with, im having a very hard time separating functionality out into separate files

7:56 since they all seem to rely on one another

7:57 LauJensen: Ok - I really need to duck out now, but I'll think it over. I also have a tool in mind for organizing projects, but more on that later :)

7:58 defn: sounds good, thanks again

7:59 LauJensen: np

8:06 esj: defn: nice requests, I could use that stuff too.

8:07 gerr: hello

8:07 what's wrong with this: (defprotocol Show (show [x]))

8:08 (deftype Person [name age] Show (show [x] (str (:name x) (:age x))))

8:08 java.lang.IllegalArgumentException: Can't define method not in interfaces: show (NO_SOURCE_FILE:2)

8:09 ,(defprotocol Show (show [x]))

8:09 clojurebot: DENIED

8:14 defn: esj: ive been thinking a lot about organization

8:14 esj: i think it's important to pay attention to the type that a function returns

8:14 Raynes: gerr: http://gist.github.com/275175

8:14 gerr: Sorry for the delay.

8:14 esj: defn: me too actually, getting things properly structured is a good part of the battle.

8:14 gerr: Raynes: ok

8:15 Raynes: It appears that 'this' is implicit.

8:15 defn: so for instance, a "controller" function in my compojure app can return anything, EXCEPT html

8:15 instead of making some function (defn gen-page [] (html (interpose .......)))

8:15 Raynes: gerr: You can access the fields of the type directly in the protocol functions.

8:15 defn: you just put the (html x) part into a layout file

8:16 Raynes: I didn't realize that initially earlier, and had hell with it.

8:16 gerr: Raynes: but in defprotocol, i still need one arg?

8:16 Raynes: gerr: Yes.

8:16 It's 'this'.

8:17 gerr: hmm, thx

8:17 {newbie}: deftype? is clojure gaining an builtin OO system?

8:18 Raynes: {newbie}: Not really. No more than Haskell has an OOP system because of it's algebraic datatypes.

8:18 cemerick: ~deftype?

8:18 clojurebot: deftype is see datatype

8:18 cemerick: ~datatype?

8:18 clojurebot: datatype is see datatypes

8:18 cemerick: ~datatypes?

8:18 clojurebot: http://www.assembla.com/wiki/show/clojure/Datatypes

8:18 cemerick: sheesh

8:18 {newbie}: see ^^

8:19 Raynes: gerr: Note you can do this `(deftype Person [name age] :as x Show (show [] [x] (str name age)))' if you want to access 'this' directly.

8:19 {newbie}: OH, I'm reading programming clojure right now so I'm a couple of revs behind

8:19 Raynes: s/directly/explicitly/

8:20 gerr: Raynes: ..(Show [] [x]..) two arg list is abit odd

8:21 Raynes: gerr: Also, see the examples in (doc defprotocol)

8:21 gerr: ok

8:23 rhickey: so, who's written code that depends on defmacro creating (internally) a fn with the same signature?

8:23 Raynes: gerr: The resulting functions from defprotocol dispatch on their first argument, and that's why they have to have at least one argument.

8:24 gerr: Raynes: i see

8:34 Raynes: Somebody needs to write a book and host it for free online, like Real World Haskell.

8:34 * Raynes dreams.

8:37 * vy dreams a complete Clojure Reference in DocBook, where functions are given in some sort of BNF notation that is concise, clean, and well-defined.

8:38 cemerick: vy: functions in BNF?

8:38 overkill for sexprs, no?

8:39 _fogus_: cemerick: I don't know about BNF, but the format that the CLIPS user manual uses for its functions is pretty nice.

8:39 vy: cemerick: In some sort of BNF, for instance, CLHS is quite in this area.

8:39 s/quite/quite good/

8:39 _fogus_: +1

8:41 _fogus_: Chouser and I have adopted a similar format for our book

8:46 chouser: rhickey: now *that's* an interesting question. what are you up to?

8:47 I don't have any real code like that.

8:47 Should 'restart' be named 'restart-agent'?

8:47 cemerick: seems like a bad idea in general

8:49 chouser: I guess if you were trying to write your own (modified?) version of macroexpand or something.

8:49 rhickey: chouser: I'm thinking of supplying 2 more implicit args to defmacro expansion fns - &env and &whole

8:50 chouser: ooh

8:50 rhickey: cemerick: right, I consider any such code as relying on implementation details

8:50 and thus subject to breakage

8:51 the latter, &whole, might be the path for fn metadata

8:54 &env will preclude the implementation-dep inside things like local-bindings here: http://gist.github.com/254110

9:28 midget: Hey.

9:28 Do you know how to twist on the knife?

9:28 I can`t make it right - always cut myself

9:30 esj: well, that would be a mutating operation, so we can't help you there.

9:31 Drakeson: how do you add a repository to the 3 default ones in leiningen?

9:32 for instance, I want to add http://mirrors.ibiblio.org/pub/mirrors/maven2

10:01 lisppaste8: someone-stuck-behind-a-mean-proxy pasted "+1 for a supported way to access the environment in macros" at http://paste.lisp.org/display/93280

10:19 Raynes: Drakeson: :repositories

10:21 Of course, there isn't any example of how to actually use that, so I can't help you there.

10:54 chouser: ,({(int 5) :ok} (long 5) :not-ok)

10:58 ,({(int 5) :ok} (long 5) :not-ok)

10:58 clojurebot: :not-ok

10:59 chouser: can we use Clojure's = instead of Java's .equals() for map key comparison?

10:59 this just bit me hard.

11:05 cemerick: 1.equals(1L) is false ?!? Crazy.

11:05 rhickey: chouser: not without breaking the contract of j.u.Map

11:07 chouser: arararagag

11:10 I just spent longer than I'd care to admit tracking down a map lookup failure.

11:11 the keys of the map are complex nested maps and vectors, and printing the map keys and the item I was looking up showed they printed identically.

11:11 cemerick: that's not friendly at all.

11:12 chouser: so then I added debugging code to walk through the map, and discovered that the key and lookup value were =

11:12 rhickey: chouser: how did you end up with a long?

11:12 chouser: checking that now. I think the long came from a protobuf

11:13 cemerick: pr should probably attach suffixes to numbers as long as stuff like this is possible.

11:13 or, optionally so, perhaps

11:13 chouser: yeah, I think that was it. some of these maps are converted to protobufs and back. so this one went in as an int and came out a long

11:14 but then I looked it up using the original int

11:15 I even knew about the problem with different number types as map keys, and still didn't "get" it

11:15 ,(= (int 5) (long 5))

11:15 clojurebot: true

11:16 chouser: ,(= (hash (int 5)) (hash (long 5)))

11:16 clojurebot: true

11:18 rhickey: this is an area with no universally good answer

11:18 chouser: no kidding

11:18 well

11:18 rhickey: as long as you can have different types represent the same value

11:18 chouser: .equals() could be potentially do the "right thing" couldn't it?

11:19 rhickey: you mean if JAva changed it?

11:19 chouser: right

11:19 I guess it still couldn't support new number types like Ratio

11:19 rhickey: what about (.equals 1 1.0) ?

11:20 chouser: I understand that's a question that would come up, but this morning the difference between 1.0 and (int 1) seems much bigger than the difference between (int 1) and (long 1)

11:20 because they print differently, I would have spotted 1.0 much sooner.

11:21 Of course I'd hate for either ints or longs to print with decorations be default

11:21 and I wouldn't have thought of trying a non-default print option until after I'd identified the real problem.

11:22 *print-dup* already prints them differently

11:22 didn't even occur to me to try that.

11:23 cemerick: stuff like this is going to cause so much pain when people start seriously targeting other hosts

11:23 Spockz|lap: stuff like what?

11:30 stuartsierra: ,(.equals (long 1) (int 1))

11:30 clojurebot: false

11:30 arohner: chouser: yeah, that problem bit me hard a few months ago

11:31 different printing would have helped me catch it much sooner

11:31 stuartsierra: ,(with-out-str (binding [*print-dup* true] (pr (long 1) (int 1))))

11:31 clojurebot: "#=(java.lang.Long. \"1\") 1"

11:31 arohner: what's the problem with making longs print as "1L" or whatever?

11:31 chouser: ugly

11:32 stuartsierra: Isn't that what Java's long syntax uses?

11:32 chouser: but maybe it'd be worth it.

11:32 arohner: that's not very convincing to me when we already print 1.0 and 1M

11:32 stuartsierra: ,(pr-str 12345678901234567890)

11:32 clojurebot: java.lang.ExceptionInInitializerError

11:33 stuartsierra: ,(pr-str (BigInteger. "12345678901234567890"))

11:33 clojurebot: "12345678901234567890"

11:33 stuartsierra: ,(binding [*print-dup* true] (pr-str (BigInteger. "12345678901234567890")))

11:33 clojurebot: "#=(java.math.BigInteger. \"12345678901234567890\")"

11:33 cemerick: 1L is a lot prettier than #=(java.lang.Long. "1")

11:34 chouser: heh. true.

11:34 cemerick: I'd love to have literals like that in general, to avoid stuff like (int 1)

11:35 stuartsierra: Yes, Java uses 1L for (long 1).

11:37 chouser: (int 1) also means primitive in some contexts. I assume 1I or whatever wouldn't?

11:38 stuartsierra: chouser: probably not

11:38 1L would probably mean (java.lang.Long. "1") to the Clojure reader.

11:39 arohner: why not?

11:39 it probably doesn't now, but why couldn't it?

11:40 stuartsierra: I guess it could, in a 'loop' head.

11:40 cemerick: 1L should just expand out to (long 1), which will get boxed as necessary anyway

11:40 arohner: the reader reads 1M appropriately, so I don't see why it can't do 1L just as easily

11:42 stuartsierra: cemerick: that assumes that "L" is a reader macro

11:43 cemerick: stuartsierra: it should probably be considered something lower-level than that. Not dispatching on #, etc.

11:44 the reader can emit whatever symbols it wants as its tokenizing

11:56 rhickey: Long-term (pardon the pun) I think longs and doubles will win out as defaults, making ints as rare as shorts

11:56 stuartsierra: rhickey: That wouldn't have prevented chouser's original problem caused by interop with protobuf.

11:56 rhickey: stuartsierra: sure it would, if Clojure never boxed to Integer, only to Long

11:57 stuartsierra: Until some other library decides to down-cast long to int!

11:57 rhickey: stuartsierra: but only boxed things end up as map keys

11:58 so back to Long on box

11:58 stuartsierra: Ah, I think I see

11:58 In other words, there wouldn't be any auto-boxed java.lang.Integer

11:58 rhickey: in my do-over universe, Clojure integer literals would be longs that did exception on overflow. The only other interger would be explicitly-requested bigints

11:58 stuartsierra: Just java.lang.Long

11:59 leafw: considering the overhead of an Object, whether it has a long or an int inside will make little difference. I'd go for having only boxed Long as well.

11:59 stuartsierra: rhickey: But aren't automatic integer upgrades a cornestone of Lisp? :)

12:00 rhickey: stuartsierra: I now consider that a mistake for Lisps

12:00 stuartsierra: Huh, interesting.

12:01 rhickey: I agree that 'bad math' is unacceptable, but exception on overflow is fine, as long as explicit bigints are there and contagious

12:01 cemerick: sort of inevitable given hardware history

12:02 chouser: interesting

12:02 rhickey: In DotLisp I did exception on overflow, and it is better for 95% of the use cases

12:03 If you know you will have bigints, use 42BIG (or whatever)

12:03 chouser: but a protobuf can emit a boxed Integer too -- that would be the same problem in reverse.

12:03 rhickey: chouser: a boxed integer how?

12:03 user boxing?

12:03 reflection?

12:04 chouser: oh

12:04 rhickey: if the lang only does Long boxes, and fixes reflection boxes, then only user boxing is an issue

12:05 oh, and Java-land boxing

12:05 chouser: right, it's coming from java-land

12:05 rhickey: the Java wrapper for protobufs boxes?

12:06 LauJensen: So the compiler will handle all incoming Ints being cast to longs and the same outgoing if need be ?

12:06 rhickey: rather than generating classes with primitive fields?

12:06 chouser: oh, i see what you're saying. let me check.

12:13 the generated methods return primitives, but I'm building the clojure map from a java.util.Map

12:13 so it's java or protobuf doing the boxking, not Clojure

12:14 djpowell: if someone calls (mymacro String), is there anyway to resolve the symbol: String in that macro, into the class object: java.lang.String

12:14 chouser: ,(resolve 'String)

12:14 clojurebot: java.lang.String

12:14 djpowell: ah

12:17 rhickey: chouser: when Java is boxing you will always have to manually do matching of types. But at least with Longs-only on the Clojure side you would rarely have this problem in Clojure code, whereas it is a current issue

12:17 every now and the I contemplate these changes, but dread the pushback

12:17 breakage

12:18 chouser: yeah. In this case, I have a loop that's converting and can easily adjust the number type.

12:18 but what should I adjust to? with your proposed change, it would be easy: Long.

12:18 rhickey: right

12:19 chouser: today, I guess I'll want to convert to the minimal acceptible type. is there a fn for that?

12:19 rhickey: also, longs are on the table to get primitive arg/return support

12:19 chouser: so 1 is Byte?

12:19 chouser: :-(

12:20 rhickey: exactly

12:20 chouser: no, I want to match what Clojure would do for a similar literal

12:20 so that when the protobut has {5 10]

12:20 so that when the protobut has {5 10} and I type {5 10} in the code, they match

12:20 eh

12:21 maybe. Either that, or I want to manually cast to longs in my hand-built maps to match the declared types of the protobuf fields.

12:21 both sound like trouble.

12:22 rhickey: if Clojure defaulted to Long, I'd be happy printing all others with suffixes

12:23 but the fact is, in Java, if you put a boxed long 42 into a map key and lookup a literal 42 you won't find it

12:23 that is the map you are building and handing to Clojure

12:24 basically, types matter when numbers are used as keys

12:25 Java could have made different decisions in the boxed number tower, but that's water under the bridge

12:26 so, Long integers by default, exceptions on overflow, suffixes for all others?

12:26 * rhickey ducks

12:27 chouser: I'm on board.

12:27 :-)

12:27 cemerick: very happy about Longs and suffixes

12:28 rhickey: cemerick: and on overflow?

12:28 chouser: who are these people that cause you pain when you make beneficial breaking changes.

12:28 ?

12:28 cemerick: rhickey: aren't things going to get promoted automatically anyway?

12:28 chouser: and can I have a little one-on-one time with them?

12:28 rhickey: I hardly ever make breaking changes

12:28 cemerick: no, that's the change

12:29 chouser: I know. because you fear these bullies. ;-)

12:30 rhickey: what's funny is that, in spite of rarely making breaking changes, still sometimes get dinged for Clojure changing so fast, even though it's largely additions

12:31 cemerick: it ends up that promotion from primitive to boxed (BigInteger) is a primary perf disaster

12:31 cemerick: because on the bytecode level no single type can hold both

12:31 cemerick: clearly, I don't do enough maths

12:31 ,(-> Integer/MAX_VALUE inc)

12:31 clojurebot: 2147483648

12:32 cemerick: that's interesting -- that fails in my repl with an overflow

12:32 rhickey: here too

12:33 cemerick: anyway, that (sometimes?!?!?) fails, but this is OK currently:

12:33 ,(-> Integer/MAX_VALUE Integer. inc)

12:33 clojurebot: 2147483648

12:33 chouser: ((identity inc) Integer/MAX_VALUE)

12:34 _fogus_: Are we playing, avoid the overflow exception game?

12:34 rhickey: but Integer/MAX_VALUE is tricky as you are already into Java primitive rules

12:35 cemerick: rhickey: so, insofar as I obviously don't know what the overflow rules are currently, I can't see how I could have a defensible position (or opinion, even) on changing them :-)

12:36 rhickey: cemerick: with no Java interop in play, the rules are the traditional lisp ones - unbounded integers

12:36 cemerick: ,(inc (int 2147483647))

12:36 clojurebot: 2147483648

12:37 rhickey: the change would be that unqualified integers would be longs, and would throw on overflow rather than auto-convert to bigints

12:37 cemerick: I'm really curious about why clojurebot isn't erroring on that.

12:37 oh, I see

12:37 * rhickey off to lunch

12:38 cemerick: rhickey: if it's primarily a perf issue, I wonder if it's at all possible to opt out of autoconversion, rather than opting into it.

12:40 lpetit: Hello, is it normal to have an ArrayIndexOutOfBoundsException throw from clojure.lang code, more precisely PersistentArrayMap$Seq.first() (line 217) ?

12:40 chouser: lpetit: when you give a non-even number of items in a literal {}, yes.

12:41 cemerick: but it's not just perf, I think -- it's problems like the one I just had.

12:41 lpetit: Ah, but here first() is called from APersistentMap.hashCode() (line 101) which is called from APersistentMap.equals() (line 60) which is called from java code

12:42 chouser: ,{1}

12:42 clojurebot: java.lang.ArrayIndexOutOfBoundsException: 1

12:42 lpetit: ,(equals {1} {2})

12:42 clojurebot: 1

12:43 lpetit: ,(= {1} {2})

12:43 clojurebot: 1

12:43 chouser: ,(first {1})

12:43 clojurebot: 1

12:43 lpetit: ,{1}

12:43 clojurebot: java.lang.ArrayIndexOutOfBoundsException: 1

12:43 chouser: noo

12:43 ,(val (first {1}))

12:43 clojurebot: 1

12:43 chouser: no! those are failing for me.

12:43 lpetit: gargl

12:43 (clojure-version)

12:44 ,(clojure-version)

12:44 clojurebot: "1.1.0-alpha-SNAPSHOT"

12:44 chouser: anyway, those maps are invalid. Don't do that.

12:44 lunch.

12:44 cemerick: chouser: how does overflow impact the issue of concrete types of map keys?

12:44 lpetit: Well, it's from something read by the reader from a user source code editor ...

12:45 So the reader seems to not complain, and the exception is throw later

12:45 (doc read-string)

12:45 clojurebot: "([s]); Reads one object from the string s"

12:45 lpetit: ,(read-string "{1}")

12:45 clojurebot: 1

12:45 lpetit: ,(read-string "{1 2}")

12:45 clojurebot: {1 2}

12:46 lpetit: ,(read-string "{1}")

12:46 clojurebot: 1

12:46 lpetit: ok clojurebot is fooling us there

12:48 unfo-: any help to why my join-channel function is not being called? https://gist.github.com/5005a3004cf58b1b7df3

12:49 lpetit: Anyway, I now know how and where to catch the problem, thanks

12:52 stuartsierra: rhickey: Personally, I think rapid change is good IF it comes with a predictable cycle of stable releases

12:54 cemerick: stuartsierra: absolutely. Everything can get broken in the process of being improved as long as there's a tag for a stable build in clojure and contrib.

12:57 stuartsierra: I'm working on Contrib.

12:59 And I think Clojure itself needs more releases. 1.1 added a whole pile of stuff that could have been let out incrementally.

12:59 cemerick: more tests + a maven repo + build process would make weekly releases entirely plausible, if warranted.

13:00 stuartsierra: Maybe not weekly, but at least every 6 months. Weekly would be a lot of extra work for rhickey.

13:01 cemerick: Shouldn't be. mvn release:prepare release:perform, and you're done. *shrug*

13:02 I'm probably not seeing a lot of stuff that is happening around release time.

13:03 stuartsierra: cemerick: Not until we have a Maven build for Clojure. That's another mountain to climb.

13:04 cemerick: stuartsierra: we'll have to bag rhickey first. ;-)

13:07 stuartsierra: right

13:07 * stuartsierra departs

13:25 unfo-: if I have some data in a struct and I get it via (:somekey @mysharedstuff) how could i (in repl) get info about its type?

13:26 Chousuke: well, you can call class on it

13:27 technomancy: unfo-: C-c S-i gives you a nice inspector if you're using slime

13:28 unfo-: technomancy, nope, not using it since emacs is bizarre to me :) coding with IDEA and standard REPL

13:28 technomancy: then I guess you need to use the class function

13:29 unfo-: ty

13:40 patrkris: LauJensen: is it possible to say to clojureql that utf8 must be used when connecting to mysql?

13:41 LauJensen: patrkris: I'm pretty sure its an attribute of the driver, but we haven't wrapped it. You might be able to specify it directly on the connection-string

13:42 Uuh check it out, Clojure almost in top10 again on Hacker News :)

13:43 patrkris: patrkris: are you suggesting I modify the jdbc-url on the map returned by make-connection, or is there another way to specify the connection string directly?

13:43 LauJensen: patrkris: Gimme a sec I'll check

13:43 patrkris: LauJensen: thanks

13:44 LauJensen: patrkris: In the URL set "//localhost/db&characterEncoding=UTF-8"

13:44 2.nd argument to make-connection-info

13:44 patrkris: LauJensen: coolio, thanks

13:45 unfo-: fffffuuuuu! I had a samename struct as I had a local variable in a few places... great confusion

13:46 hiredman: use ’

13:46 or <x>

13:52 unfo-: https://gist.github.com/5005a3004cf58b1b7df3 -- why does my map fail?

13:52 hiredman: map is lazy

13:53 unfo-: aaaaah! didn't know that

13:53 so I need to use a do* function there? the doall or wotnot

13:53 or was it dorun

13:53 hiredman: sure, you might just replace the call to map with a call to doseq

13:53 unfo-: ok. thanks!

13:54 hiredman: doseq is like for, but not lazy, and it evaluates to nil

13:54 LauJensen: hehe

13:54 "doseq is not like for because..." :)

13:56 Does anybody know where _ato Alex Osborne is hiding these days?

14:02 unfo-: (dorun (map myfun mylist)) worked wonders :-)

14:03 hiredman, even tho' I read the lazy/infinite sequences chapter quite well in my view (from programming clojure) i still managed to forget that map is lazy... doh :D

14:03 hiredman, very much appreciated! :)

14:05 technomancy: clojurebot: map?

14:05 clojurebot: map is *LAZY*

14:06 * technomancy remembers when he was getting chided by clojurebot for that exact same thing.

14:07 unfo-: :-)

14:08 REPL is deceptive in this because it gives me the result I am expecting immediately

14:09 LauJensen: Yea I've been tripped up by that as well

14:09 unfo-: but now for something completely different after I submit this patch to my github

14:11 mebaran151: I think I'm finally comfortable in emacs

14:11 my penance for accidentally deleting my homedir is completed

14:12 LauJensen: hqhq

14:12 i mean... haha :)

14:12 mebaran151: eah

14:12 I'm gonna stick around

14:12 I got the the layout I like, and tab completed bufffers are kind of groovy

14:12 I'm just looking for a good window manager now

14:13 as in a quick way to switch between emacs panes

14:13 LauJensen: C-x b, aint working?

14:13 mebaran151: I mean

14:13 I have three different windows open

14:13 I'd like to switch between the repl and a pane

14:13 of doc editing really fast

14:14 LauJensen: C-x o ?

14:14 mebaran151: well it's a little basic

14:14 technomancy: mebaran151: C-c C-z switches to the repl from any clojure buffer

14:14 mebaran151: but what about switching back :)

14:14 technomancy: I don't know if there's a reverse

14:14 mebaran151: yeah

14:14 I'd like something a little more general

14:14 forwards and backwards

14:14 I'd also like an undo that doesn't make me cry

14:14 ska2342: mebaran151: checkout iswitchb, mtorus, windmove and windresize

14:15 LauJensen: mebaran151: the undo makes you cry? I really like it

14:15 technomancy: emacs' undo mechanism is carefully architected in order to avoid creating time-travel paradoxes

14:15 trust me, you really don't want to have to think about what happens when alternate timelines interact.

14:16 mebaran151: I haven't successfully undone yet

14:16 hg rollback!

14:16 hg revert

14:16 ska2342: mebaran151: you can setup a slime-selector-method for switching between clojure code files and the repl, back and forth

14:16 mebaran151: ah that was another questiong

14:17 how do I control where the slime error pane renders itself

14:17 chouser: vim undo lets you go to any version of the file since you opened it -- even branches that have been undone.

14:17 LauJensen: Its fun I was trying to remember what I do for undo/redo, but I cant remember it directly, I have to read it from my fingers first

14:17 chouser: just fyi

14:18 mebaran151: chouser, I'm a big vim fan

14:19 it's the only thing I use for sysadmin

14:20 technomancy: there's no way to calculate an md5 sum of a file without slurping it all into memory, is there?

14:20 unless you shell out or something

14:20 ska2342: mebaran151: I seem to remember to get the slime selector method from Bill Clementson, here: http://bc.tech.coop/blog/docs/clojure-emacs.el

14:21 chouser: technomancy: it doesn't all have to be in memory at once

14:22 Chousuke: technomancy: IIRC you can feed the MD5 calculator thingy data in chunks

14:22 mebaran151: yeah so I remembered

14:22 I think it takes an input stream

14:25 technomancy: aha, you can call "update" on it with just a few bytes. sweet.

14:26 humphrej: I've got a clojure syntax question..

14:26 mebaran151: heh, playing in Erc

14:26 this is actually a far more convenient way to ask coding questions

14:26 Hun: mebaran151: try rcirc. it feels more clean :)

14:26 humphrej: I don't think In understand binding

14:27 mebaran151: can I get it from packages?

14:27 humphrej: http://pastebin.com/d727cc1bd

14:27 Hun: it's included by default since emacs22

14:27 M-x irc

14:27 humphrej: My question is why do I get the error if the set! is within the map func

14:28 chouser: humphrej: you probably understand 'binding' ok -- the problem there is that map is lazy

14:28 so the code in your fn isn't executed until the resulting seq is printed by the repl, *after* you've left the 'binding' scope.

14:29 humphrej: I see - it does work if I enclose everything in a huge binding

14:29 inc the usage of the lazy seq

14:30 chouser: right. or realize the seq before leaving the binding you've got.

14:30 cemerick: is there any way to configure a var so that one can set! a value to it without having a binding in place? Seems like doing (binding [*foo* *foo*] ...) shouldn't be necessary if one wants to use a var to provide returns/status/etc outside the stack.

14:31 chouser: humphrej: via 'doall' for example.

14:32 humphrej: reason I ask is that I found this page http://www.findinglisp.com/blog/2004/11/investing-with-lisp.html

14:32 and was wondering the best way to implement the make-history-function in clojure

14:34 I was thinking keeping it lazy would be nice as then the source seq could be a seque or somesuch

14:34 rhickey: cemerick: what happens in other threads?

14:35 fliebel: Can someone answer me this very simple question: How do I empty a vector in an agent?

14:35 cemerick: rhickey: in my ideal world, nothing -- it seems that set! should be a no-op (not an error) on a var that has no binding.

14:36 rhickey: cemerick: I'm confused - what's the use case?

14:37 cemerick: rhickey: I have a fn that has a status code, which is generally uninteresting. When a caller *is* interested in that status code, I'd like them to be able to bind on that var, and check it when they want.

14:38 I just think it's irritating to have to wrap my fn impl in (binding [*foo* *foo*] ...) in order to set! that occasionally-interesting status code

14:38 chouser: fliebel: (send empty agt) ?

14:38 ska2342: cemerick: wrap it in a try catch in your fn?

14:39 cemerick: ska2342: surely you're joking :-P

14:39 ska2342: cemerick: Hm, I'm not so sure.. Going back to the REPL for a moment to try this

14:39 fliebel: chouser: I did not think of the possibility that such a stupid function would be in core.

14:40 cemerick: ska2342: oh, I'm sure it'll work, but that's hardcore ugly.

14:41 rhickey: fliebel: what's stupid about empty ?

14:41 chouser: fliebel: it's actually quite important to allow fns to support a variety of collections.

14:41 ska2342: cemerick: uglier than changing the behaviour of a special form for a rare use-case?

14:41 chouser: (into (empty x) (map f x)) is such a nice pattern that lots of people want it to be a fn of its own. :-)

14:42 qbg: cemerick: That would be solved beautifully with multiple return values

14:42 cemerick: ska2342: not so rare, IMO, but regardless, uglier than what's necessary now

14:42 fliebel: rhickey: Nothing really, but I could not imagine a use case where you would want to return an empty sequence. Since stuff is immutable anyway I'd just use [].

14:42 ska2342: yay, multiple-value-bind, here we come :-)

14:42 rhickey: cemerick: I'll admit that use case is not well supported, but unsure about set! of unbound as no-op

14:42 chouser: humphrej: I'd actually recommend strongly against using a var for your *histry* in this case.

14:43 humphrej: you might be interested in 'partition'

14:43 ,(partition 3 1 (range 10))

14:43 clojurebot: ((0 1 2) (1 2 3) (2 3 4) (3 4 5) (4 5 6) (5 6 7) (6 7 8) (7 8 9))

14:43 cemerick: qbg: if I wanted that, I could simply return a vector from the fn in question

14:44 ska2342: cemerick: currently the users of your fn will *have* to establish a binding, even if not interested in the status. I'd consider it nicer from the user standpoint if it were wrapped in an ignore-errors-like form

14:44 cemerick: rhickey: just a thought -- I've just written the (binding ...) workaround three times this afternoon, so I figured I'd bring it up.

14:44 mebaran151: any of you guys use eproject or nav?

14:45 chouser: cemerick: what's the type of the object you return (not the binding one, the main one)?

14:45 cemerick: ska2342: no, the current best-practice is for the author of such fns to bind the var to its existing value so that set!'s work, but have no effect. This only affects library authors, not users.

14:46 chouser: a map, but the status code in question in this fn is an int that's only of interest 4-5 levels up the stack

14:46 chouser: it's actually perfect for error-kit, but too simple of a problem to use error-kit for :-)

14:46 rhickey: cemerick: if you bind in the setting fn, that won't make it out of the binding

14:46 chouser: heh. every problem is too simple to use error-kit for

14:47 cemerick: having the ignore-on-unbound-set configurable (non-default) is a bit interesting.

14:48 ska2342: this sounds more like a thread-local atom, not?

14:48 rhickey: cemerick: you could test that the var is bound before trying to set!

14:48 chouser: you want naive misuse of var and set! to be flagged with an error, but if you specifically ask for such errors to be ignored on a given var, maybe that'd be good enough.

14:49 rhickey: don't we just need a bound? fn ?

14:49 then you could write -set-if-bound!

14:49 chouser: yeah, that's better

14:49 humphrej: chouser: thanks let me ponder that one

14:50 ska2342: would bound? return false if only the root-binding is established? or would it have to distinguish between no binding, root-binding and binding-form-dynamic-binding? No too easy I guess.

14:50 /No/Not/

14:51 chouser: ska2342: right, there's .isBound already, but that's something else.

14:51 cemerick: ska2342: that's a thought -- perhaps I should set the api up so that callers bind an atom to a var, which is reset! if non-nil. That might be simpler all-around.

14:51 qbg: random question: Is it a known issue that the master branch of clojure-contrib will no longer compile with the master branch of clojure?

14:52 rhickey: cemerick: and then reimplement the stack-unwinding?

14:52 chouser: you'd want 'thread-bound?' or something?

14:52 rhickey: chouser: yes, two flavors

14:52 chouser: qbg: did you 'ant clean' your contrib before building?

14:53 rhickey: is there a reason that contrib doesn't auto-clean?

14:53 cemerick: rhickey: I sense sarcasm. Did I miss something?

14:53 qbg: chouser: Thanks, that fixed it

14:53 rhickey: cemerick: no sarcasm, but what happens with nested calls when you start using an atom?

14:54 cemerick: yeah, not a general solution -- works in this particular case, though, where I know there's no nested calls

14:55 rhickey: cemerick: would not thread-bound? solve your problem?

14:55 ska2342: I humbly repeat my question about a thread-local atom-like-type. Is that desirable, interesting or even doable?

14:56 chouser: ska2342: var is a thread-local atom-like

14:56 cemerick: rhickey: I believe so, and I'd use it. I'm just trying to finish this particular piece this afternoon. :-)

14:57 rhickey: cemerick: you could send me a patch with bound? and thread-bound? right now...

14:57 :)

14:57 * chouser smiles

14:57 rhickey: all the support is in Var already

14:58 cemerick: rhickey: halfway there already :-)

14:58 arohner: I wrote thread-bound? a few days ago, and then threw it away because I went with another approach for the problem that needed it...

14:58 cemerick: still won't be in our actual build of clojure for a while tho

15:00 rhickey: when would Var.count be > 0 but yet the bindings have no entry for the var?

15:01 trmsw: does anybody else get an error from (use 'clojure.contrib.http.agent): bytes already refers to: #'clojure.core/bytes in namespace: user?

15:02 rhickey: cemerick: you don't want count, that is an optimization. You want getThreadBinding(0 != null, but not public

15:02 trmsw: I'm using clojure-1.1.0 and clojure-contrib-1.1.0-RC1

15:03 cemerick: rhickey: yeah, that's what I've done already, I was just wondering re: count

15:03 rhickey: bound? == hasRoot(), thread-bound? == getThreadBinding() != null

15:03 cemerick: count allows Var to check an Atom prior to incurring the overhead of getting the thread local

15:03 if count is 0, no thread has a local binding

15:04 chouser: what is isBound()

15:04 rhickey: chouser: bound either way

15:04 chouser: bound only at the most recently level of 'binding'?

15:04 oh, || hm..

15:05 rhickey: and maybe what bound? should map to

15:05 bound? means deref will work, thread-bound? means set! will work

15:07 stuartsierra: to your point before, breaking changes in timely releases will put more pressure for patches for prior releases. We didn't get any for 1.0

15:08 stuartsierra: yes

15:08 technomancy: what's the easiest way to pad a string with a character if it's less than a given length? is there a built-in or contrib function for that?

15:09 stuartsierra: ,(format "%10s" :foo)

15:09 clojurebot: " :foo"

15:09 rhickey: poll, when fns get metadata - where do you want to put it?

15:10 hiredman: on mars

15:10 rhickey: hiredman: ?

15:10 technomancy: stuartsierra: any way to do it with a character other than space?

15:11 hiredman: rhickey: sorry

15:11 stuartsierra: rhickey: before argument list, (fn {metadata} [x] ...)

15:11 rhickey: stuartsierra: won't that be confusing with multiple arity?

15:11 since won't be per-arity

15:11 chouser: after the 'fn'

15:12 stuartsierra: actually, I have no idea

15:12 rhickey: chouser: and if there's a name?

15:12 chouser: so, before the name if any

15:12 before the arg vector if only one, and before the list of arities

15:12 except

15:13 that's the same "place" as var metadata on defns. :-/

15:13 stuartsierra: The only time it matters is in defn, where there's confusion with Var metadata. Anywhere else we have #^

15:13 rhickey: so, this is still code as data

15:13 hiredman: stuartsierra: #^ has to expand into something

15:14 stuartsierra: hiredman: yes, but #^{...} (fn ...) could set metadata on the fn

15:14 (def #^{...var metadata...} symbol #^{...fn metadata...} (fn ...))

15:15 hiredman: stuartsierra: but #^ is a reader macro

15:15 ahem

15:15 right

15:16 stuartsierra: hiredman: oh, right. (with-meta {...} (fn ...)) then

15:16 But (fn...) is a special form, so I suppose it could accept read-time metadata too.

15:17 rhickey: fn is a macro

15:17 fn* is special

15:17 stuartsierra: oh

15:18 rhickey: but the fn form can certainly take metadata on the form, once macros can get their forms

15:18 chouser: we're not talking about fns support with-meta, are we?

15:18 rhickey: chouser: possiblty

15:19 which argues for simple #^{:a 1} (fn []...)

15:20 stuartsierra: I actually prefer #^ to having metadata in a different place for different macros (defn, fn, def, ...)

15:20 But people will complain that it's ugly.

15:20 chouser: ^{:a 1} (fn [] ...) :-)

15:21 stuartsierra: chouser: yes, I like that

15:21 arohner: why do does the "defn metadata" need to go on the var once fns have metadata?

15:22 rhickey: arohner: backwards compatibility?

15:22 stuartsierra: arohner: {:private true} for one, and people may still have use for Var metadata

15:22 Would fn metdata include :pre/:post conditions?

15:23 arohner: ah right, thanks

15:23 chouser: some var metadata is used for non-fn values that don't themselves support metadata. docstring on *print-length*

15:23 technomancy: if IMeta is implemented in terms of protocols, does that mean we'll be able to add metadata to instances of final classes?

15:23 chouser: technomancy: where would the metadata be stored?

15:24 rhickey: stuartsierra: yes

15:24 technomancy: no

15:24 technomancy: chouser: in... a metadata store? I hadn't really thought it through. =)

15:25 stuartsierra: technomancy: it might be possible, but still inadvisable

15:25 technomancy: stuartsierra: how so?

15:25 * rhickey sticks with no

15:26 hiredman: :D

15:26 stuartsierra: Well, if IMeta is a protocol, there's nothing stopping you from extending it for any class, stashing the metadata in a weak hash map or something.

15:26 rhickey: the contract of with-meta is: the same value, with metadata. You can't superimpose that on a final class

15:27 if you pretend (via an external map), you will have a performance, GC, and concurrency nightmare

15:27 stuartsierra: rhickey: Yes, that's why I said inadvisable. ;)

15:27 technomancy: gotcha

15:27 rhickey: nevermind a problem with identity

15:28 stuartsierra: you mean insoluble?

15:28 technomancy: how about IFn on java.util.regex.Patterns then?

15:29 stuartsierra: rhickey: Insoluble to do it correctly. Hence, inadvisable to try it.

15:29 rhickey: technomancy: needs a wrapper

15:29 stuartsierra: ok than :)

15:29 then

15:29 stuartsierra: Comp. Sci. needs a word for that: "you can't do this correctly, so don't do it at all."

15:30 technomancy: well shucks, I'm going to have to find another 1.2-specific to get excited about then.

15:30 stuartsierra: technomancy: deftype! locals-clearing!

15:31 technomancy: oh yeah, locals-clearing is awesome. it's just easy to forget about. =)

15:31 rhickey: defprotocol, improved agent erros, direct binding

15:31 stuartsierra: direct binding!!!

15:31 rhickey: metadata on fns, form and locals in macros

15:31 technomancy: I just don't have any use in mind for protocols off the top of my head anymore

15:32 rhickey: direct binding is on right now in master, for clojure.*

15:32 technomancy: I'm sure I'll be able to think of something. =)

15:32 hiredman: cinc!

15:32 rhickey: hiredman: not 1.2

15:32 stuartsierra: While we're on the subject, what do you say to publicly giving a target date and feature set for 1.2?

15:33 technomancy: isn't the feature set already fairly clear?

15:34 stuartsierra: I mean make it public, put a roadmap on the web.

15:34 hiredman: rhickey: sure

15:34 stuartsierra: With a due date.

15:34 rhickey: stuartsierra: most of the heavy lifting is already done. A bunch of things need some experience-based feedback. I'm not 100% in love with how map support works in deftype, we need to decide what the knobs are for direct binding, people need to try the new aagent error system...

15:34 hiredman: but that is a use for protocols

15:34 * rhickey doesn't like due dates

15:34 stuartsierra: I was thinking, if people could see what new features are coming out, and when, they would be more motivated to test.

15:35 Not a due date per se, but a planned date. Like Ubuntu releases.

15:35 rhickey: stuartsierra: I think the current system is working ok, I just got too far ahead of the releases. But that means 1.2 will come much sooner than 1.1 did

15:36 stuartsierra: rather than a date, I'd prefer to scope it by features. When all the features are in, then it's a matter of testing and ship

15:37 stuartsierra: rhickey: ok, it's your show, after all.

15:37 rhickey: plus any bug fixes that make it in the meantime

15:37 all programmers do with dates is miss them

15:38 stuartsierra: but I agree, fewer features per release, more frequent releases

15:38 stuartsierra: rhickey: that's good, that's the important part

15:39 rhickey: one problem with that is insufficient feedback time, so more things might be labeled alpha

15:40 * technomancy hopes he didn't come across as too snarky; that's just the sound of re-adjusting expectations

15:40 technomancy: protocols aren't magic fairy dust that suddenly give me all the features I want. =)

15:40 stuartsierra: A description of which milestone to assign tickets to would help.

15:44 rhickey: stuartsierra: everything should go into backlog - I'll move them

15:44 hiredman: technomancy: http://clojure.org/rationale is still good, a functional lisp, nice datastructures, jvm libraries, the rest is just details, nothing to get too excited about

15:44 stuartsierra: rhickey: might be worth mentioning on http://clojure.org/patches

15:45 rhickey: so, when can we move to ^{:lean :metadata} foo

15:45 stuartsierra: backlog is the default

15:46 stuartsierra: rhickey: ok, I was just moving some old tickets from "no milestone" to backlog

15:46 hiredman: is ^ still going to be pre form? just #^ without the #

15:48 rhickey: stuartsierra: I need to check, but I think they might have preceded setting up the default. I added a note to http://clojure.org/patches

15:48 stuartsierra: cool, sounds good

15:49 rhickey: hiredman: yes, just #^ without the #

15:52 ecyrb: Could someone point me to an example of using "{#^:static true}" to declare a static method in gen-class?

15:53 hiredman: ecyrb: completely wrong

15:53 #^ is a reader macro for attaching metadata to the following form

15:54 so {#^:static true} tries to attach :static as metadata on true

15:54 which is nonsense

15:54 rhickey: ecyrb: looks like you've got a typo there

15:54 should be #^{:static true}

15:54 hiredman: #^{:static true} goes before the vector specifing the method

15:54 ecyrb: Ah. #^{:static true}

15:55 cemerick: rhickey: I got a little fancy with bound? and thread-bound? Figured they'd be used more commonly in literal form than in conjunction with map, etc. http://github.com/cemerick/clojure/commit/d270aae483c804c219b30cc2e5a93a764f739215 I'll put a patch on a ticket if that's what you had in mind.

15:56 ecyrb: Thanks guys.

15:56 rhickey: cemerick: I think they should be ordinary functions

15:57 ?

15:58 cemerick: rhickey: I wouldn't have expected that, but OK. Trying to be explicit about vars?

15:59 rhickey: cemerick: well, there's the don't make macros that don't need to be macros...

16:01 heritage is: http://www.lispworks.com/documentation/HyperSpec/Body/f_boundp.htm

16:07 cemerick: rhickey: ok, done. I left them with rest args, though -- it's too easy to do (thread-bound? #'a #'b #'c) rather than (every? thread-bound? ...)

16:09 rhickey: cemerick: cool, thanks!

16:10 LauJensen: Anybody have some hints as to which Java classes would be appropriate for writing a proxy ?

16:13 chouser: my favorite is clojure.lang.IDeref :-)

16:14 hiredman: I think he must have meant an http proxy

16:14 chouser: oh

16:14 heh

16:14 LauJensen: Thats right :)

16:18 chouser: it doesn't seem quite right that queues print looking like lists

16:19 rhickey: chouser: what queues?

16:19 chouser: PersistentQueues

16:19 rhickey: oh, those

16:19 chouser: we're documenting them

16:19 :-)

16:20 rhickey: are people using them?

16:20 chouser: sure we are

16:21 _fogus_: They will once they read our great section. :-p

16:21 chouser: not a lot, but when you need a queue, that's what you need.

16:21 when people don't use a queue the do horrible things to vectors instead.

16:22 I saw that in the wild -- shoot, where's that link...

16:22 LauJensen: bestinclass.dk ? :)

16:23 _fogus_: I propose printing them as <(1 2 3)<

16:23 rhickey: any proposals for an api, printed representation, tests etc?

16:23 hiredman: _fogus_: :|

16:23 dancing queues

16:23 _fogus_: fish queues

16:23 hiredman: <()< >()>

16:23 rhickey: I've always been concerned about people not understanding how to use them and getting confused vs. imperative queues, which we still need to support

16:24 chouser: the api is fine as-is, maybe add a 'queue' factory fn. printed is rarish, I would be ok with #=(queue a b c)

16:24 rhickey: and when we have an api for I/O queues?

16:25 chouser: LauJensen: nah, I think it was rosetta stone something, though I can't find it now.

16:26 wow there's a lot there: http://rosettacode.org/wiki/Category:Clojure

16:27 cemerick: rhickey: this your cue for a generalized queue interface ;-)

16:27 rhickey: cemerick: but it won't unify persistent and I/O queues

16:27 chouser: call it persistent-queue for now. *shrug*

16:28 cemerick: rhickey: I'm all about the tangents today.

16:28 chouser: ah, there it is: http://rosettacode.org/wiki/FIFO#Clojure

16:28 * rhickey tea time

16:29 LauJensen: hehe

16:29 _fogus_: chouser: Sounds like you just volunteered to fix that. ;)

16:29 chouser: someone didn't know about PersistentQueue and wrote one on vectors that leaks every item inserted.

16:29 _fogus_: I *was* going to educate the world about not doing that instead, but then you went and did it.

16:35 * arohner didn't realize PersistentQueue existed

16:39 stuartsierra: rhickey: want to celebrate 1.1 at LispNYC tonight?

16:40 (and anyone else, come on down)

16:40 * LauJensen pouts

16:40 stuartsierra: Tonight at 7, P&G's, 380 Columbus Ave.

16:42 Be there, or be parenthetical.

16:43 duncanm: is deftype not in clojure 1.1?

16:43 * chouser has a Clojure party at home every night, and everyone from my city that's into Clojure comes.

16:44 chouser: duncanm: nope, in "master", slated for 1.2

16:53 LauJensen: (apply str (mapcat #(map char %) (concat [(map inc [70 110 110 99 109 104]) (reverse '(33 116 104 103))])))

17:02 ninjudd: is there any way to tell what type a struct object is?

17:02 hiredman: type?

17:02 kotarak: ninjudd: IPersistentMap

17:02 ninjudd: what type of struct

17:03 chouser: that's not really a type, it's more like which constructor you used.

17:03 or in other words, no you can't.

17:03 kotarak: ninjudd: you have to attach such information in the metadata

17:04 ,(let [s (create-struct :a :b)] (type (with-meta (struct s 1 2) {:type ::MyType})))

17:04 clojurebot: :sandbox/MyType

17:04 kotarak: ninjudd: structs don't have necessarily a name.

17:04 ninjudd: what you probably want is defstruct from master

17:04 ninjudd: kotarak: i see, that makes sense

17:05 kotarak: does that add the metadata automatically?

17:05 kotarak: ninjudd: no. you have to do it manually with with-meta

17:05 ninjudd: ok

17:06 kotarak: (defn my-type [x y] (with-meta (struct my-type-struct x y) {:type ::MyType}))

17:06 something like that

17:06 ninjudd: there isn't a struct? method either...

17:07 really, in this case, i just need to know if the type is PersistentStructMap

17:07 kotarak: ninjudd: let's try it the other way around: what are you trying to do?

17:08 Maybe there is a different solution?

17:09 ninjudd: kotarak: i'm writing a method that i want to vary its behavior depending on whether a struct is passed in

17:09 chouser: (instance? clojure.lang.PersistentStructMap x)

17:10 ninjudd: kotarak: more specifically, i want to override the behavior of print for a specific struct type

17:10 kotarak: ninjudd: (defmethod print-method ::MyType ...)

17:11 ninjudd: kotarak: so i really need to make a new class in Java then?

17:11 kotarak: ninjudd: no. you have to attach metadata with type info

17:11 ninjudd: print-method dispatches on type which checks for :type in the metadata

17:11 ninjudd: kotarak: oh, right

17:12 kotarak: ok, thanks

17:12 kotarak: ninjudd: checking on PersistentStructMap would change the behaviour for *all* struct maps, not just your type.

17:12 ninjudd: np

17:13 ninjudd: chouser: thanks, i knew there must be some way to check the type. i'm coming from ruby, so i was looking for something like is_a? or kind_of?

17:14 class rather

17:14 kotarak: ninjudd: you'll find types pretty much uninteresting in Clojure, in general.

17:14 A lot works by abstractions

17:18 technomancy: same as in Ruby actually, if you're using is_a? much something is probably wrong

17:19 ninjudd: technomancy: i'm not, i just didn't know how to do it

17:20 technomancy: speaking of which, I can't be the only person who gets confused about the fact that isa? and instance? have their arguments in opposite order, can I?

17:20 not to mention trying to use isa? to check if an object is an instance of a class?

17:22 wilig: Getting very strange error from slime when trying to use clojure.contrib.sql. I get "No matching method found: println for class swank.util.io.proxy$java.io.StringWriter$0" Any pointers?

18:08 arohner: technomancy: IIRC, you can blow your permgen in some cases just by creating too many anonymous functions

18:08 it has to do with the JVM GC'ing classes

18:08 the JVM doesn't GC classes unless their owning classloader is GC'd (I think)

18:09 technomancy: from what I understand closures are generated with their own classloader for precisely this reason

18:09 arohner: yes. A lot of clojure creates new classloaders and lets them be GC'd for exactly this

18:10 but it wouldn't surprise me if it were possible to create a situation where your fn isn't GC'd

18:11 technomancy: it's odd that it would happen without being accompanied by a regular memory leak though

18:11 so it's mostly just use of eval and anonymous fns that cause runtime class generation, right?

18:14 arohner: I can't think of any others off the top of my head

18:14 aside from silly stuff like deftype in a loop

18:15 proxy and friends create classes

18:18 technomancy: oh, good point. I'll have to check that too

18:26 the-kenny: Anyone who can recommend me a good elisp tutorial?

18:27 trmsw: you're familiar with lisp?

18:27 the-kenny: trmsw: Of course

18:28 trmsw: Common Lisp and Clojure, to be precise

18:28 technomancy: the-kenny: just forget everything you've learned in Clojure about FP and data structures that are convenient to use and you should be in good shape. =\

18:28 the-kenny: Maybe "Tutorial" isn't the right word. I'm searching for something like an introduction to programming Emacs

18:28 technomancy: in other words, Common Lisp should be a great introduction. =)

18:29 the-kenny: technomancy: Sounds like.. Common Lisp

18:29 :D

18:29 technomancy: the-kenny: have you checked the one in M-x info? it's not bad.

18:30 trmsw: it's probably better than any tutorial that tries to teach you lisp into the bargain

18:30 technomancy: generally M-x apropos and the describe-* commands are your friends when exploring the actual APIs

18:30 the-kenny: technomancy: I always forget the built-in stuff in Emacs.. I'll look at it

18:33 trmsw: the-kenny: somewhere there is a book on how to write Emacs modes, can't find it but I remember reading it...

18:41 mtm: you're probably thinking of "Writing GNU Emacs Extensions" http://oreilly.com/catalog/9781565922617/

19:22 mebaran151: how do you print out slime's classpath?

19:23 seths: mebaran151: not sure, but it might be using the contents of $HOME/.clojure

19:23 probably more swank than slime, swank is the server side of slime

19:24 mebaran151: no I'm pretty sure it's getting my classpath

19:24 I just want to print it out to see what jars it's getting

19:24 seths: wait there was a post on the Clojure Google group recently

19:24 checking...

19:24 mebaran151: I launched it with swank-clojure-project

19:24 seths: oh

19:25 that method asks for a base dir, and I *think* includes the contents of the lib directory

19:26 that's how I run a repl from the new branch, since lein repl uses its internal version of clojure

19:28 technomancy: ,(System/getProperty "java.class.path")

19:28 clojurebot: java.security.AccessControlException: access denied (java.util.PropertyPermission java.class.path read)

19:28 technomancy: should work outside the sandbox

19:28 won't work with lein swank though

19:29 mebaran151: no magic swank vars

19:38 cool that worked, thanks technomancy

19:38 if I had a running project, say a server, I wanted to be able to patch on the fly, could I use swank to remote connect to it?

19:38 crazzyford: techno I worked up an elisp function that works with my project layout to run tests from implimentation files

19:41 lisppaste8: crazzyford pasted "test" at http://paste.lisp.org/display/93316

19:41 crazzyford: something like that

19:42 seths: technomancy: the .gitignore from lein new FOO could use a "FOO-standalone.jar" line

19:49 technomancy: crazzyford: what about a command instead that just toggles between implementation and test?

19:49 then you could build a "run tests for this ns" command in terms of that?

19:49 seths: great idea, let's see a patch. =)

19:49 crazzyford: this seemed faster

19:49 for refactoring stuff at least

19:50 move stuff around, run some tests, move more stuff around, run some tests

19:50 technomancy: sure; I'm just saying they're both useful

19:50 crazzyford: aye aye capn

19:50 technomancy: and one could be implemented using the other

19:51 crazzyford: eventually will have a "get buffer for this implementation file"

19:51 and then can easily switch/run tests on said buffer

19:51 the only thing that bothers me about clojure-test-mode atm is changing the color of output based on tests passing/failing

19:53 I looked into it some, but it looks like the way to change face of the minibuffer is using a minibuffer hook

19:55 technomancy: changing the color of the message in the minibuffer? hrm. don't know if you can do that, but it'd be great if you could.

19:56 crazzyford: if not might be able to flash the modeline green/red

19:56 maybe

19:56 minibuffer stuff looks difficult

20:01 ido does it, so must be possible in some way

20:03 aha (I think)

20:04 looks like you can use put-text-property inside the minibuffer

20:05 dnolen: technomancy: how can I get lein swank to use clojure new? does it just use the clojure inside leiningen/lib by default?

20:05 hiredman: new was merged into master

20:06 dnolen: hiredman: yes I saw that, but even so that's not the one that lein pulls down, so question is still the same :)

20:07 hiredman: I imagine if you change the version in your project.clj it will pull down what you ask for

20:07 qbg: If I have a symbol, how do I find the metadata that was associated with it when it was def'ed?

20:08 hiredman: def attaches metadata to the var, not the symbol

20:08 seths: dnolen: swank looks inside $HOME/.clojure which leiningen does not use

20:09 I wrote a tool to update ~/.m2 and ~/.clojure with different versions of Clojure/Contrib

20:09 http://bitbucket.org/seths/clojuggle/src/

20:09 technomancy: dnolen: it should use the version of clojure inside your project's lib/ directory

20:09 seths: may or may not solve the problem tho

20:10 dnolen: technomancy: hmm doesn't seem to be doing that, i have clojure-new there.

20:10 seths: to clarify: when using M-x slime

20:10 technomancy: leiningen will run in leiningen's version of clojure, and your project will run in its own

20:10 dnolen: technomancy: do I need to build the lein-swank jar with clojure-new

20:10 ?

20:10 technomancy: dnolen: the one place that doesn't apply yet is lein repl

20:11 dnolen: if you build lein-swank with the latest leiningen it doesn't matter since no AOT is done

20:11 dnolen: technomancy: I am using lein from source

20:12 technomancy: dnolen: how are you checking the clojure version

20:12 ?

20:12 dnolen: er, not scientifically that for sure. deftype isn't available :)

20:13 technomancy: I mean, lein swank + M-x slime connect, running the test suite, lein repl, etc.

20:13 dnolen: technomancy: I switch to the project dir, lein swank, connect from Emacs

20:13 hiredman: ,*clojure-version*

20:13 clojurebot: {:interim true, :major 1, :minor 1, :incremental 0, :qualifier "alpha"}

20:13 technomancy: dnolen: sounds like a bug; could you post to the lein mailing list?

20:14 dnolen: technomancy: sure

21:07 I314159: is there a mod operator in clojure?

21:07 mitchellh: I314159: rem

21:07 ,(doc rem)

21:07 clojurebot: "([num div]); remainder of dividing numerator by denominator."

21:08 markgunnels: If I wanted to use deftype and defprotocol, what should I point my leiningen dependencies to?

21:09 dnolen: markgunnels: something like, :dependencies [[org.clojure/clojure "1.1.0-new-SNAPSHOT"]]

21:09 markgunnels: dnolen: thanks.

21:09 I314159: ahh - thx

21:10 dnolen: np

21:10 markgunnels: dnolen: tried that and then ran lein repl and it greets me with:

21:11 Clojure 1.1.0-master-SNAPSHOT

21:11 user=> (doc deftype)

21:11 java.lang.Exception: Unable to resolve var: deftype in this context (NO_SOURCE_FILE:1)

21:11 dnolen: markgunnels: that might be related to an bug that I've just posted on the list

21:11 do you see clojure new in your project lib folder?

21:11 markgunnels: dnolen: Yes.

21:11 dnolen: markgunnels: yes probably a bug.

21:12 markgunnels: dnolen: K. Suspected I was just being dense with this. Statistically more likely. :-)

21:12 seths: dnolen: not a bug

21:12 lein repl uses the built in version clojure, not what's in lib

21:12 it's a known issue

21:13 your code in the src folder can still use deftype and defprotocol

21:13 dnolen: ah so well missing feature than that people seem to expect :)

21:13 markgunnels: seths: Ok. Thanks.

21:13 seths: agreed!

21:14 markgunnels: if you are using emacs, try swank-clojure-project to get a repl with the contents of the lib/ directory

21:14 markgunnels: seths: I am. That was actually what I was just trying...:-)

21:17 seths: is there a special swank dev-dependency I need with the new branch?

21:18 #<CompilerException java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V (pprint.clj:1)>

21:18 Make sure swank-clojure is added as a dev-dependency in your project.clj.

21:19 seths: I may have misunderstood your earlier statement.

21:20 seths: markgunnels: not sure, let me check

21:20 btw I am just a happy user of lein, not part of the project

21:21 markgunnels: seths: I am a VERY happy user of lein.

21:21 seths: It's very nice. Thanks for your help.

21:24 timothypratley: ,(doc mod)

21:24 clojurebot: "([num div]); Modulus of num and div. Truncates toward negative infinity."

21:24 markgunnels: seths: Don't spend too much time on it. I'll just write a little script to launch it outside of leiningen.

21:25 seths: Thanks again for your help.

21:28 seths: markgunnels: happy to help!

21:29 markgunnels: I am able to use defprotocol from swank-clojure-project

21:29 with this in my project.clj

21:30 :dependencies [[org.clojure/clojure "1.1.0-new-SNAPSHOT"]

21:30 [org.clojure/clojure-contrib "1.1.0-new-SNAPSHOT"]]

21:30

21:30 :dev-dependencies [[lein-clojars "0.5.0-SNAPSHOT"]

21:30 [leiningen/lein-swank "1.0.0-SNAPSHOT"]]

21:44 gstamp: curses. monad tutorial part 2 is down. http://onclojure.com/2009/03/06/a-monad-tutorial-for-clojure-programmers-part-2/

21:44 google cache to the rescue

23:36 defn`: in the ns macro is it correct to do [:use (foo bar baz)] where bar and baz are foo.bar and foo.baz?

23:39 ts00000: is there a reason why (re-find #"(.*\b(\r))+") wouldn't work?

23:40 sorry, (re-find #"(.*\b(\r))+" x)

23:40 defn`: you have a " in the wrong spot?

23:40 oops nvm

23:40 ts00000: my bad :)

23:40 chouser: defn`: you need round-parens around :use, not brackets

23:40 ts00000: is there something awkward with the backref syntax or something

23:40 defn`: chouser: do i then need to quote my namespaces below it

23:41 [:use clojure.set (base ext1 ext2)]

23:41 chouser: defn`: I don't understand. But something like (ns foo (:use (clojure.contrib repl-utils seq-utils))) works

23:41 defn`: chouser: right but what about (:use (clojure core contrib set))

23:42 oh nvm didnt read all of it

23:42 thank you

23:42 chouser: ,(re-find #"(.*\b(\r))+" "hi\r")

23:42 clojurebot: ["hi\r" "hi\r" "\r"]

23:43 chouser: ts00000: what's the problem?

23:43 defn`: but not core or contrib. core comes in automatically with 'ns', and contrib is not itself a namespace.

23:44 defn`: sure just an example

23:44 chouser: ok

23:44 ts00000: chouser: what I want is a block to be used in a second regex. see http://pastie.org/776064

23:44 defn`: chouser, i take it the same thing is true for :require and :import

23:44 ts00000: I want one match to contain the first block before the newline, and the second to contain the second block

23:45 chouser: defn`: :require is almost identical to :use. :import is something else, though it does allow similar lists for class packages/names

23:45 defn`: but as far as syntax, i should be doing (:import (com.petebevin.markdown MarkdownProcessor))

23:45 and not [:import...]

23:45 chouser: defn`: yes

23:45 defn`: cool, thank you

23:47 chouser: ts00000: you're trying to break that input at the blank line?

23:47 ts00000: chouser: yeah, ostensibly I have a long "data packet" that consists of a lot of these sections, not all of them evenly formatted, but i'm trying to iterate closer and closer to my ideal solution; problem is clojure doesn't seem to want to provide me a match for the expression I described

23:48 when I run my function designed to give me this, it just returns nil

23:48 but things like (.*) do what I expect

23:48 chouser: that regex appears to just be searching for a <CR> in the input

23:49 ts00000: http://pastie.org/776071 is a "real" example of what I want

23:49 where x is the true input

23:50 and yes, what I want is to search for a <CR>, and give me the match up to the <CR>

23:50 chouser: a single regex will return a fixed number of matches. You may want something like re-seq instead of re-find, so that you can get multiple results

23:50 ts00000: even with re-seq, I get no matches

23:50 chouser: ts00000: are you on a platform that uses \r for line endings rather than \n

23:52 ts00000: chouser: moving to \n does some things right, but not exactly what I expect; why do I get three elements in the sequence rather than two

23:52 I would think that the first element is the real text, and the second element is the parsed text; is the third element the backref?

23:52 chouser: what do you mean by "backref"?

23:53 ts00000: backreference

23:53 in the regular expression

23:53 to be used during the match

23:53 chouser: re-find returns a vector of n things where n is the number of groups in the regex plus one

23:53 the first is the whole match, the second your (.* ...)+ group, and the third your (\r) group

23:54 I think you might want something more like: (re-seq #"(?s).+?(?:\n\n|$)" x)

23:55 ts00000: yup cho, you got it. thank you

23:55 working through regular expressions for the first time

23:55 is the oreilly book best for gaining clue rapidly?

23:55 chouser: ah! well, good luck to you. It's a challenging and rewarding subject. :-)

23:56 couldn't say, sorry.

23:56 I don't think your regex had any backrefs in it. were you thinking of the \b part or something else?

23:58 ts00000: the \b part

23:59 chouser: in a java regex, anyway, that matches a word boundary.

23:59 so, not a backreference

Logging service provided by n01se.net