#clojure log - Nov 18 2009

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

0:38 technomancy: _ato: how goes?

0:38 have you beaten me to the finish line yet? =)

1:19 oy... you can't add a docstring to a namespace once it's been defined?

1:33 _ato: technomancy: you should be able to, it should be mutable

1:33 technomancy: alter-meta!

1:33 technomancy: right; I was expecting re-evaling the ns form after adding a docstring would do it.

1:33 no such luck

1:34 _ato: ah :(

1:34 technomancy: just confused me because I started to wonder if I was accessing the metadata correctly for a minute

1:34 _ato: oh and I'm getting there, got distracted by some other stuff for a few hours

1:35 technomancy: I just need more detailed help output for various tasks before I consider it ready for release.

1:35 _ato: I'm currently fighting sqlite's full-text search, looks like I need to make a seperate search table, it only wants to search one column at once

1:36 technomancy: =\

1:36 how much works so far? can you sign up for an account?

1:36 _ato: pretty much everything but search should work, though it hasn't be thouroughly tested, lemme push my current version in to production

1:38 technomancy: oh yeah. Also would you be able to add a way to set <description> in the POM with leiningen? (assuming you haven't since I last looked at it) I need something to search on ;-)

1:39 technomancy: sure thing

1:41 _ato: ooh.. I jsut looked in the production db and there's already 2 other users, how exciting! ;-)

1:43 technomancy: and now three!

1:45 piccolino: Four

1:45 _ato: damn... uploading is broken

1:46 piccolino: That'll give me time to figure out how to make a jar.

1:51 _ato: oh bummer, and links to jars aren't working either. heh. like I said not tested

1:51 uploading should now work though.. sorta mostly :P

1:51 oh and the repo URL is http://clojars.org/repo/

1:52 technomancy: _ato: pushed out descriptions in leiningen

1:55 _ato: technomancy: awesome, thanks :)

2:04 technomancy: is lein push implemented?

2:05 also: do you want me to add clojars to the default repo for this release?

2:05 _ato: ^^

2:07 _ato: technomancy: take a look at http://github.com/ato/lein-clojars/

2:07 technomancy: I saw that; just wondering if it was working. =)

2:08 _ato: push should work with that, although again I haven't extensively everything yet

2:08 technomancy: cool

2:08 _ato: err extensively tested*

2:08 and yeah if you'd like to add clojars to lein's default repos, please do :)

2:09 technomancy: if you think it's ready. =)

2:09 jkkramer: technomancy: there's a typo in your latest commit. "designed not to set your hair on _file_"

2:09 in the :description line

2:10 technomancy: oops! thanks

2:11 _ato: technomancy: I'm determined to get the basics fully functional and debugged today. :)

2:14 ah! fixed the jar pages: http://clojars.org/compojure

2:17 technomancy: _ato: you want me to mention clojars as a "coming soon, watch out for:" in my leiningen announcement?

2:17 =)

2:17 _ato: technomancy: hehe sure. :)

2:20 technomancy: _ato: I'm thrilled to get this out the door, but once the dust settles I'm going to be very interested in taking a closer look at the clojars code.

2:23 _ato: eek! :-) I'm a total compojure newbie so it probably doesn't look like much at the moment.

2:24 adityo: guys..what is Clojars.org?

2:24 technomancy: _ato: I haven't done anything with compojure either; no worries

2:25 _ato: adityo: it's *almost* a clojure community jar repository (for use with leiningen or maven or whatever)

2:25 well actually the repo part works, just need finish off browse and seearch

2:25 adityo: coool!!

2:32 technomancy: released, pushed, and announced.

2:33 * technomancy calls it a night

2:34 _ato: technomancy: congrats! goodnight. :-)

2:38 adityo: waddap piyush

5:02 ,doc partial

5:02 clojurebot: java.lang.Exception: Can't take value of a macro: #'clojure.core/doc

5:03 adityo: ,(doc partial)

5:03 clojurebot: "([f arg1] [f arg1 arg2] [f arg1 arg2 arg3] [f arg1 arg2 arg3 & more]); Takes a function f and fewer than the normal arguments to f, and returns a fn that takes a variable number of additional args. When called, the returned function calls f with args + additional args."

5:03 adityo: is a bit confusing!

5:03 would like to see some simple examples

5:27 _ato: ,(filter (partial < 5) [1 7 3 2 5 9 2 3 4])

5:27 clojurebot: (7 9)

5:27 _ato: adityo: ^

5:33 adityo: _ato: hmm

5:33 ,(filter #(< 5 %) [1 7 3 2 5 9 2 3 4])

5:33 clojurebot: (7 9)

5:34 adityo: what would be the benefits of using partial

5:34 Chousuke: it's sometimes neater.

5:35 mostly personal preference :P

5:36 adityo: anyways i think partial is cool :P

5:47 hoeck: adityo: also, partial can be nested, #() not

5:52 adityo: hoeck: yeah, thanks for pointing that out :)

6:05 Chousuke: adityo: the biggest problem with partial is that it's got 7 characters :P

6:08 hoeck: Chousuke: yes, are there any alternatives, for example, a shorter name or a reader macro?

6:09 Chousuke: hoeck: well, you can (def p partial)

6:09 but there's no reader macro

6:09 and somehow I doubt there will be :/

6:10 good macro characters are a scarce resource :)

6:15 hoeck: Chousuke: | is unused :)

6:15 Hun: Chousuke: not if your reader allows unicode :)

6:16 Chousuke: unicode characters are out by default. :P

6:18 hoeck: and will probably be used for something more important than partial

6:26 adityo: ,(doc comp)

6:26 clojurebot: "([f] [f g] [f g h] [f1 f2 f3 & fs]); Takes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc."

6:42 esj: Guys, does there exists such a thing as a 'blocking rest' ? I have a seq that lives in atom and gets switched out from time to time as new data gets appended to it. I'm thinking about how to consume this seq, such that when the consumer gets to the end of the seq it doesn't just die, but blocks until something new is in the seq, rinse, repeat.

6:42 any ideas ?

6:43 Chousuke: rest won't block, because it's lazy and you won't actually execute the function until you call first on it

6:44 but if the function generating the lazy seq items blocks, then any attempts to advance the seq will block too

6:45 I think there's something in contrib that creates a seq based on a BlockingQueue or something. (...vague, huh :P)

6:45 esj: Yeah, I've been reading through those

6:45 its seque and fill-queue

6:46 and something else too....

6:46 Chousuke: there's the hydra

6:46 hmm

6:46 ohpauleez: do you really want to block or do you want to poll/select?

6:46 Chousuke: ~hydra

6:46 clojurebot: Excuse me?

6:46 esj: hydra - i'll have a look that

6:46 I really don't want to poll

6:47 Chousuke: it was somewhere on pastebin/github

6:47 ohpauleez: ahh ok

6:47 esj: I basically need to know, cheaply, when a seq has been extended

6:47 Chousuke: hmm.

6:48 esj: I could use an observer type pattern so that the seq sends notifications, but wondered if there was a way to put the logic in the consumer, rather than the producer

6:49 ohpauleez: http://www.assembla.com/wiki/show/clojure/Protocols

6:49 one possibility might be to add a protocol for it, extending it

6:49 ie: if you go to observer way

6:50 cgrand: esj, you can try a promised seq: (lazy-seq @p) where p is a promise, producer thread deliver p and calls to seq/next/rest will block

6:51 ohpauleez: cgrand: any docs on that?

6:53 oh nvm, I just reread what you wrote, I get it

6:53 esj: esj has been scared to look at protocols --- massive brain stack overflow as it is :)

6:54 ohpauleez: haha

6:55 esj: thanks for the input everybody.

6:56 ohpauleez: esj: np

7:14 esj: cgrand: oh having unpacked this promised seq idea, the question I have is what function do I use as the promise / future ? It needs to somehow know when the original seq has been extended, or am I being dull ?

7:15 which is how I got to the idea of the 'blocking rest' function

7:25 _ato: ,(doc fill-queue)

7:25 clojurebot: "clojure.contrib.seq-utils/fill-queue;[[filler-func & optseq]]; filler-func will be called in another thread with a single arg 'fill'. filler-func may call fill repeatedly with one arg each time which will be pushed onto a queue, blocking if needed until this is possible. fill-queue will return a lazy seq of the values filler-func has pushed onto the queue, blocking if needed until each next element becomes available. fil

7:31 esj: _ato: doh !

7:32 * licoresse just received a new Magic Mouse, oh joy!

7:33 licoresse: oversaw someone speaking about many new special forms, where?

7:40 rsynnott: licoresse: is it any good? (the mouse)

7:40 licoresse: rsynnott: so far I am realy happy with it, very flexible with what finger you use to scroll

7:40 you don't have to stay in the middle (where the ball previously were)

7:53 the-kenny: hm... I have to try the Magic Mouse in an Apple store.

7:56 * ohpauleez has to do the same

8:45 Licenser: for ideomatic naming every function that changes state, or has side effects should have a ! in the end? like cd! for moving into a new directory?

8:45 cemerick: that's typical, yeah

8:46 Licenser: okay

8:46 just wanted to be sure since for FileSystem opperations it kind of looked odd to have all the ! theree

8:47 cemerick: well, I don't do a lot of IO stuff, but ! is definitely associated with fns that destructively modify some data structure

8:47 Licenser: well rm! does that kind of doesn't it? The Data structure is the FS not a clojure data structure, or am I seening this wrong?

8:47 cemerick: thinking about it, all of the database libs, etc., don't use !, so perhaps it can be safely skipped for libs that are always associated with IO operations.

8:48 Licenser: *nods*

8:48 hmm file IO isn't thread save :/

8:48 cemerick: yeah, I'll backtrack and say that for things that are implicitly side-effecting, ! is probably unnecessary

8:49 Licenser: that sounds usefull, it looked very odd after I added all the !

8:50 hmm I think FS's are just not functional and I#ve to live with that

8:57 weissj: anybody here use vimclojure?

8:57 ohpauleez: I do

8:57 weissj: was looking for a better colorscheme than default - couldn't figure out where to get the one shown here: http://kotka.de/projects/clojure/vimclojure.html

8:58 chouser: inkpot has been my favorite for quite a while

8:58 weissj: chouser: is that builtin?

8:58 ohpauleez: I use wombat

8:58 chouser: weissj: I don't think so

8:58 ohpauleez: inkpot: http://www.vim.org/scripts/script.php?script_id=1143

8:59 wombat: http://dengmao.wordpress.com/2007/01/22/vim-color-scheme-wombat/

8:59 in the comments is my 256 version

9:00 weissj: ohpauleez: weird, i loaded inkpot and it's just plain green.

9:00 green is my terminal text color

9:00 ohpauleez: you might need to set your term and vim to 256 color

9:00 weissj: ohpauleez: gnome-terminal doesn't have 256?

9:01 ohpauleez: I've had issues with 256 and gnome-terminal, but other guys I work with have done it

9:01 weissj: ohpauleez: any idea how/

9:02 chouser: I just use gvim.

9:02 sorry that's not much help.

9:02 ohpauleez: http://ubuntuforums.org/showthread.php?t=1090344

9:02 export TERM="xterm-256color"

9:02 in your bash or zsh rc

9:04 weissj: ohpauleez: i think it got it, thanks!

9:04 supposed to be a lot of purple and blue right

9:04 ohpauleez: weissj: awesome, glad to hear it!

9:06 weissj: ohpauleez: so, what i find odd here is that "if" is purple, "defn" is green, "throw" is blue, "not" is red.

9:06 ohpauleez: with wombat?

9:07 weissj: oh sorry, i'm using chouser's colorscheme. but i think all those are different colors in any scheme

9:07 ohpauleez: right, macro, special forms, functions, data types, comments

9:07 etc

9:08 chouser: not is purple for me, like the other core fns

9:09 dunno why "for" is blue but "with-out-str" is green. honestly, I'd never thought about it.

9:09 Licenser: hmm is there a way to compile a clojure into a jar with all dependecies? like the clojure stuff, and additional lbiraries?

9:09 weissj: chouser: is defn green for you?

9:09 chouser: weissj: yeah. so is "ns"

9:10 Licenser: I think that lein-thing has an "uberjar" command to do just that.

9:10 weissj: so no one has any idea what colorscheme is used here: http://kotka.de/projects/clojure/vimclojure.html

9:11 Licenser: chouser: thanks I'll try to figure that out

9:11 chouser: ~seen kotarak

9:11 clojurebot: kotarak was last seen quiting IRC, 983 minutes ago

9:11 fogus_: Licenser: http://ant.apache.org/manual/CoreTypes/zipfileset.html

9:11 weissj: chouser: oh ok didn't know he hung out here

9:13 cemerick: that's funny, kotarak uses twitter via TwitVim

9:13 chouser: weissj: yeah, but I think he's on European time, so you'll have to wait a bit. :-)

9:13 weissj: chouser: isn't it the middle of the day in europe?

9:13 Licenser: fogus_: thanks

9:14 weissj: chouser or maybe you mean he hangs out here after work

9:14 chouser: weissj: hm. I guess you're right.

9:14 liwp: it's 2:13PM in the UK, so 3:13PM in Germany IIRC

9:15 Licenser: liwp: actually 15:14

9:15 liwp: :-P

9:15 Licenser: we have twice as much houres here in germany then you in the us :P

9:15 lisppaste8: fogus pasted "zipfileset example" at http://paste.lisp.org/display/90663

9:15 fogus_: Licenser: Use like this ^^^^^^

9:15 Licenser: fogus_: thanks, you're my hero!

9:16 fogus_: Licenser: YW. BUT, using Leningen would be nice too. :)

9:17 liwp: has anyone tried / does anyone know if the repl in leiningen is slime/swank enabled?

9:18 Licenser: fogus_: not when you're trapped om M$ Windooze

9:19 chouser: leningen doesn't work on Windows?

9:20 Licenser: chouser: it has a bash file :P

9:20 liwp: should be fine with cygwin or mingw though

9:20 Licenser: and I'm not in the mood right now to translate bash to bat :P

9:20 chouser: ah, yeah, maybe it just needs a .bat

9:21 liwp: the script uses curl / wget to pull stuff from github, so you need to have something similar available for windows

9:21 chouser: I haven't looked at it at all. Does it assume you have clojure or at least java already?

9:22 liwp: yeah, I think so

9:22 chouser: ok

9:22 liwp: IIRC it just pulls the leiningen stuff from github and that's it]

9:23 Licenser: well what I want to do is to create a .jar file that my more stupid colegues can execute without having to deal wit installing clojure or stuff

9:23 liwp: Licenser: are you using clojure at work?

9:24 Licenser: liwp: yes

9:24 liwp: Licenser: lucky you!

9:24 Licenser: but not for a project just for supporting tools

9:24 liwp: yap lucky me

9:24 liwp: Licenser: that's still better than no clojure

9:24 weissj: any vim clojure users recognize this error with omnicomplete: Error detected while processing function vimclojure#OmniCompletion..vimclojure#ExecuteNail..vimclojure#ExecuteNa

9:24 ilWithInput:

9:24 line 19:

9:24 Couldn't execute Nail! [{"word" : "RuntimeException", "info" : "", "kind" : "c", "menu" : ""}]

9:24 Licenser: my boss as realized that letting me do my stuff is better then not letting me do my stuff :P

9:32 esj: sigh, making slime/swank work with the latest clojure is upsetting

9:33 ambient: making emacs a full clojure ide is upsetting, but perhaps that's just me

9:35 esj: making it work the first time was unenjoyable, but repeating the exercise...

9:35 well, it hasn't killed me, so i must be getting stronger

9:35 chouser: heh

9:36 unfortunately all you can no for sure is that it hasn't killed you *yet*

9:36 ambient: but how would you know after you died that it killed you?

9:37 Maddas: esj: http://site.despair.com/images/dpage/adversity03.jpg

9:38 ambient: heh. my own version is "that which does not kill me, makes me weaker"

9:38 chouser: heh. replace "adversity" with "emacs" and *then* you'd have a poster.

9:38 esj: ie: that which does not kill me, is due for upgrade in the next version ?

9:39 ambient: unless you kill it first

9:40 ohpauleez: weissj: are you just opening up vim or trying to open a fie

9:40 also, do you have nailgun running and is the client in your path?

9:40 weissj: ohpauleez: it's working now, for some reason

9:40 now i'm trying to figure out how to load the file i'm editing in a repl, and call one of the fn's

9:40 when i do \ef i get a read-only window listing the fn's

9:41 ohpauleez: Ok, I've noticed that vimclojure will choke sometimes if you open a file with a ns form at the top

9:41 weissj: ohpauleez: really? isn't that pretty much all of em

9:41 ohpauleez: weissj: (load-file "file-name")

9:41 yes, it is, but after the error happens once it doesn't happen again for me

9:41 weissj: ohpauleez: then what is \ef for

9:42 <LocalLeader>ef *ef* *EvalFile*

9:42 Send off the current file to the Clojure Server.

9:42 ohpauleez: ohhh in vimclojure

9:42 I thought you meant on any given REPL

9:42 weissj: ohpauleez: yeah sorry :) that load thing is why i'm trying vimclojure

9:43 that gets annoying

9:43 ohpauleez: I rarely use all the extra things, and only use it for text editing and quick evaling

9:43 weissj: hm ok

9:51 Licenser: hmm I found a pretty simple msolution, netbeans puts all libs in a lib folder which the jar uses automatically :D

10:00 sh10151: technomancy: found a little bug in swank-clojure-project the other night

10:02 esj: yeah, it came up on the googlegroup: http://www.mail-archive.com/clojure@googlegroups.com/msg20575.html

10:02 http://www.mail-archive.com/clojure@googlegroups.com/msg20576.html rather

10:07 sh10151: think this is a different bug I found

10:07 Mine's just the maven-specific portion should treat target/dependency like a directory full of jars, not an exploded directory of .class files

10:10 esj: ok, sorry.

10:21 patrkris: the way to get clojure 1.1 alpha is just by cloning the git repos?

10:21 ohpauleez: patrkris: yes

10:21 patrkris: thanks

10:21 ohpauleez: clone it and build it, then put the jar in your classpath like normal

10:21 np

10:46 michael_teter: Hello. I'm having great difficulty with basic configuration (I get FileNotFoundException when trying to use clojure.contrib)

10:47 I've built clojure-contrib.jar, and my clj.bat script is adding clojure.jar and clojure-contrib.jar to the classpath (-cp), but still I can't use clojure.contrib

10:47 Ideas?

10:50 my script is listed at http://pastebin.com/d5bdff0ef

10:51 and C:\src\clojure contains clojure.jar, and C:\src\clojure-contrib contains clojure-contrib.jar

10:53 AWizzArd: michael_teter: could you try to echo the variable which you append as the CP?

10:53 So you can see if it really points to the clojure.jar and the clojure-contrib.jar

10:54 michael_teter: ok, willdo

10:54 AWizzArd: maybe @echo on or something like that at top of the .bat file

10:54 patrkris: michael_teter: what do you write in the REPL to try to use clojure-contrib?

10:55 michael_teter: It appears I have a user path problem, so it was using an old clj.bat

10:55 I may be ok; let me test with the correct .bat :)

10:56 I'm sorry, this was a stupid user problem. my clj.bat is fine, and my contrib is loadable. I just had a windows path problem

10:56 but to answer patrkris, I did (use 'clojure.contrib.sql)

10:57 it works now

10:57 Thanks all

10:57 sh10151: looking at clojure.contrib.zip-filter.xml source, I don't see any negation examples

10:58 has anyone done that? e.g. return nodes that don't match a predicate

10:58 s/e.g./i.e.

10:59 chouser: sh10151: I don't think I've done it, but each step in xml-> is a filter run against all nodes at the level, so it should be straightforward.

11:19 Licenser: hmm (reader) will block when the stream it reads from is empty, what is the best way to prevent this, or at least give a usefull return value like :reader_empty?

11:19 stuartsierra: Licenser: call .available on the stream

11:19 http://java.sun.com/j2se/1.5.0/docs/api/java/io/InputStream.html

11:20 Licenser: ah darn I looked at the output stream docs o.O

11:20 stuartsierra: or .ready on a Reader

11:21 Licenser: I called ready but (first (line-seq *reader-thingy*)) still blocks

11:21 ah darn I think I know why o.O because the line-seq does not find a \n on the last line *hrm*

11:24 stuartsierra: reader, line-seq, etc. are conveniences, if you need to handle streams directly, e.g. to avoid blocking, you may be better off working with the stream objects

11:25 Licenser: *whine* but it is javaisch :P

11:25 stuartsierra: Clojure is Java. Therein lies its beauty and its tragedy.

11:26 Speaking of which, someone tried my clojure-hadoop library on large-ish data and kept getting "GC limit exceeded" errors

11:26 Licenser: Clojure has the JVM but untill now it really shielded me from the ugly object mess in java

11:26 cemerick: stuartsierra: what's "large-ish"?

11:29 sh10151: chouser: looks as though it's as straightforward as (comp not (attr= :foo "bar")) at least in my case

11:29 chouser: sh10151: great!

11:32 stuartsierra: cemerick: 3 GB

11:33 I think it's something to do with handling the Hadoop reducer operation with lazy sequences.

11:36 cemerick: holding head, etc., I presume

11:40 stuartsierra: I think so, yes. But it's interesting that it's not "Heap size exceeded," but "GC overhead exceeded," i.e., the JVM is spending too much time in GC.

11:41 chouser: stuartsierra: I tend to get those more or less interchangably

11:41 I think

11:41 stuartsierra: Interesting.

11:42 tomoj: I've never seen "GC limit exceeded" before

11:42 stuartsierra: Is it true that simply (defn foo [a-sequence] ...) holds the head of a-sequence?

11:43 cemerick: it has to, yes

11:43 tomoj: so how to the core sequence functions get around that?

11:43 how _do_ I mean

11:44 Licenser: hmm why does the function has to hold head?

11:44 cemerick: further, I presume that rebinding a-sequence elsewhere doesn't impact that -- if that weren't the case, that would be helpful.

11:45 tomoj: oh, I guess it only holds the head for the duration of the function call?

11:45 stuartsierra: Licenser: It doesn't HAVE to, but it does, because of the way Clojure and the JVM interact.

11:45 Licenser: with [a-seq] do you meen the arg seq or is a-seq a argument passed to the seq?

11:45 tomoj: so that if you return a lazy-seq, you're ok

11:45 cemerick: right, insofar as parameters to clojure fns are parameters to java methods, the same semantics apply

11:45 stuartsierra: yes, function locals last until the method returns

11:46 rhickey: stuartsierra: it won't hold it beyond the tail call of ...

11:46 Licenser: ah okay that is what you mean

11:46 if you don#t want to have it hold head you could call (afn (fn [] a-seq)) right?

11:47 stuartsierra: rhickey: That's what I thought. Unfortunately, the reducer function, as I've implemented it, has to return pairs.

11:47 rhickey: cemerick: and loop rebinding will overwrite and thus release

11:47 stuartsierra: It looks like (defn my-reducer [key seq-of-values] [[key (reduce + seq-of-values)]])

11:47 for a simple wordcount example

11:48 So the (reduce + ...) isn't in tail position.

11:48 cemerick: rhickey: sure, but a loop binding doesn't impact a separate fn parameter binding w.r.t. the latter holding head, right?

11:48 rhickey: yeah, the JVM doesn't see the stack reference to seq-of-vales as dead, and I only explicit null out (to help the JVM) on tail calls

11:49 stuartsierra: Is there a way I can work around that?

11:49 rhickey: cemerick: no, they are different bindings, even if the same name

11:49 cemerick: OK, glad I didn't misunderstand that.

11:50 lpetit: stuartsierra: out of my head (so maybe a big idiocy) : (defn my-reducer [key fn-producing-seq-of-values] [[key (reduce + (fn-producing-seq-of-values))]])

11:51 stuartsierra: does that solve it?

11:54 lpetit: stuartsierra: or (not changing your user interface) : (defn my-reducer [key seq-or-fn] (if (ifn? seq-or-fn) [[key (reduce + (seq-or-fn))]] (recur key #(seq-or-fn))))

11:54 ugly, if not :)

11:54 but still I'm not 100% sure this solves your problem

11:54 feedback appreciated

11:56 stuartsierra: lpetit: I'm not worried about changing the interface; my-reducer is a user-supplied function, not part of the library.

11:56 lpetit: stuartsierra: sorry, mistake in the #() (but you've got the idea)

11:56 stuartsierra: I'm going to try that, though

11:56 lpetit: stuartsierra: but beware the problem may still be hidden in the user code ?

11:57 tomoj: is there a better way to get the project root than something like (nth (iterate #(.getParentFile %) (File. *file*)) 5) ?

11:59 stuartsierra: tomoj: in general, Java prefers classpath-relative paths rather than filesystem lookup

12:01 tomoj: yeah, but I wanted to get a file:///... to load some static html files with htmlunit

12:01 thinking I'll just start a servlet instead since I'll need to do cookies etc eventually

12:01 stuartsierra: tomoj: you can add your static html directory to the classpath, then use one of the ClassLoader.getResource* methods

12:03 tomoj: oh, that would be cool

12:03 thanks

12:03 stuartsierra: np

12:07 Licenser: grr, I don't seem to gasp the reader stuff, I came up with a own readln but it's ugly and mostly not working (always returning blank lines). If someone would take a look I'd be very glad, https://gist.github.com/edf803e0aa07ef2161eb

12:08 stuartsierra: Licenser: this would work better with a StringBuilder

12:08 * Licenser googles for that

12:08 stuartsierra: Also Reader.read returns an int, not a char.

12:09 Licenser: ahh nseaky I missed that :(

12:15 lpetit: stuartsierra: I must leave, would you please email me the result (if it works, or even if it doesn't work)?

12:15 stuartsierra: sure

12:15 Licenser: narf I fopund the problem

12:15 the function was called too fast, the stream hadn't had data yet

12:31 rads: in ruby you can do this: [0]*6 => [0,0,0,0,0,0]. what's the equivalent in clojure?

12:32 tomoj: ,(repeat 6 0)

12:32 clojurebot: (0 0 0 0 0 0)

12:32 rads: thanks

12:48 Licenser: well time to go home

12:59 icey: technomancy: congrats on launching leiningen - it looks awesome!

13:05 technomancy: icey: thanks! hope it works well for you.

13:11 djork: technomancy: what's leiningen?

13:11 technomancy: djork: a build tool designed not to set your hair on fire

13:11 I should teach clojurebot!

13:11 djork: oh cool

13:12 heh yes

13:12 ohpauleez: build tool, an awesome one

13:12 technomancy: clojurebot: leiningen is a build tool designed not to set your hair on fire (http://github.com/technomancy/leiningen)

13:12 clojurebot: 'Sea, mhuise.

13:12 * technomancy likes to set expectations low.

13:12 technomancy: of course, there's no guarantee that it won't set your hair on fire. that's just the goal.

13:12 ohpauleez: I haven't used it yet, but I'm pumped to

13:13 Well I think any build tool that is expressive makes the job easier

13:13 but Clojure allows you to make a DSL

13:13 for building, which is ideal

13:13 * ambient is happily impervious to hair being set on fire

13:17 rahulkmr1: Having trouble with vimclojure. It won't compile complaining about pprint not found. "Could not locate clojure/contrib/pprint__init.class or clojure/contrib/pprint.clj on classpath"

13:18 michaeljaaka: hi

13:18 rahulkmr1: I compiled clojure-contrib again from source. and -Dclojure.jar=/path/to/clojure.jar

13:18 michaeljaaka: I want to learn how to assign new values to vars

13:18 I have read that somehting like this

13:18 ,(do (def n 1)(set! n 2 )(println n))

13:18 clojurebot: DENIED

13:18 ohpauleez: You need to put the contrib jar in your classpath too

13:18 rahulkmr1: but that still didn't solve the issue. Any ideas what am I doing wrong?

13:18 michaeljaaka: is not valid

13:19 rahulkmr1: for compiling vimclojure? yes. I did that.

13:19 michaeljaaka: so what I should use to make it possible?

13:19 djork: michaeljaaka: try refs, not vars

13:19 rahulkmr1: when I compiled clojure-contrib with ant -Dclojure.jar, I still couldn't find the file vimclojure is complaining about

13:19 ppprint__init.class

13:19 djork: michaeljaaka: but first consider if you really need to change anything at all

13:20 michaeljaaka: yes, I need it

13:20 I think that agents will be good

13:20 rahulkmr1: it wasn't there in the classes or clojure-contrib.jar. The error message also talks about pprint.clj. Is there a way I can place the .clj file somewhere and it takes it from there?

13:20 michaeljaaka: but first I want to learn anything about assigning values

13:21 djork: michaeljaaka: I just feel that if you're asking about how to re-assign to vars in Clojure you haven't had quite enough experience with the language to know if you really need to in the first place

13:21 chouser: changing the root value of a var is hardly ever the right thing to do

13:21 michaeljaaka: well, I want to track available nodes in a cluster

13:22 chouser: a ref!

13:22 michaeljaaka: they are chaning in time

13:22 so I need to store theirs availbility (addresses)

13:22 djork: a ref is perfect for that

13:22 michaeljaaka: and remove if timeout of hearbeat occures

13:22 ok

13:23 ohpauleez: rahulkmr1: Are you building everything from clean, are following every instruction

13:24 I've had vimclojure fail when I was building with an unclean build dir

13:24 but I just rebuilt everything about five days ago, and it's working ok for me

13:25 rahulkmr1: ohpauleez: ant clean should do the trick? anyways, let me try to untar and start again. But really, I don't see the pprint__init.class file in the contrib jar even when I did a "ant -Dclojure.jar=/path". I think even my clean compile will fail again.

13:26 ohpauleez: rahulkmr1: also, just for the sake of it: export CLASSPATH=$CLASSPATH:/path/to/clojure.jar:/path/to/contrib.jar:.

13:27 rahulkmr1: yes. I have that in my .bashrc. I have been running clojure for the past week. So no issues with cp. I was re-compiling contrib coz of vimclojure

13:27 hiredman_: rahulkmr1: where did you get contrib from?

13:27 _!

13:28 rahulkmr1: hiredman: I didn't really pay attention. I got one copy of contrib with sample code for programming clojure. And I d/l the source a couple of mins ago from some git repo which came up in my google search. Do I know a specific one?

13:28 hiredman: sounds right

13:29 what does the output of ant look like?

13:29 rahulkmr1: BUILD FAILED

13:29 /home/rahulkmr/utils/vimclojure/vimclojure/build.xml:66: java.io.FileNotFoundException: Could not locate clojure/contrib/pprint__init.class or clojure/contrib/pprint.clj on classpath: (util.clj:23)

13:29 hiredman: rahulkmr1: I meant for contrib

13:30 rahulkmr1: oops. sorry

13:30 michaeljaaka: what is a difference between alter and commute?

13:30 hiredman: ~commute

13:30 clojurebot: I don't understand.

13:30 hiredman: ~alter

13:30 clojurebot: alter is always correct

13:30 rahulkmr1: hiredman: jar:

13:30 [jar] Building jar: /home/rahulkmr/utils/richhickey-clojure-contrib-f165e28/clojure-contrib.jar

13:30 BUILD SUCCESSFUL

13:30 michaeljaaka: I can read that commute allow concurent changes within transaction

13:30 hiredman: rahulkmr1: that is not the whole output

13:31 pastebin it somewhere

13:31 rahulkmr1: oh. ok. will do that

13:31 michaeljaaka: I mean others won't wait for transaction to finish

13:31 hiredman: michaeljaaka: use alter

13:31 michaeljaaka: ok

13:31 alter is like pesimistic locking?

13:31 I alter lock

13:31 hiredman: no

13:31 michaeljaaka: monitor or whatever

13:31 change value

13:31 and release lock?

13:31 hiredman: no

13:32 michaeljaaka: synchonized(value) { value.add("somthing") }

13:32 ohpauleez: no

13:32 michaeljaaka: this is alter?

13:32 hiredman: no

13:32 michaeljaaka: :)

13:32 ohpauleez: michaeljaaka: http://groups.google.com/group/clojure/browse_thread/thread/0e575db4718c1f85

13:32 danlarkin: yes?

13:33 ohpauleez: alter does it during the transaction, commute waits for commit time

13:34 hiredman: no

13:34 ohpauleez: no?

13:35 hiredman: no

13:35 use alter

13:37 rahulkmr1: hiredman: here is the dump: http://pastebin.mozilla.org/684620

13:37 qed: i have a grid 20x20 as a vector, how do I split it up into 2 sequences which are 20 rows and 20 columns

13:38 michaeljaaka: wow, I manage to write first alternation in transaction! thanks man!

13:38 hiredman: rahulkmr1: where did you get your clojure?

13:39 rahulkmr1: I think it's the one which came with the book. Lemme check

13:39 hiredman: ok

13:39 ohpauleez: qed: map vector, and partition?

13:39 Bjering_: Why does this throw IOException? (with-open [rdr (reader "http://clojure.org/&quot;)] (take 2 (line-seq rdr)))

13:39 hiredman: you will need the 1.0 compat branch of contrib

13:39 Bjering_: line-seq and take are both lazy

13:40 so by the time you force them, with-open has closed the reader

13:40 ohpauleez: ,(map vector [1 1 1 1][2 2 2 2])

13:40 clojurebot: ([1 2] [1 2] [1 2] [1 2])

13:40 Bjering_: ah

13:40 michaeljaaka: check this out and let me know if it is ok http://pastebin.com/d2a6d0ae0

13:40 or anything can be improved

13:41 Bjering_: Then the next q becomes, why is (with-open [rdr (reader "http://clojure.org/&quot;)] (doall (take 2 (line-seq rdr)))) empty?

13:42 hiredman: ,(doc reader)

13:42 clojurebot: "clojure.contrib.duck-streams/reader;[[x]]; Attempts to coerce its argument into an open java.io.BufferedReader. Argument may be an instance of Reader, BufferedReader, InputStream, File, URI, URL, Socket, or String. If argument is a String, it tries to resolve it first as a URI, then as a local file name. URIs with a 'file' protocol are converted to local file names. Uses *default-encoding* as the text encoding. Should be

13:42 qed: ohpauleez: oh right :) i didnt know about partition

13:42 thanks

13:42 ohpauleez: qed: happy to help

13:44 hiredman: Bjering_: hard to say

13:44 I blame reader

13:47 rahulkmr1: hiredman: just to be sure, i just downloaded a new copy of clojure from clojure.org and compiled it. copied the jar files and set the classpath. I still am getting those pesky messages while compiling clojure-contrib if that's what you asked me where did I get clojure from

13:47 hiredman: Caused by: java.io.FileNotFoundException: Could not locate clojure/walk__init.class or clojure/walk.clj on classpath:

13:47 I got a new copy of clojure and these messages persist while compiling contrib

13:47 hiredman: rahulkmr1: as I said, you need the 1.0 compat branch of contrib

13:48 rahulkmr1: oh. I thought I got the latest copy from github. Lemme check

13:48 hiredman: you did get the latest

13:48 but you don't have the latest clojure

13:48 you have the 1.0 release

13:48 rahulkmr1: so shall I do a repo copy then?

13:48 for clojure, I mean

13:49 hiredman: you can also just get the 1.0 compat branch of contrib

13:50 rahulkmr1: I would rather be on the bleeding edge:-). Will check if the repo copy works with this contrib or else would downgrade contrib

13:50 jkkramer: Bjering: clojure.org redirects upon visiting. see `curl -i http://clojure.org`

13:51 Bjering_: jkkramer: aha.. yes wirks nicely with google.com

13:51 works

13:52 thanks hiredman & jkkramer

13:54 michaeljaaka: I need some advice can it be improved? http://pastebin.com/d3e81dde0

13:54 as you can see every time I create a map

13:54 is there any way to replace values under key inplace ?

13:55 the keys are :alive and :reported

13:55 maybe I should use struct ?

13:58 rahulkmr1: So I got my vimclojure compiled. I had to "git clone" clojure to make it work with my copy of contrib. But the compilation completed fine. I have my vimclojure.jar now. Thanks

13:59 ohpauleez: nice to hear rahulkmr1, enjoy!

14:00 stuartsierra: Can we come up with a general notion of "lazy-safe" functions in Clojure?

14:01 That is, functions that take a sequence as an argument and will not run out of memory on very large sequences.

14:07 chouser: stuartsierra: how would you classify 'reduce'?

14:08 (reduce + c) is safe, (reduce conj {} c) is not

14:09 hiredman: (reduce + c) might not be either

14:09 for a big C

14:09 chouser: oh?

14:09 If it's ever safe to walk all of c, (reduce + c) is safe, isn't it?

14:10 hiredman: there is a limit to how large of a number that can be stored in the memory of a computer

14:10 chouser: oh

14:10 (reduce (constantly nil) c)

14:10 hiredman: :P

14:11 (partial * 0)

14:11 chouser: but of course if c is being held elsewhere, or if c itself has elements that are dangerous to compute, then still dangerous.

14:13 hiredman: I think you end up with moscow rules with regards to laziness

14:14 http://en.wikipedia.org/wiki/The_Moscow_Rules

14:14 chouser: already there

14:14 :-)

14:14 stuartsierra: hmph

14:15 I was hoping we could codify some rules for what is "lazy-safe."

14:15 hiredman: "# Everyone is potentially under opposition control."

14:15 stuartsierra: "Technology will always let you down."

14:15 chouser: everything is lazy safe if seqs are never very large.

14:16 hiredman: stuartsierra: that might just be the halting problem all over again

14:16 you can't tell if it is lazy safe without computing it

14:16 stuartsierra: hiredman: Ok, not totally generally, then. But rules of thumb.

14:16 tayssir: Hi! Can someone help with a weird headscratcher? I used to be able to MySQL db from Clojure/Emacs/Slime, but not today. It still works under both pure Java and commandline Clojure. And it's apparently not a classpath issue, since (Class/forName "com.mysql.jdbc.Driver") works... Voodoo suggestions welcome! ;)

14:17 stuartsierra: I don't want an algorithmic lazy-safe-check, I want guidelines to give to new users.

14:17 rhickey: stuartsierra: do you have an example of one that isn't?

14:17 stuartsierra: Sure: (defn count-them [seq] [(count seq)])

14:18 rhickey: that's your function, not Clojure's

14:18 stuartsierra: Right, so I want guidelines for writing functions that are lazy-safe.

14:18 rhickey: the rules are simple, all seqs are live until the tail call of the function

14:19 chouser: stuartsierra: Guideline number 1: Vary your pattern and stay within your cover.

14:19 stuartsierra: ok, so could one say that any function that calls a built-in sequence function in tail position is safe?

14:19 rhickey: stuartsierra: should be

14:21 stuartsierra: And, following lpetit's suggestion, a lazy seq wrapped in a function is also safe: (defn count-them [seq-fn] [(count (seq-fn))])

14:21 ohpauleez: chouser: haha

14:21 re: vary your pattern...

14:21 chouser: :-)

14:22 rhickey: you can see the technique used in drop/drop-while also

14:22 stuartsierra: ok, that's helpful

14:23 Can I generalize that?

14:23 chouser: the rules are as simple as when scheme will avoid stack consumption on a recursive call

14:23 can we have a 'recur' for lazy seqs?

14:23 stuartsierra: as in (defn count-them [a-seq] (let [f (fn [] s)] [(count (f))]) ?

14:23 michaeljaaka: hi!

14:24 I have function

14:24 stuartsierra: I mean (defn count-them [a-seq] (let [f (fn [] a-seq)] [(count (f))]) ?

14:24 michaeljaaka: (fn [] let[ x 3 ] (when (true) (set! x 5)))

14:24 how to change local value in codition?

14:24 chouser: michaeljaaka: locals are immutable

14:25 ohpauleez: and are bound to that scope

14:25 chouser: michaeljaaka: you can get close to that with loop and recur

14:25 stuartsierra: no, that last example doesn't work

14:26 rhickey: stuartsierra: didn't think so

14:26 michaeljaaka: hmmm, I will split func to two funcs and make an codition

14:27 stuartsierra: So once you accept a sequence as an argument, you must use a lazy-seq function in tail position or you're hosed?

14:29 rhickey: lazy != ephemeral

14:32 stuartsierra: yeah, yeah. :)

14:32 rhickey: that said, I understand it could be known that seq is not used after the call to count in: (defn count-them [seq] [(count seq)])

14:33 and the CLR knows that

14:33 stuartsierra: ok

14:33 Is there a way I can tell the JVM that?

14:33 rhickey: but the JVM doesn't, and doing that manually would be a significant piece of work in the current compiler

14:33 what I'm doing now (nulling locals on tail call) is a complete hack that shouldn't be needed

14:34 chouser: but would be a cinch with datalog

14:34 rhickey: doing liveness tracking a whole other thing

14:34 * chouser is just making wild assertions for the fun of it

14:34 stuartsierra: rhickey: Got it. What I need is a workaround then. Wrapping the seq in a fn is one way, I guess.

14:34 rhickey: there isn't always a workaround

14:34 stuartsierra: hrm, ok

14:35 rhickey: one thing that might be possible, but extremely ugly and painful, would be some sort of (releasing seq) primitive

14:35 slectively applied could solve any case

14:36 stuartsierra: Yeah, I wondered about that. (ephemeral! a-seq)

14:36 rhickey: it's really (I'm-done-with seq)

14:36 stuartsierra: (dispose seq)

14:37 rhickey: aargh

14:37 stuartsierra: :)

14:37 rhickey: because it doesn't really dispose, more like relinquish

14:38 ohpauleez: (release seq)

14:38 rhickey: no point in a naming exercise since I'm unlikely to add this wart-like thing and have it be in people's code

14:39 stuartsierra: heh

14:39 * rhickey sure wishes Clojure was sponsored/funded

14:39 stuartsierra: wish I could help with that

14:39 ohpauleez: have you shopped it out yet, or asked around?

14:40 cburroughs: When would the 'wrap a seq in a fn' technique not work?

14:40 ohpauleez: I know the PyPy guys went on a speaking tour when their EU funding was running low

14:40 rhickey: It has to become important to enough companies that something like this: http://industry.haskell.org/index might fly

14:41 ohpauleez: I know for a fact of two companies in Philadelphia (one of them being Comcast) that are actively developing with clojure

14:42 rhickey: If you want, I can roll through some of my contacts to see if I can get the groundwork for some sponsorship for you

14:42 fogus_: Is the Haskell industrial community that much larger?

14:43 ohpauleez: fogus_: I wouldn't think so

14:44 fogus_: Granted, Haskell has been around for 100 years

14:44 chouser: in "clojure years"

14:44 ohpauleez: haha

14:45 fogus_: I dog year == ?? Clojure years

14:45 1 that is

14:45 jweiss: i got $20 i can donate :)

14:45 rhickey: ohpauleez: thanks, I'd like to wait until I have a model to propose

14:45 * jweiss clicks donate button

14:46 ohpauleez: rhickey: totally, let me know. I'm more than happy to help via community support or outreach

14:46 michaeljaaka: hi can anyone tell what is wrong with that code? http://pastebin.com/d25bc28af

14:46 I get

14:46 #<CompilerException java.lang.IllegalArgumentException: if-let requires a vector for its binding (NO_SOURCE_FILE:457)>

14:46 that pseudo code (def n {123 #{"a" "b"}})(if-let [t (get n 123)] t nil) works fine

14:47 I think that I'm using it in the same way

14:48 ohpauleez: ,(let [[a b c] [1 2 3] b (str b)] (list a b c))

14:48 clojurebot: (1 "2" 3)

14:48 ohpauleez: look at your let form

14:49 tomoj: is it just me or are you trying to call correct like correct(args...)

14:49 sh10151: tayssir: did you get your MySQL issue sorted out?

14:49 michaeljaaka: doh

14:50 bad call for correct :)

14:50 lol

14:50 Kjellski: Guess you´ve got exactly 5 min to show clojure in a REPL, what would you show?

14:50 sh10151: Kjellski: are you showing it to Java people, Lisp people, or scripting language people?

14:51 Kjellski: sh10151 : Java...

14:52 ohpauleez: michaeljaaka: did that fix it, the correct?

14:52 michaeljaaka: yes

14:52 tomoj: seqs and java interop?

14:52 jweiss: any vimclojure users know how to control indenting? I'm surrounding a form with another fn call, i want it to indent the entire block more.

14:52 michaeljaaka: thank you very much

14:52 sh10151: Kjellski: the Apache Commons isEmpty() example from "Programming Clojure" might be a good start

14:52 Kjellski: sh10151 : And btw. The simple don´t fear the braces from stuarts book is in...

14:52 sh10151: sorry, isBlank

14:52 Kjellski: sh10151 : ^^ you mean the indexOfAny?

14:53 michaeljaaka: this irc channel saves me a lot of time

14:53 jkkramer: manipulating parts of a running program is always fun to show off

14:53 sh10151: no, StringUtils.isBlank from page 2

14:53 Kjellski: jkkramer : like the almost "magically" Frame setSite?

14:53 stuartsierra_: show a simple "map" example, then ask "how would you parallelize this across multiple cores," then add one letter to get "pmap"

14:55 sh10151: are you showing it in a REPL or do you you use slime? when I did a presentation to Java people they seemed impressed with emacs + paredit + slime :-P

14:55 Kjellski: stuartsierra : Thats neat, ... definitively in...

14:55 sh10151: not really something to point out specifically

14:55 jkkramer: Kjellski: could create/run a simple game, like tic-tac-toe. and manipulate rules or appearance during the game

14:55 i might be doing that for a presentation, using the game go

14:56 Kjellski: jkkramer : I would love to discribe what I´m doing while typing, and I guess it would be hard to tell them from scratch everything for a tic tac toe...

14:56 jkkramer: yeah, probably too complex to explain quickly

14:57 stuartsierra_: rhickey used to do demos showing that a Swing GUI app is shorter in Clojure than in Java

14:57 sh10151: Maybe you can concoct an example for (binding ...) ... every time I use it I think, "why the heck do people think they need a framework for this?"

14:57 Kjellski: stuartsierra_: damn, that is a really nice thing to ask... =)

14:57 tomoj: I think it could be good to show them how easily they can use the java stuff they've already got

14:57 but 5min isn't a long time :(

14:58 sh10151: since I'm pretty sure everything you can do with Spring container injection you can do with binding

14:59 Kjellski: tomoj: That´s true! Really not enough ... but I need to fix my time before breaking my own rules... ^^

15:00 sh10151 : I´m not sure that everyone of them used these in lab... so I think one Java-interop thing is missing... maybe a small frame with setSize as you mentioned before?

15:01 sh10151: seems straightforward to me but I think it was stuartsierra_ mentioning Swing :)

15:02 Kjellski: oh, sorry... but that gave me some nice hints, thank all.

15:03 tomoj: I'm wondering if I can convince my employers to let me use clojure since they have java stuff in place. probably unlikely since I'm the only one who knows clojure and I'm not gonna be there for a long time :(

15:03 lisppaste8: Chouser pasted "failed attempt to make assertions about head-holding" at http://paste.lisp.org/display/90685

15:04 chouser: http://www.ecentralmetrics.com/onlinedisplay/jobdisplay.cfm?posting=73790&bid=326 -- comcast job listing with clojure

15:04 * rhickey shudders every time he sees WeakReference

15:04 sh10151: tomoj: I've been able to use it pretty well as a prototyping/scripting/"one-time shot" language

15:05 chouser: rhickey: well this is meant as a diagnostic tool, not for deployed code.

15:05 rhickey: just kidding

15:05 chouser: but I appear to be doing it wrong anyhow

15:06 djork: chouser: wow, clojure in a job listing... that's a first for me

15:06 chouser: tomoj: I've gotten away with using Clojure so far because they're under the vague impression it'll be rewritten in C++ once the performance starts to be an issue.

15:06 stuartsierra_: djork: there have been a few now; follow #clojure on Twitter

15:06 djork: neat

15:07 heh http://craiglook.com/all.html?q=clojure

15:07 0 results

15:07 stuartsierra_: cool jobs aren't on Craigslist :)

15:07 djork: probably not

15:08 tomoj: chouser: haha

15:09 stuartsierra_: chouser: I did the pmap trick for a C++ guy and he said, "ooh, that's hot"

15:09 chouser: heh

15:10 tomoj: this job looks awesome http://is.gd/4YecE

15:10 djork: I can't convince my C# friend that Clojure is even worth a glance

15:11 ohpauleez: then he isn't your friend anymore

15:11 djork: hah. he always says "I can do that with LINQ!"

15:11 but then I say "but can you add new syntax? from a REPL?"

15:11 ohpauleez: Yes Comcast uses clojure, as does Algorithmics

15:12 chouser: cgrand: is pipe the same as fill-queue only *so* much cleaner?

15:12 tomoj: C#==blub?

15:13 djork: C# is a much better blub than most though

15:13 Chousuke_: chouser: when in fact, once performance becomes an issue, you'll just add type hints? :P

15:14 icey: djork, I'm a c# guy; the key is to have him read up on macros

15:14 djork: yeah, I might even call myself a C# guy too :)

15:15 tomoj: hard to see why macros are useful if you've never used them before

15:15 djork: yeah

15:15 icey: i'm trying to remember when / how I saw the light

15:16 djork: functional + REPL + macros + namespaces + multimethods + lazy seqs are the power features to me

15:16 icey: oh, multimethods might be another good angle of attack

15:17 it will be tough to woo him away when F# lands / is supported officially

15:18 chouser: Chousuke_: :-)

15:19 djork: ok... is "chousuke" "chouser's uke" or what?

15:19 Chousuke_: no :P

15:19 Bjering_: You know, you all probably know this, but what a newcomber really want to hear is how something great can be done with Clojure that is just too hard/expensive todo with another tool. Like how hearing that CCP used stackless-Python for EVE Online put many performance-huggers at rest.

15:19 ...as it is _the_ largest single-shard-mmo server.

15:20 djork: clojure would need some beefy hardware for a mmo server (because of thread overhead)

15:20 assuming you used something like an agent per player

15:20 hiredman: erm

15:20 agents are not tied to threads

15:21 djork: pools

15:21 Bjering_: Well, ofc it doesnät have to be that. That was a kiler app for a light-weight-thread system like stackless-Python

15:21 djork: right?

15:23 hiredman: apparently paypal is too hard for me

15:23 djork: some days anything is too hard

15:24 hiredman: I think I haven't used my paypal account in a few years, and maybe they changed something out from under me

15:24 djork: today it's this offshore team's tangle of globals and inane constructs in some iPhone code

15:38 ambient: icey clojure on clr would be sweet

15:38 ...i mean as functional as it is on jvm

15:41 ordnungswidrig: hi

15:42 ohpauleez: hello

15:46 KirinDave: ambient: That way we could have a slower, worse performing clojure on a runtime that is less open and less populated and run by a capricious company with competing products. Sounds good to me. ;)

15:46 ambient: And I say that from the perspective of a Microsoft employee. Even internally we get frustrated at the strange ways of the C#+CLR development timeline.

15:48 djork: hah wow

15:48 Bjering_: Ok, I am at page 141 in "programming clojure" and reading about the relational-algebra. I take it there are no lazy sets?

15:48 djork: yeah, I think the JDK is more well-defined than the CLR at this point, is that correct KirinDave

15:49 KirinDave: djork: I can't ascertain a technical definition from "well-defined".

15:49 djork: The main advantage of the CLR, in my estimation, is that you can write a search engine with C# but it's harder to do with Java. :D

15:50 djork: well-defined meaning how much effort it would take to implement a new and correct VM

15:50 not effort

15:50 but hassle

15:50 Chousuke: Bjering_: I'm not sure how you would implement a lazy set.

15:50 djork: in terms of getting it to be compatible

15:51 KirinDave: Wasn't the old clojure a compiler to java and C#?

15:52 stuartsierra_: KirinDave: yes, it was never released

15:58 hiredman: Chousuke: rule sets!

15:58 mrSpec: Hello

15:58 Bjering_: Chousuke: in a way any predicate is a lazy set I guess... but perhaps there is little value to be able to use the join syntax on those as there are other functions that does that.

15:58 hiredman: ^-

15:59 KirinDave2: Does anyone here use emacs with swank-clojure?

16:00 * the-kenny raises hand

16:00 jasapp: are there many people who don't?

16:00 KirinDave2: I'm having trouble getting swank-clojure-project to work.

16:01 I try to root to my project root and it waits forever.

16:01 I suspect from looking at what process is started that it's not adding the swank-clojure-1.0.jar

16:01 Obviously I can put that in lib

16:01 but it seems like this must be a bug.

16:01 Any advice?

16:02 jkkramer: KirinDave2: is it printing a newline after you press RET when giving the project root path?

16:03 technomancy: KirinDave2: it's a change in behaviour; if you use swank-clojure you should treat it like a dependency, even if it's only a dev-time dependency.

16:03 KirinDave2: technomancy: So I should link it into lib?

16:03 technomancy: previous versions would automatically add it to the classpath, but they assumed that you had a git checkout of the swank-clojure project, which you can no longer assume

16:04 yeah

16:04 * technomancy needs to document that better

16:05 KirinDave2: Well that fixed it. :)

16:05 ohpauleez: does anyone know if -?> is getting moved into core?

16:05 KirinDave2: technomancy: If you want to teach me I'll write up an epic dev howto.

16:05 technomancy: I've gotta break into the community somehow, in any case. ;)

16:05 shonen: ah it is time for me to start on my road with clojure so that opauleez and i can battle to the tic tac toe death

16:06 KirinDave2: I've got a SimpleDateFormat that I want to use ONE of to parse dates in my library

16:07 Is it better style to use a def, or better style to (let [formatter (…)] (defn …))

16:09 Kjellski: Is every datastructure in clojure build from the bit mapped hash trees? In order to get the nice branching factor?

16:09 hiredman: lists are just linked lists, I believe

16:09 rhickey: Kjellski: other than seqs, trees with high branching factors

16:10 maps/sets are tries, vectors just trees

16:10 hiredman: didn't someone reimplement maps using something else?

16:10 chouser: sorted-maps are red black trees, right?

16:10 rhickey: right and sorteds are RB

16:11 technomancy: KirinDave2: I see def used more often than defn inside a let. you might also like defonce.

16:11 Kjellski: Thanks!

16:12 If I "alter" one thing in a list, this would cost linear time? Or how is the old version kept?

16:13 chouser: ooh, you don't know? get ready to experience magic...

16:13 ohpauleez: haha

16:14 Kjellski: chouser : C´mon, I am ready.

16:15 ohpauleez: Kjellski: this was in the IRC yesterday, I'm looking through the logs to find it for you

16:15 chouser: it's "essentially constant" time to change one item. log32

16:15 Kjellski: ohpauleez : Thanks a lot...

16:15 chouser: no locks, no mutation

16:15 hiredman: chouser: he asked about lists

16:16 chouser: oh

16:16 oh

16:16 :-(

16:16 Kjellski: chouser : =P

16:16 ohpauleez: yeah, if you're doing random access or lookup, you should use vectors

16:16 KirinDave2: Yeah, use vectors.

16:16 ohpauleez: unless you have to use a list

16:16 chouser: you can't alter lists except as you would a normal linked list.

16:16 KirinDave2: But evidently (count list) is O(1)

16:17 As is (count my-vec)

16:17 So there is that at least. :)

16:17 chouser: yeah, an immutable linked list that knows its size.

16:17 :-)

16:17 adding/removing from the head is constant time. which is neat, of corse, but hardly magical.

16:18 ohpauleez: Kjellski: check out: http://java.ociweb.com/mark/clojure/article.html#Collections

16:21 Kjellski: ohpauleez: Thanks...

16:21 ohpauleez: Kjellski: np, totally welcome

16:29 kzar: So I've been watching some Clojure videos and I'm pretty convinced but I had one question before I spend too much time learning it. I would want to run web apps on a VM with 256meg of ram, is that possible? (I found Hunchentoot used around 50megs with SBCL and Python used maybe 10megs with web.py, I was wondering what to expect with Clojure)

16:30 ohpauleez: I don't know footprints, but you there is a lightweight web.py like project

16:31 as well as more complete web framework project, like pylons or rails

16:31 kzar: ohpauleez: What's the lightweight one called?

16:32 Kjellski: Is there any other difference than spelling between "trees" and "tries"?

16:33 ohpauleez: There is Compojure (which looks awesome, but I haven't built anything with it) and webjure

16:34 kzar: ohpauleez: OK thanks

16:34 ohpauleez: kzar: I have one more link for you...

16:34 here is a blog, written in compojure: http://github.com/briancarper/cow-blog/tree/master/blog/

16:36 Kjellski: Is there any other difference than spelling between "trees" and "tries"?

16:37 ohpauleez: a trie is a prefix tree

16:37 http://en.wikipedia.org/wiki/Trie

16:39 shonen: yessir a trie be prefix

16:41 arj: hi

16:41 how exactly does one import a static class into clojure?

16:42 a normal import seems to fail with class not found?

16:44 hiredman: well, then you must be doing it wrong

16:44 so unless you show use what you are doing, it will be difficult to tell you what exactly you are doing wrong

16:44 arj: I'm trying to import JNotify

16:44 that class is static

16:45 arohner: arj: is the class on your classpath?

16:45 arj: (import net.contentobjects.jnotify JNotify)

16:45 fails

16:45 but

16:45 (import net.contentobjects.jnotify JNotifyListener)

16:45 works fine

16:45 hiredman: (import '(net.contentobjects.jnotify JNotify))

16:45 arj: ah yeah sorry, that is what I was doing

16:45 tried import-static from clojure-contrib, hence th change

16:46 Could not initialize class net.contentobjects.jnotify.JNotify [Thrown class java.lang.NoClassDefFoundError]

16:46 the class contains only static stuff

16:47 hiredman: do you have the java docs for JNotify?

16:47 arj: no but I have the source

16:48 hiredman: :(

16:48 arj: http://jnotify.sourceforge.net/

16:48 there is some java examples

16:48 *are

16:49 hiredman: it's possible the native part of jnotify is missing

16:49 chouser: arj: do you need the windows support?

16:49 arj: not really

16:49 but I'd like to use Jnotify and not the Linux one, since I would like the dir recursion stuff

16:49 chouser: oh, ok.

16:50 arj: I did a add-classpath with the dir I have the .so file in

16:50 maybe I need to do something else hiredman ?

16:50 hiredman:

16:50 chouser: classpath doesn't help find .so files

16:50 hiredman: ~add-classpath

16:50 clojurebot: add-classpath is bad, avoid it. I mean it!

16:50 kzar: Is there a good page to read for people just starting with Clojure but with Lisp 'n Python experience? I want to give it a shot

16:50 arj: hmm

16:51 * technomancy recommends the peepcode, since he wrote it. =)

16:51 technomancy: ~peepcode

16:51 clojurebot: peepcode is a commercial screencast series; see the Clojure one at http://peepcode.com/products/functional-programming-with-clojure by technomancy

16:51 KirinDave2: I liked the peepcode.

16:51 The project was cool

16:51 arj: how do I make my repl find the .so file?

16:51 KirinDave2: technomancy: Although how you'd implement taking between users seemed tough to me. :)

16:51 hiredman: ~blip.tv

16:51 clojurebot: blip.tv is http://clojure.blip.tv/

16:52 technomancy: KirinDave2: I had that in a branch of mire, but I didn't have time to work it into the video.

16:52 KirinDave2: technomancy: Did you have to make an agent per user?

16:53 technomancy: no, I stored a map of usernames to outputstreams rather than just a set of users

16:53 it didn't work smoothly with the prompt though.

16:53 KirinDave2: Yeah

17:07 arj: gagh system/load also doesn't seem to work

17:12 jasapp: is anyone familiar with discrete event simulation?

17:14 I need to do some simulation, preferably with clojure, and I'm a bit unsure of the proper clojure approach

17:24 twbray: Am closing in on my (presumed, for the moment) memory leak... calling NIO to map regions of a file and stringify them. Never did like NIO much.

17:26 hiredman: huh

17:34 ohpauleez: jasapp: I have made a DES before

17:34 in a lot of languages

17:34 what's up?

17:34 jasapp: interesting

17:35 what do you think the best approach in clojure would be?

17:35 I'm having a hard time not thinking of explicit locking

17:36 ohpauleez: if it's single threaded, no need to lock. You can use a vector of vectors to represent a tree of events

17:36 jasapp: I was thinking of using multiple threads, but I don't know why

17:37 ohpauleez: then you push new events onto the tree and reorder it, and see if there is something to do

17:37 that's typically how I do these things

17:37 jasapp: and a single threaded model doesn't suffer from any performance issues?

17:38 ohpauleez: is this for a college homework assignment or something mission critical

17:38 jasapp: heh

17:38 well, no one will die if it breaks, but it's work related

17:40 performance would be nice since I was considering using a genetic algorithm to find good parameters

17:40 ohpauleez: Sure, if you're just looking to use clojure a tree made up of a vector of vectors should do it

17:41 and if you do things in a nice functional way, you should have no trouble

17:41 jasapp: excellent, thanks for the help

17:42 ohpauleez: totally, I'm trying to dig you up an example before I put up my own

17:42 jasapp: cool, ok

17:42 the single threaded approach doesn't sound bad at all

17:42 shonen: your brain will thank you as well :-P

17:43 ohpauleez: nope, it's real easy, especially when you use a functional approach, it'll be a breeze

17:43 shonen: how many times have we all gone, "why is this variable changing!?! i hate you threading!!"

17:45 hiredman: shonen: er

17:45 variable?

17:46 surely you have mistaken #clojure for #imperative

17:46 shonen: haha oh yes yes quite i apologize

17:46 ohpauleez: jasapp: specifically you want to use a heap: http://bit.ly/37wiF7

17:46 the first result has a PDF

17:47 that walks through it

17:47 jasapp: thanks, I'll check it out

17:47 KirinDave: Heap sorting by event timestamp?

17:48 ohpauleez: more or less

17:48 kzar: Dumb question, I'm following that peepcode video and I was curious how to stop the server from the repl?

17:50 defn: 'lo

17:51 ohpauleez: jasapp: one really dirty and quick way would be to use a sorted map where the keys were timestamps, and the values were the events

17:52 ok, that's all I got, but the way to do it is with a heap. :)

17:54 jasapp: yeah, I was thinking I might just hack out a quick one with a sorted map

18:10 KirinDave: So I have like 0 expereince with clojure and I started writing a quick twitter library

18:10 For a project I'd like to do

18:11 ohpauleez: awesome, how's it going?

18:11 KirinDave: https://gist.github.com/e696d410b168ba507046

18:11 I feel like I am doing something wrong with prep-timeline-entry

18:11 * ohpauleez checks it out

18:11 KirinDave: And yes, i am aware that map is lazy, it's fine.

18:12 twbray: Um.... is "str" lazy? I kinda suspect it might be based on observed behavior.

18:12 KirinDave: twbray: There is an easy way to find out. :)

18:13 twbray: KirinDave: What would that be?

18:14 KirinDave: twbray: Write a (str) that has side effects

18:14 And capture that in a variable.

18:14 twbray: KirinDave: What a perfectly horrible perverted thing to think about.

18:14 Thanks, I'll try that.

18:14 ohpauleez: haha

18:14 KirinDave: (cliffnotes version: str is eager)

18:15 hiredman: str is definitely not lazy

18:15 KirinDave: ohpauleez: Is there anything I am doing obviously wrong?

18:15 twbray: because I'm keying a an array with (str foo bar) where bar is produced by (. substring ... ) out of a 50M Java string and it sorta looks like the string isn't being garbage collected

18:15 er a map I mean

18:16 ohpauleez: KirinDave: I think I might have spotted it, but I'm going to hit the REPL to try some things out

18:16 twbray: Anyhow, back to the coal-face... I'm closing in on the culprit one way or another

18:16 hiredman: twbray: string literals in clojure are .intern'ed, I believe

18:16 KirinDave: Woah

18:16 twbray: hiredman: Yes, they are. None of these are literals.

18:18 hiredman: twbray: have you seen http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=99227e05664f737f96932f3ec3c0?bug_id=4513622

18:19 KirinDave: Huh

18:19 That there is a nasty bug.

18:19 twbray: hiredman: Yeah, I knew that, but I'm taking the substring and making a bigger string with (str ... ); now if str were lazy, I'd have an explanation. But anyhow, I'll know what's going on by end-of-day

18:20 ohpauleez: KirinDave: I'm new to Clojure, this is new to me: [{user :user, created-at :created_at :as entry}]

18:20 if that is indeed a hash map

18:20 KirinDave: ohpauleez: That's a destructing bind on a map.

18:20 ohpauleez: shouldn't it be :key value, etc

18:21 given the :as in the arg list I figured it was destructuring, but that's the correct form?

18:21 KirinDave: ohpauleez: Clojure doesn't seem to feel that way: http://idisk.me.com/dfayram/Public/Pictures/Skitch/Terminal_%E2%80%94_java_%E2%80%94_Homebrew_%E2%80%94_ttys002_%E2%80%94_80%C3%9724-20091118-152059.png

18:22 dysinger: Fancy meeting you here.

18:22 dysinger: I'm usually always here :)

18:22 ohpauleez: ah, awesome

18:22 dysinger: blending the erlang and clojure into a good golash !

18:22 ohpauleez: hmm, let me look some more

18:22 KirinDave: dysinger: My next project is a better jinterface binding for clojure.

18:23 dysinger: sweet KirinDave we should team up - I did that over the weekend !

18:23 the-kenny: Is there a way to do a (binding) with dynamic scopt which gets inherited to threads started by inside this binding?

18:23 dysinger: KirinDave: not to say I have anything finished but played with it.

18:23 KirinDave: dysinger: Is it on github?

18:23 dysinger: no not yet

18:24 hiredman: the-kenny: there is a new construct, bound-fn, which will capture dynamic bindings

18:24 KirinDave: dysinger: It seems like a multi-method could make it very easy to auto-convert clojure primitives to the Erlang primitives.

18:24 dysinger: KirinDave there is some public domain clojure code on the clojure list @ goog groups

18:24 the-kenny: hiredman: Is this in the "new" branch?

18:24 dysinger: KirinDave: exactly

18:24 ohpauleez: KirinDave: what is happening when you run it. That looks fine to me

18:24 KirinDave: dysinger: And a language with vectors, lists, maps, and symbols makes it way easier.

18:24 ohpauleez: Oh it's not broken

18:24 the-kenny: hiredman: And... is it stable enough?

18:24 dysinger: that's what the google groups code looks like KirinDave

18:24 hiredman: tehseel no idea

18:24 er

18:25 the-kenny: no idea

18:25 ohpauleez: ohh, that looks fine to me

18:25 KirinDave: ohpauleez: I was hoping for style tips, particularly with the prep-timeline-entry

18:25 hiredman: I've never bothered with it, since I understand the difference between dynamic and lexical scope, and avoid dynamic scope

18:26 the-kenny: hm... it's in "fbacc4a"

18:26 KirinDave: hiredman: It makes sense for things like io streams. It was just overused in the past. :)

18:26 dysinger: KirinDave: http://clojure.googlegroups.com/web/erlang+(2).clj?gda=nPnuyEQAAAB9TgGpbzbMg0BCq3i8IqXnF8SIL0JIfoYuHsuFZ6eabNDNU7UYDrd2uE4tSk0x5Y5V6u9SiETdg0Q2ffAyHU-dzc4BZkLnSFWX59nr5BxGqA

18:26 KirinDave: hiredman: Fear it not

18:26 hiredman: KirinDave: I don't fear it

18:26 I just have no need of it

18:26 and it annoys me that everone *must* write their database api to use it

18:27 KirinDave: So for something like clojure.contrib.json.read, what do you recommend is a better solution?

18:28 the-kenny: hiredman: That's exactly my problem :) I have a setup with some thread pools and one or two agents... and I'm using clojure-couchdb, which uses a binding named *server*.

18:28 hiredman: grrr

18:28 the-kenny: I hacked a macro together, but it really bloats the code..

18:28 hiredman: the-kenny: wrap the api with functions that take a server argument

18:29 or write an email to the author complaining

18:29 KirinDave: Well what's the correct solution?

18:29 dysinger: KirinDave: the thing I am working on is clojure + interface (client) | erlang + ports + clojure + jinterface (server)

18:29 s/interface/jinterface

18:29 (on the side for fun)

18:29 KirinDave: dysinger: You know exactly why I'd like to get java talking over a local erlang port. ;)

18:29 dysinger: :)

18:30 KirinDave: I can't show you the code yet, but the next big katamari thing is nodes that can handle multiple connections at once.

18:30 dysinger: sweet

18:30 KirinDave: And removing the insistence on port-based nodes.

18:30 dysinger: cool

18:30 KirinDave: Well, that'll make katamari able to work very well with hadoop.

18:31 Which I think will be a big part of the future of katamari...

18:31 the-kenny: hiredman: hm.. sounds a bit annoying. There is also a problem with the http-library clojure-couchdb uses.. I have to send an authentication-header to properly identify to the database server, and clojure-couchdb provides no api to access the underlying http-calls... I hacked together a solution to modify the standard-headers field of the http-client :D

18:31 hiredman: http://github.com/hiredman/clojurebot/blob/master/hiredman/triples.clj <-- all the functions take a db parameter

18:31 dysinger: I like the idea - better than hadoop's IO based mappers

18:32 jasapp: hiredman: did you ever use clsql for common lisp?

18:32 KirinDave: hiredman: Man that is one HELL of a defmethod criterion.

18:33 hiredman: jasapp: nope

18:34 the-kenny: http://stackoverflow.com/questions/480153/how-to-modify-the-header-of-a-httpurlconnection

18:34 KirinDave: :)

18:34 I'm sure I could have just written out a table and reduced it to a few cases

18:34 but I just can't be bothered

18:35 the-kenny: hiredman: I know how to do this, but I don't have any access to the instance of HttpUrlConnection clojure-couchdb uses :(

18:35 hiredman: :|

18:36 sounds like you need to reach out to the author

18:36 danlarkin?

18:36 the-kenny: Yes

18:36 He said some time ago that he's really busy

18:37 But I have a fork of it in my local repository.

18:38 I think I'll just merge the http-url to the server with the db-parameter...

18:38 The first time I tried to use the library, I tried exactly that because there was no documentation

18:38 dysinger: I have rubbed the genie lamp

18:39 danlarkin will be here in a sec :)

18:39 * danlarkin appears!

18:39 the-kenny: Wow, where did you get that lamp? :)

18:39 hiredman: almost like /summon still worked

18:40 dysinger: (we work together)

18:40 danlarkin: the-kenny: yeah I saw you have patches for me

18:41 I just haven't gotten around to reviewing or applying them :(

18:42 the-kenny: danlarkin: No problem :) I didn't want to rush you

18:44 danlarkin: the-kenny: maybe I'll give you commit access to my repo and "solve" the problem that way :)

18:44 I'm not dealing with couchdb too much at the moment

18:45 the-kenny: danlarkin: Oh, I'm happy with my fork. I don't want to mess things up in your repository

18:53 Ah, I think I've found a clean way to deal with the authentication problem

18:57 qed: every time i think i understand loop/recur i just sit there and scratch my head -- im trying to take a vector [1 2 3 4 5], and conj the product of [1 2 3], [2 3 4], [3 4 5] onto a vector

18:58 errr (* 1 2 3), (* 2 3 4), etc.

18:59 the-kenny: Awesome :) java.net.Authenticator is just perfect

19:01 jweiss: anyone here use vimclojure? i'm trying to figure out why when i run this in its repl, (do (println "hi") (Thread/sleep 2000) (println "there")) - that nothing is printed until after the sleep, then it prints everything.

19:01 qed: jweiss: let me apologize in advance for saying this, but: learn emacs

19:02 repls in vim == ugly hacks

19:03 jweiss: qed: i'm not going to learn emacs just to use clojure

19:03 defmacro: jweiss: amen

19:04 the-kenny: jweiss: But emacs is the nonplusultra for lisp-editing

19:04 I learned it just for CommonLisp and I'll never go back

19:04 qed: i learned emacs to use clojure

19:05 it took about 1 week of pain, but now id never go back

19:05 </editor wars>

19:05 jweiss: meh

19:05 the-kenny: qed: I felt no pain. I had a feeling of freedom after one or two years with vim

19:06 qed: i use vim still for really quick and dirty stuff if i dont have an emacs open already

19:06 defmacro: emacs is all pain to me, <8 vim, but that's just me

19:06 fanatico: there is always viper-mode.

19:06 qed: defmacro: the big thing for me was getting emacs configured to fit my tastes

19:06 if you dont like emacs, you can change every damn thing you dont like

19:07 fanatico: emulates the vi key bindings in emacs.

19:07 qed: evaluating elisp inside your buffer is pretty sweet

19:07 defmacro: qed: very very true, and I never got it configured to suit me. but i really love the modal editing theme in vim, the emacs commands didn't make sense to me

19:08 qed: defmacro: yeah they're really weird at first, but its been about a month since i started with emacs, and im flying around now

19:08 it's a little pain, big gain, IMO

19:08 defmacro: qed: emacs also have me more hand pain than vim, which is a serious thing fo rme

19:08 the-kenny: Emacs isn't complicated.. it's much easier to understand the first time than vim, in my opinion

19:08 qed: and this brings us to our next discussion: keybindings and keyboard choice

19:09 defmacro: qed: kinesis contour, with customized mappings for keys to load balance across my hands and good fingers left

19:09 qed: map ctrl to caps lock

19:09 defmacro: booya, nice

19:09 i love the kinesis advantage pro

19:09 but ive been using my happy hacking keyboard almost exclusively at work

19:10 not as good for my hands, but very functional still

19:10 defmacro: yeah, i got three of the kinesis, for every workstation. i cannot type on anything else, making my macbook useless

19:10 qed: the keyswitches on the HHK make it friggen butter

19:10 Topre capacitive switches

19:10 * qed melts

19:11 * jweiss sighs,spent all day learning more complex editing in vi

19:12 jweiss: i suppose it's not wasted

19:12 none of the systems i use at work have emacs by default

19:12 but they all have vi/vim

19:13 the-kenny: jweiss: It's possible to use vim *and* emacs.

19:13 defmacro: working on using vim's ruby support to extend the editor, heh

19:13 jweiss: the-kenny: yeah, but having to learn more than one arcane editor kinda sucks. why can't one of them be enough

19:15 defmacro: jweiss: do you want/need to use slime? cause vim doesn't have anything close to that awesomeness, that's why one can't be enough

19:15 qed: ^^

19:15 the-kenny: Yes, slime and org-mode are the most awesome pieces of software for emacs.

19:16 jweiss: defmacro: what specifically about vim makes it worse? just that no one wrote something like slime for it?

19:16 defn: can you hang out in #clojure while you're coding clojure in another buffer and using slime/swank-clojure repl in another buffer inside your editor?

19:16 jweiss: seems like of arbitrary

19:16 defn: jweiss: no it's the base construction of emacs

19:17 thats why you can code something like slime for it

19:17 vim "REPL"s are hacks

19:17 defmacro: jweiss: have someone show you slime in person, it blew me away. not enough to make me switch to emacs, tho ;p

19:17 jweiss: well, back in college i hated emacs, but then again, back then i found java confusing.

19:17 so maybe it's worth another look

19:17 the-kenny: vim can't execute other processes on a clean way.. I think that's the biggest problem

19:18 defmacro: also, vimscript is not compariable to elisp for extending the editor

19:19 defn: jweiss: i know im evangelizing a bit here, BUT-- I tried to learn emacs like 4 times, always losing my will power and heading back to vim. This last time I said enough is enough, aliased vim, vi, etc. to emacs -nw, and struggled like crazy to do some of the most basic stuff imaginable for the first two weeks

19:20 but in the end, you will be a more efficient programmer if you take the time to get to know emacs, and that's probably going to sound like im trolling or something, but honestly, i firmly believe it to be the truth

19:20 the best software devs ive met in my life seemed to all have one thing in common: emacs

19:20 jweiss: ok, ok, it's not like vim is a shining example of clarity either, so my only reason not to go to emacs is inertia

19:21 defmacro: i should hire an emacs expert for a day to customize my setup, i just can't get started enough

19:21 fanatico: jweiss: once again, I gotta recommend viper-mode. Makes the transition much easier.

19:21 technomancy: defmacro: *cough*peepcode*cough*

19:21 defn: defmacro: the whole setup process involves a lot of pain

19:21 technomancy: </shameless-promo>

19:21 defn: technomancy's screencast on peepcode is good

19:22 defmacro: technomancy: i bought that, but i want ultra aweosme customization and i want it in a day ;p

19:22 defn: defmacro: i know where you're coming from exactly

19:22 duncanm: twbray: congrats congrats!

19:22 defmacro: once i get it the way i like, oh, i'll be 100% into emacs, but until then, i can barely stand 20 mins figuruing this and that

19:22 technomancy: defmacro: ah, that will have to wait until my career-change to a traveling lisp mendicant then.

19:22 defn: my advice is this: open up technomancy's elpa-to-submit in his starter-kit, and pick the .el files you want in your setup, install elpa, make your own init.el, and slowly start cobbling your setup together

19:23 jweiss: i'm not going to customize anything. i hate that i can't do anything on any machine but my own. i always use basically stock setup

19:23 defn: IMO you absolutely cannot just use a starter kit out of the box and be happy

19:23 you're better off starting from scratch and adding stuff as needed

19:23 defmacro: defn: tried that, i'm just too dumb. i'll keep trying tho, seriously i think a day with an emacs guy clarifying my misconcpetions about emacs setup is the way to go

19:24 technomancy: defmacro: nothing compares to looking over the shoulder of someone who's immersed in it.

19:24 defmacro: defn: yeah, i agree

19:24 technomancy: defmacro: are you the guy behind defmacro.org?

19:24 defmacro: technomancy: all textmate and vimmers at work, hehehe

19:24 technomancy: no, new nick

19:25 arj: I have a problem with the slime repl. I'm registering callback handlers in jnotify but I don't get any messages it seems when in slime, but if I start up a repl outside of emacs it works. Any ideas?

19:25 * fanatico waits for someone to start rentanelispcoder.com.

19:25 defmacro: actually, i've stopped playing with clojure cause coding with vim seems less than natural, tho for ruby it's fine

19:26 Chousuke: jweiss: you could have your config on github or something and then just clone it onto machines (or download a tarball)

19:27 technomancy: dotfiles on github is a must, no matter what your editor is

19:27 jweiss: hm that's a good idea

19:29 kzar: so loop in clojure seems to be completely different to loop in CL, is there something like common lisp's loop?

19:29 the-kenny: kzar: Loop is propably the ugliest and the most awesome thing at once - But I don't like it :)

19:30 Oh and no, there isn't something like cl's loop in clojure.

19:30 Chousuke: I think I saw at least a partial implementation of cl loop somewhere. :/

19:30 kzar: the-kenny: So supposing you need to loop over a list, grabbing the first 3 items each time what would be the clojure way to do that/

19:31 Chousuke: (map f (partition 3 list))?

19:31 the-kenny: kzar: (map fn (partition 3 list) or so

19:31 Chousuke: explicit loops are not idiomatic.

19:31 defn: oh boy

19:31 im having a hard time understanding loop/recur too

19:31 it still is making no sense to me :\

19:32 the-kenny: defn: Try not to use it :)

19:32 defn: im working on it the-kenny ! :)

19:32 Chousuke: defn: it's kind of like a recursive function

19:32 defn: right now i have this vector [1 2 3 4 5], and i want to conj (* 1 2 3), (* 2 3 4), etc. onto a list

19:33 Chousuke: only: there is no function object and primitives are supported.

19:33 defn: i put the conj part into my (recur ()), and inc my counter, but then i have 2 args where it expects 1

19:33 it's unnerving

19:33 Chousuke: (map (partial apply *) (partition 3 1 [1 2 3 4 5]))

19:33 hmm

19:33 ,(map (partial apply *) (partition 3 1 [1 2 3 4 5]))

19:33 clojurebot: (6 24 60)

19:34 defn: close

19:34 kzar: the-kenny / Chousuke: With the example list of [1 2 3 4 5 6] I need to run fn on [1 2 3], [2 3 4], [3 4 5], [4 5 6]. I think that example would run it on [1 2 3] [4 5 6]

19:34 defn: kzar: #11 in projecteuler, eh?

19:34 kzar: defn: What's projecteuler?

19:34 Chousuke: kzar: partition supports a step.

19:34 ,(map (partial apply *) (partition 3 1 [1 2 3 4 5 6]))

19:34 clojurebot: (6 24 60 120)

19:35 defn: oh, nvm, i have the exact same question kzar -- which is weird

19:35 the-kenny: ,(partition 3 1 [1 2 3 4 5 6])

19:35 clojurebot: ((1 2 3) (2 3 4) (3 4 5) (4 5 6))

19:35 kzar: Cool thanks

19:37 defn: whoa dude, that's awesome

19:47 i was going about solving that problem the complete wrong way

19:50 ,(partition 1 [1 2 3] [1 2 3] [1 2 3])

19:50 clojurebot: java.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number

19:50 defn: ,(partition 1 [[1 2 3] [1 2 3] [1 2 3]])

19:50 clojurebot: (([1 2 3]) ([1 2 3]) ([1 2 3]))

19:51 defn: ,(partition 2 1 [[1 2 3] [1 2 3] [1 2 3]])

19:51 clojurebot: (([1 2 3] [1 2 3]) ([1 2 3] [1 2 3]))

19:51 Chousuke: what are you trying to accomplish?

19:51 partition takes a single sequence and divides it.

19:51 * defn nods

19:52 defn: i have this vector of vectors, it amounts to a 20x20 grid, so now that i have all of the products for the horizontal combinations

19:52 i need to find the vertical combinations, and finally the diagonal combinations

19:53 my structure looks like [[1..20] [1..20]...[1..20]]

19:54 KirinDave: Why did you choose to make it that way?

19:54 * defn shrugs

19:54 defn: how would you do it?

19:54 Chousuke: well the vertical combinations are easy I think

19:55 ,(apply map + [[1 2 3] [4 5 6] [7 8 9]])

19:55 clojurebot: (12 15 18)

19:56 KirinDave: defn: Well, I'd make it a flat array

19:56 defn: And then use partition to make rows and columns as separate views.

19:56 defn: yeah i originally planned on doing just that

19:58 _mst: a nice thing about the nested vectors approach is you can get out the diagonals using get-in...

19:58 possibly a bit harder with a flat vector?

19:58 defn: Chousuke: your solution works, but if i have [[1 2 3] [4 5 6] [7 8 9] [10 11 12]], i need to get (* 1 4 7), (* 4 7 10), etc.

19:58 KirinDave: I dunno if it'd be any harder.

19:58 defn: harder to think about with a flat vector

19:58 for diagonals i like the nested vectors

19:59 KirinDave: Um, just write a function to translate from [x,y] -> [n]

19:59 defn: like i said "i like the nested vectors"

19:59 KirinDave: That's fine. I was just pointing out that the diagonals are not significantly easier to compute. :)

20:00 defn: sure sure

20:00 im heading home, see you guys later

20:00 thanks for the help all

20:03 michaeljaaka: hi

20:03 I'm getting Caused by: java.lang.Exception: Can't take value of a macro: #'ds.commons/invoke-me

20:03 at clojure.lang.Compiler.analyzeSymbol(Compiler.java:4610)

20:03 at clojure.lang.Compiler.analyze(Compiler.java:4307)

20:03 any idea what causes that?

20:03 anyone got such problem?

20:08 fanatico: Just like it says, you're trying to treat a macro like a value.

20:09 KirinDave2: michaeljaaka: What expression involving invoke-me signals that error?

20:10 michaeljaaka: (defn some[d] invoke-me d rest of args.. )

20:10 KirinDave2: Maybe you meant

20:10 (defn some [d] (invoke-me d …))

20:10 ?

20:10 michaeljaaka: then i get EOF

20:11 KirinDave2: Um

20:11 I suspect that there is a simple syntax error

20:11 michaeljaaka: in macro?

20:11 Caused by: java.lang.Exception: EOF while reading

20:11 at clojure.lang.LispReader.readDelimitedList(LispReader.java:1003)

20:11 at clojure.lang.LispReader$ListReader.invoke(LispReader.java:860)

20:11 at clojure.lang.LispReader.readDelimitedList(LispReader.java:1011)

20:11 when typed as you propsed

20:12 KirinDave2: What is the actual statement you typed?

20:12 I'm pretty sure it's impossible to make a macro that makes unbalanced parens.

20:12 duncanm: la la la

20:14 arj: is there any way I can using ns and import, import something java into the namespace under a different name?

20:15 fanatico: arj: Don't think so. Clojure and Java are in a different namespaces.

20:15 michaeljaaka: http://pastebin.com/d46062ac6

20:15 here is an actual code

20:16 that don't want to compile

20:16 arj: fanatico: ok, it's just that if I import something I can't create my own e.g. structs with the same name as one I imported, it's a bit annoying

20:16 KirinDave2: michaeljaaka: One moment.

20:16 fanatico: michaeljaaka: http://pastebin.com/mc7209be

20:17 duncanm: michaeljaaka: why did you write that as a macro?

20:17 michaeljaaka: because iface is an java interface name

20:17 and when written as fun iface won't be resolved

20:18 fanatico: arj: yeah. If you're not using the java class/method that conflicts, you could exclude it from the import, or you could refer to the clojure name using the full namespace.

20:18 michaeljaaka: fanatico: I get EOF when I write "act" like this

20:19 fanatico: michaeljaaka: did you balance the parens for let?

20:19 michaeljaaka: yes

20:19 KirinDave2: michaeljaaka: http://gist.github.com/238447

20:19 michaeljaaka: That does not eof for me.

20:19 And appears to match your intent

20:19 What editor are you using?

20:19 michaeljaaka: enclojure

20:20 KirinDave2: Because lisps really demand an editor.

20:20 arj: sadly I am importing something important that conflicts. But it doesn't seem like I*m able to define a new struct with the same name as some java class I imported

20:20 would be cool with a import bla as foo

20:20 KirinDave2: I'd highly recommend emacs + clojure-mode + paredit

20:20 michaeljaaka: this is an editor for netbeans

20:20 ok

20:20 KirinDave2: Anyways, I suspect you simply had unbalanced parens.

20:20 michaeljaaka: I will try compile it with emacs

20:21 KirinDave2: Just make sure your quotes are right

20:21 Remember, invoke-rmi _must_ be immediately prefaced by an open-paren to work.

20:21 arj: does anyone know why slime eats some of the output that the running code produces? It seems like messages coming out-of-band are not displayed at all?

20:22 KirinDave2: "out of band"?

20:23 the-kenny: I think he means from a different thread or so.

20:23 arj: If so, you can find them in the inferior-lisp buffer.

20:24 michaeljaaka: ok

20:24 arj: the-kenny: ah!

20:24 duncanm: arj: yeah, it's a little confusing, but *out* and *err* are not the same as System.out and System.err

20:24 arj: thanks a lot

20:24 michaeljaaka: I have looked at code and truly there were missing two closing parens

20:24 thanks a lot!

20:24 arj: very newb slime question I guess :D

20:24 michaeljaaka: btw why pastebin is lame?

20:25 KirinDave2: arj: I'd use a C-x 3 in your slime repl, then swap one to the inferior lisp buffer.

20:25 That is what I do

20:25 duncanm: michaeljaaka: i don't understand your answer

20:26 KirinDave2: arj: You end up like so : http://idisk.me.com/dfayram/Public/Pictures/Skitch/%2Ainferior-lisp%2A-20091118-172516.png

20:26 michaeljaaka: ; Rule #1, fuck pastebin.

20:26 this is from http://gist.github.com/238447#file_gistfile1.txt

20:26 KirinDave2: michaeljaaka: Because it is fairly ugly and hard to read. gist is nice because it puts the code way out in front, design wise

20:26 I mean, compare those two pages.

20:26 arj: KirinDave2: yeah that's pretty cool, thanks agian

20:27 KirinDave2: michaeljaaka: You can also checkout and manipualte whole pastes as a git repo, which can be very handy sometimes in larger pastes. And also because mojombo, defunkt and the crew are Folks Who Know What Salsa Should Taste Like.

20:28 michaeljaaka: :)

20:28 ok

20:28 now I know gist, paste.lisp.org and pastebin

20:29 hiredman: http://delicious.com/clojurebot/pastbin

20:29 michaeljaaka: :)

20:30 the-kenny: clojurebot has a delicious integration? Nice idea :)

20:31 hiredman: :)

20:53 churib: when happens destructuring? at read time?

20:54 chouser: runtime

20:55 churib: okay, thanks

20:55 hiredman: well, it's a macro

20:56 it's expanded at macro expand time, but the code it expands to is run at runtime

21:13 polypus: is this (eval `(fn ~arg-lst ~expr)) the recommended way of building a function at run time when one has a param list and expression?

21:15 duncanm: polypus: or you could use a macro

21:17 chouser: do you understand what michaeljaaka said about his macro? i'm not completely familiar with how identifiers are resolved in Clojure macros (vs. Scheme macros), but what he said didn't make sense to me

21:26 fanatico: duncanm: outside of the (.) special form, java methods don't resolve, so invoke-rmi has to be a macro.

21:34 jweiss: ok, so i was convinced this evening to switch to emacs+slime (from vim-clojure). it was pretty easy to set up. i still have no clue how to use emacs, but at least the REPL works. 2 questions. how to set classpath, and how to change the color scheme?

21:34 i saw via google a way to set classpath in the .emacs, but apparently you have to restart emacs anytime that changes. there must be an easier way?

21:36 fanatico: jweiss: C-x C-e evals the last sexp (both in elisp and clojure), so you can update the variable that way. You still may have to restart slime.

21:38 jweiss: wow, in emacs, jumping to line 99 is "ESC-X goto-line <enter> 99" ? that sucks

21:39 i'm about to fall back on viper mode

21:39 _mst: always seemed strange that it was never bound to a key

21:39 but you can bind it to a key yourself! :)

21:39 jweiss: _mst: all in due time, first i have to figure out how to do basic stuff

21:39 * jweiss is lost

21:40 jweiss: but i can see it'll be better than vi,someday

21:40 _mst: ah right :) in my ~/.emacs I have: (define-key global-map (kbd "C-c g") 'goto-line)

21:40 hiredman: pfft

21:40 jweiss: i never knew the .emacs file was lisp. that is pretty cool

21:41 dnolen: _mst: I used (meta-n), simpler, I had multiple groups of keys I used often.

21:41 also a fan of binding function keys to start REPL, magit, shell, etc.

21:42 _mst: ah yep. I'm not sure what my meta-n is off the top of my head, but I can assure you it's bound to something somewhere :)

21:43 dnolen: I hate multiple groups of keys I mean for common commands

22:12 polypus: duncanm: thanks but how? this don't work (defmacro template-function [arg-lst expr] `(fn ~arg-lst ~expr))

22:33 kzar: What's the easiest way to get the first 3 values of a sequence?

22:35 fanatico: ,(take 3 '(1 2 3 4 5))

22:35 clojurebot: (1 2 3)

22:36 kzar: fanatico: ah sweet

22:36 thanks

22:36 fanatico: np

22:41 kzar: fanatico: Is there something to give the rest after the first 3?

22:42 fanatico: ,(drop 3 '(1 2 3 4 5))

22:42 clojurebot: (4 5)

22:44 kzar: tah :)

22:46 (Although it would be kind of odd for a Lisp, maybe first and next should have an optional number parameter. It would make sense and avoid drop and take being needed)

22:47 chouser: ,(split-at 3 (range 5))

22:47 clojurebot: [(0 1 2) (3 4)]

23:13 kzar: Is the closest to "for i in [1 2 3 4 5] ..." (map (fn [i] ...) [1 2 3 4 5] ?

23:14 chouser: ,(for [i [1 2 3 4 5]] (* i 2))

23:14 clojurebot: (2 4 6 8 10)

23:17 chouser: kzar: note that both 'map' and 'for' return lazy seqs -- neither is an imperative loop like python's 'for'

23:19 kzar: whoops I didn't realise there was a for. Yea I watched some of the videos that mentioned about lazieness, it seems like a brilliant idea that's going to fuck me over one day soon heh

23:22 defn: 'lo

23:23 kzar: laziness* damn flyspell :(

23:30 chouser: kzar: heh, could be.

23:31 kzar: usually it only causes me trouble when I'm trying to be too clever -- lazily consuming UI events or lines from an open file or something.

23:31 defn: how do you use get-in?

23:31 i have a structure like [[1 2 3] [4 5 6]]

23:32 _ato: ,(get-in [0 0] [[1 2 3] [4 5 6]])

23:32 clojurebot: nil

23:32 _ato: hmm

23:32 tomoj: backwards

23:32 ,(get-in [[1 2 3] [4 5 6]] [0 0])

23:32 clojurebot: 1

23:32 _ato: ah right

23:32 of course

23:33 tomoj: ,(get-in [[1 2 3] [4 5 6]] [1 1])

23:33 clojurebot: 5

23:33 defn: ah cool

23:33 thanks

23:34 _ato: heheh I rely on slime's argument hints in the minibuffer too much... hmm... I wonder if I can get it to do it with IRC too. ;-)

23:35 defn: i dont understand the get-in "documentation", the whole m keys thing

23:36 _ato: ,(doc get-in)

23:36 clojurebot: "([m ks]); returns the value in a nested associative structure, where ks is a sequence of keys"

23:37 _ato: m means map (an associative structure)

23:37 ,(get-in {:foo {:bar 2}} [:foo :bar])

23:37 clojurebot: 2

23:38 _ato: ks is the keys in the nested maps that get to the value you want

23:38 a vector can be thought of as a map between indices and values

23:38 defn: sure i mean i understand the structure

23:39 but ive thought of [0 0] as being a sequence of keys

23:39 never thought of*

23:40 nevermind it all makes sense now

23:41 ive successfully embaressed myself again

23:41 no need to worry

23:46 fanatico: why does `get-in` take [m ks] instead of [m keys*]?

23:47 are there any guidelines about when to write one style over the other?

23:54 ,(defn my-get-in [x & args] (if (seq args) (recur (get x (first args)) (rest args)) x))

23:54 clojurebot: DENIED

23:55 fanatico: ,((fn [x & args] (if (seq args) (recur (get x (first args)) (rest args)) x)) [[1 2 3] [4 5]] 0 1)

23:55 clojurebot: 2

Logging service provided by n01se.net