#clojure log - Apr 18 2010

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

0:01 _brian2_: hi, i am trying to grok the enlive tutorial better, have question about selectors , ie how this works: http://clojure.pastebin.com/5v4GKYUE

0:07 falconair: [newbie] hi, i started the repl through "lein repl" for a project that has clojure-contrib as a dependency, but (doc create-server) gives "Unable to resolve var" error

0:07 I also tried (doc clojure-contrib/create-server), same thing...how can i resolve this?

0:09 schemer999: is compojure the most developed clojure web framework?

0:10 _brian2_: schemer999> you might want to look at enlive and the enlive tutorial, which is built on top of compojure

0:11 schemer999: _brian2_: thanks, i'll look into that.

0:12 _ato: falconair: what

0:12 s

0:12 create-server

0:12 oh right, server-sock

0:12 falconair: _ato create-server is a function in clojure-contrib (http://richhickey.github.com/clojure-contrib/server-socket-api.html)

0:12 _ato: you first need to require/use it:

0:13 (use 'clojure.contrib.server-socket)

0:13 falconair: i tried (use clojure-contrib)

0:13 _brian2_: you need '

0:14 falconair: hm...just tried (use 'clojure-contrib.server-socket) and it told me "Could not locate clojure_contrib/server_socket_init.class or ...)

0:14 _ato: not dash

0:14 .

0:14 clojure.contrib

0:15 schemer999: i'm getting ready to start a slightly involved web app. def don't want to use php again. rails looks interesting, but clojure looks fun.

0:15 falconair: _ato: so I need to use ' for repl but not when i am writing in a clj file?

0:15 _ato: you need to use ' when you just do a bare (use '...). You don't need it when you're putting a (:use ...) inside an (ns ...)

0:16 falconair: _ato, hm...ok, thanks

0:17 _brian2_: <schemer999> i'm not an expert, but compojure is based om sinatra (ruby)which is a much simplified web framework

0:17 easier to prototype

0:20 _ato: falconair: it's because bare (use ...) is a function while (ns ...) is a macro. The whole import thing often comes up as one of the messier parts of Clojure, there's been a lot of talk of simplifying it, but it's a tricky issue

0:21 falconair: _ato...so if I had to call (use (clojure.blash)), then I understand needing a tick to tell clojure that (clojure.blah) is not a function, but why do I need a tick when clojure.contrib... is clearly an argument to use?

0:22 I don't have to do (+ '1 '2) afterall

0:23 _ato: numbers evaluate to themselves

0:23 ,1

0:23 clojurebot: 1

0:23 _ato: symbols don't

0:23 ,blagh

0:23 clojurebot: java.lang.Exception: Unable to resolve symbol: blagh in this context

0:23 _ato: ,'blagh

0:23 clojurebot: blagh

0:23 _ato: so they need to be quoted when you pass them to a function

0:24 falconair: _ato..hm...ok, i'm starting my first project, hopefully i'll get over these basics soon :)

0:28 defn: was clojure.lang.ArrayStream deprecated with 1.2?

0:36 java.lang.ClassNotFoundException: clojure.lang.ArrayStream (safe_fns.clj:124)

0:36 hiredman: the Stream stuff was an idea rich was working, but never was used anywhere as far as I know, so if it dispeared I would not be surprised

0:36 defn: hiredman: okay, thanks

0:39 technomancy: defn: http://www.assembla.com/spaces/clojure/tickets/247-remove-clojure-lang-stream-streamable-and-all-uses

0:39 sexpbot: "#247 - Remove clojure.lang.Stream/Streamable and all uses (Fixed) | Clojure | Assembla"

0:46 defn: technomancy: thanks -- i was going to try to go to 1.2 with my project, but it looks like too many deps will break

0:47 java.io.FileNotFoundException: Could not locate clojure/contrib/java_utils__init.class or clojure/contrib/java_utils.clj on classpath: (core.clj:9) --- Looks like this is Ring's fault

0:48 cemerick: defn: I just pushed a 1.2-compatible changeset to my compojure fork FWIW

0:49 0.3.2 though, not 0.4.0

0:49 defn: cemerick: thanks i found sergey miryanov made a 1.2.0 compat version

0:49 cemerick: sheesh, right

0:49 * cemerick should go to bed

0:50 technomancy: never heard of anyone actually trying to use streams =)

0:51 cemerick: It seems like lazy seqs are streams++, IIUC

0:51 Never used streams myself either.

0:59 defn: man i cannot figure out where this include of java-utils is coming from

1:51 yn: Is there a place where I can download all clojure docs (reference, clojure api, clojure-contrib api) in one large archive? Can't find it through google, and want to make sure before I start running a big wget job

2:07 nipra_: yn, I don't think so it's available as a tarball. Clojure and contrib API docs are available at http://github.com/richhickey/clojure/tree/gh-pages and http://github.com/richhickey/clojure-contrib/tree/gh-pages respectively.

2:10 defn: yn: use autodoc

2:11 if you grab the autodoc source i think you'll be able to build all of the API docs for c.contrib and core without any wgetting

2:23 yn: anyone here?

2:27 Hali_303: hi!

2:28 is there a safe parse-integer function in some namespace? I mean if Integer/parseInt throws exception it returns nil

2:29 tomoj: seems doubtful

2:30 well, perhaps in some namespace, but not in core or contrib, afaik

2:32 Hali_303: tomoj: ok, thanks

2:37 tomoj: Hali_303: I'm not actually sure, but people have asked for a clojure version of Integer/parseInt before only to be told to just use Integer/parseInt, which suggests that you'll have to write it yourself

2:38 Hali_303: I did already, just curious if there is an official one

2:42 falconair: is there a good vim syntax file for clojure, i know there is vimclojure that does all kinds of fancy stuff, but i'd like to start with just a syntax file

2:46 cheezey: mm... so im so lost on that lazy seq thing =_=

2:46 defn: cheezey: that one takes a little bit to wrap your brain around :)

2:46 bozhidar: tomoj: it's useless to wrap stuff like Inteter/parseInt imo

2:47 after all one of clojure's core ideas is not to fix parts of java that aren't broken

2:47 cheezey: defn: is there a good tutorial? im just trying to use the string library from clojure-contrib but it returns a lazy seq instead of a string and im like ... blahhhh

2:49 defn: cheezey: oh, well, that might not be as hard to work with as you think

2:49 cheezey: what are you trying to accomplish

2:50 cheezey: use (take n s) and actually get a string :p

2:50 although i'd still like to learn about lazy seqs so .. :\

2:51 defn: cheezey: you want to be lazy

2:51 cheezey: i know about lazy evaluations. is that all it is?

2:52 defn: basically yea, it just is a sequence which is evaluated lazily

2:54 cheezey: right. so what is the thing returned? why is it a sequence?

2:55 defn: cheezey: if you have a specific example of some code and an objective that'd be helpful

2:55 tomoj: bozhidar: sure, unless you want it not to throw an exception :)

2:55 defn: ,(+ 1 2)

2:55 clojurebot: 3

2:55 defn: you can evaluate code using clojurebot by prefixing a , to your expression

2:55 cheezey: ,(take 2 "asdf")

2:55 clojurebot: (\a \s)

2:55 cheezey: that was my earlier code

2:58 tomoj: ,(doc subs)

2:58 clojurebot: "([s start] [s start end]); Returns the substring of s beginning at start inclusive, and ending at end (defaults to length of string), exclusive."

2:58 tomoj: perhaps?

2:58 defn: ,(apply str (take 2 "asdf"))

2:58 clojurebot: "as"

2:58 bozhidar: tomoj: you're right, many time i've wished that this particular method simply returned null on bad output(although this is rarely a good idea) :-)

2:59 tomoj: hmm, why does subs exist?

2:59 bozhidar: s/output/input/

2:59 tomoj: java.lang.String/substring is perfectly good, after all :P

2:59 defn: ,(subs "asdf" 0 1)

2:59 clojurebot: "a"

2:59 defn: ,(subs "asdf" 0 2)

2:59 clojurebot: "as"

2:59 tomoj: er, hmm.. I wonder what the java convention for denoting instance methods is

3:00 cheezey: umm... so which would be better to use :o

3:01 or i could just use java's string methods

3:01 bozhidar: tomoj: denoting in which sense?

3:03 defn: cheezey: i suggest using clojure, but it is up to you

3:03 tomoj: bozhidar: I mean, if I want to refer to the substring method in java.lang.String, what do I write?

3:04 java.lang.String/substring looks like a clojurian talking about a class method

3:13 cemerick: ,(.substring "asdf" 0 2)

3:13 clojurebot: "as"

3:24 defn: i prefer clojurist! :)

4:01 is there any way to use old clojure.contrib and new clojure.contrib (1.2) stuff together?

4:17 _ato: xgnu

4:37 defn: _ato: ?

4:43 _mst: a missed alt key in an attempt to start gnus? :)

4:49 _ato: yep

4:50 I really need to bind that

5:00 _mst: funny how you can recognise the typos you make yourself...

5:38 LauJensen: ~seen etate

5:38 clojurebot: etate was last seen quiting IRC, 28918 minutes ago

6:31 Borkdude: Can I evaluate in a clj file in emacs slime mode and have the result inserted in my file directly ?

6:38 tcrayford: yes

6:38 I have something like that setup somewhere in my emacs

6:39 the function you're looking for is 'slime-eval-print-last-expression

6:42 Borkdude: ah tnx

6:42 it's not bound to a key by default I guess?

6:45 anyway, this is what I searched for, tnx a lot!

6:46 tcrayford: yeah its not bound to anything by default

6:46 you can learn a lot about slime just by doing apropos "slime"

6:48 does anybody know the syntax for using :only inside of ns declarations

6:48 ?

6:49 Borkdude: Why is eval defun called eval defun? A top level element is not nec. a defun?

6:50 tcrayford: hold over from common lisp

6:50 I think

6:50 Borkdude: in common lisp top level elts are neither always defuns

6:50 * tcrayford has nearly gotten who-calls support into swank

6:50 tcrayford: from the guys who originally wrote slime anyway

6:53 tomoj: tcrayford: (:use [foo.bar :only (baz)]) should work

6:53 LauJensen: chouser: I really liked your last blogpost, but I found a redundant comment which you might as well remove "It's not obivous from the error message, [whats going on]"

6:53 tcrayford: tomoj: I had to give that up because the thing I want to import is private

6:53 tomoj: ah

6:53 tcrayford: :(

7:49 nur: Good morning.

7:50 AWizzArd: Good afternoon nur.

8:02 cYmen: Somewhere in labrepl the missed telling me what the % in (filter #(.contains % "root") words) does.

8:04 tomoj: cYmen: are you asking, or just noting the flaw?

8:06 cYmen: tomoj: both :)

8:07 tcrayford: it is an argument to the anonymous function made by #()

8:07 you can write that fn as (fn [thing] (.contains thing "root"))

8:07 tomoj: #(foo %) and #(foo %1) are abbreviations for (fn [x] (foo x))

8:08 (though those are both silly...)

8:09 tcrayford: man I wish emacs' stringp would tell me what I passed to it that throws an error

8:10 tomoj: "wrong argument type stringp" or something?

8:10 tcrayford: yeah

8:11 I can't see why its wanting a string for this, when I'm obviously sending it data (that should be a list)

8:11 * tcrayford runs off to look at slime's source code

8:12 tomoj: ode

8:12 oops

8:16 defn: tcrayford: thanks for the slime-eval-print-last-expression -- ive been meaning to make something like that myself

8:16 tcrayford: how about a function which lets you take the most recent sexp evaluated in the repl and insert at your point in an open file?

8:17 cYmen: What's the clojure equivalent of a python dictionary?

8:18 tcrayford: Cymen: a map

8:18 defn: there isn't anything like that in slime

8:18 defn: although I've been meaning to make one

8:19 defn: ,(:a {:a 1 :b 2})

8:19 clojurebot: 1

8:19 defn: ,({:a 1 :b 2} :a)

8:19 clojurebot: 1

8:19 cYmen: defn: Can I make one that has a default value?

8:20 ,(set {} a 3)

8:20 clojurebot: java.lang.Exception: Unable to resolve symbol: a in this context

8:20 cYmen: ,(set {} \a 3)

8:20 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$set

8:20 cYmen: I should be trying crap like that somewhere else. :P

8:20 defn: cYmen: im firing up my repl for that reason :)

8:20 tcrayford: if you use emacs, you can have a repl in IRC that nobody else can see

8:20 wop

8:21 cYmen: I'm trying to do that "write your own 'frequencies' function using reduce" exercise from labrepl...

8:21 tcrayford: you want assoc

8:21 ,(assoc {} :a 1)

8:21 clojurebot: {:a 1}

8:21 tcrayford: note that that returns a new map, and doesn't modify the old one (immutable data, harf)

8:21 defn: cYmen: you definitely want assoc, but you can do:

8:22 ,(into {:a 1} {:b 2})

8:22 clojurebot: {:a 1, :b 2}

8:22 defn: just a for example, not necessarily specific to your problem...

8:26 ,(let [{a 1, b 2} (take 4 (iterate inc 1))] [a b])

8:26 clojurebot: [nil nil]

8:27 defn: weird -- i got [2, nil] somehow -- maybe my version of clojure?

8:46 tomoj: r

8:46 dammit, I need to turn off click-to-focus

8:49 defn: is there any way to do (doc ~) and be referred to documentation for it?

8:54 cYmen: What's your preferred paste tool?

8:54 bozhidar: cYmen: gist & lisppaste

8:55 I prefer lisppaste for irc channel having the lisppaste bot

8:55 otherwise gist

8:55 both have great Emacs integration which is very important

8:55 at least to me...

8:56 cYmen: I'm trying not to use emacs.

8:58 This is what I tried for writing my own frequencies function:

8:58 http://gist.github.com/370211

8:58 Something is wrong with the let but I don't see it...

9:03 mfex: the let form should be with brackets: (let [a 1 b 2] (+ a b))

9:03 cYmen: oh

9:03 heh

9:04 neotyk: Hi *

9:04 mfex: and you could combine the let and if form with if-let

9:05 mikem: I have a map with integer keys. I'd like to find the first integer, starting from 1, which is not already in the map. what's the best way to do this?

9:05 I have this: (first (filter #(not (contains? v %)) (take java.lang.Integer/MAX_VALUE (iterate inc 1)))) -- where v is the map with integer keys

9:05 is there something simpler, perhaps?

9:06 cYmen: mfex: never heard of if-let

9:06 Any other advice on that code? Feels a bit clumsy...

9:06 neotyk: where I can read what is difference between ':' and '::' ?

9:08 defn: cYmen: name it with a .clj :)

9:10 cYmen: defn: hrhr

9:10 defn: Didn't even notice. Just wanted gist to be able to do the highlighting.

9:10 defn: mikem: what do you mean by map with integer keys? like {1 2, 3 4}? or do you mean [1 2 3 4 5]?

9:11 mfex: cYmen, (defn addi [tehmap val] (assoc tehmap val (+ (tehmap val 0) 1)))

9:11 mikem: defn: like {1 2, 3 4}

9:11 mfex: cYmen, but that's perhaps a bit less readable

9:12 mikem: defn: or more likely for my use case: {4 "something", 29 "something else", 33 "one more"}

9:13 tomoj: mikem: why are you taking MAX_VALUE??

9:14 defn: yeah im kind of trying to figure out that as well :)

9:14 tcrayford: ,(inc (last (sort (keys {1 2, 3 4}))))

9:14 clojurebot: 4

9:14 mikem: tomoj: if I don't take anything, then (iterate inc 1) could go on forever

9:14 tcrayford: mikem: see that

9:14 tomoj: mikem: ok, but you're willing to sit there and wait while it goes through every single positive integer?

9:15 mikem: tcrayford: the keys may not necessarily be in increasing order, there may be gaps. otherwise I'd use (max (keys {1 2, 3 4}))

9:15 tomoj: anyway, it won't go on forever unless your map has an infinite number of keys, right?

9:15 tcrayford: yeah, just figured that out

9:15 mikem: tomoj: exactly, if all the keys are taken I probably have other issues ;)

9:16 tcrayford: ~seen technomancy

9:16 clojurebot: technomancy was last seen in #clojure, 506 minutes ago saying: never heard of anyone actually trying to use streams =)

9:17 tomoj: ,(first (remove {1 2, 3 4} (iterate inc 1)))

9:17 clojurebot: 2

9:17 tomoj: can your map have nil or false values?

9:18 mikem: no, the map will only have integer keys starting with 1

9:18 tomoj: but what about values

9:18 mikem: values will be vectors, so it's unlikely to be false or nil

9:18 if it is, it's a bug

9:18 tcrayford: ,(first (filter #(not (contains? {1 :a, 2 :b} %)) (iterate inc 1)))

9:18 clojurebot: 3

9:18 tomoj: then the above should work

9:19 mikem: tcrayford: that's what I have, except I (take java.lang.Integer/MAX_VALUE (iterate inc 1)) so I don't run on forever... :)

9:19 * mikem reads up on remove

9:19 tcrayford: mikem: thing is, you won't ever run on forever

9:20 mikem: I also don't want anything that's a BigInteger

9:20 tomoj: that would only happen, again, if your map has every single Integer stuffed in it

9:20 tcrayford: yep

9:20 which is probably unlikely

9:21 LaPingvino: ,(take java.lang.Integer/MAX_VALUE (iterate inc 1))

9:21 clojurebot: Execution Timed Out

9:22 mikem: cool, the remove method would work

9:22 tomoj, tcrayford: thanks

9:23 tcrayford: does anybody know their way around a common lisp implementation of swank?

9:23 tomoj: I think you'd only need 8GB of RAM to store every positive Integer assuming no overhead

9:25 defn: tcrayford: is there a minor mode now for clojure-refactoring?

9:25 tcrayford: not yet

9:25 LaPingvino: ,1

9:25 clojurebot: 1

9:25 tcrayford: I've been working on getting proper renaming going

9:25 via slimes xref feature

9:25 defn: tcrayford: i looked into it tcrayford but i just don't know about my way around elisp well enough to do much with it

9:25 tcrayford: yeah

9:25 me neither

9:26 defn: ill keep poking at it but dont count on me :)

9:26 tcrayford: most of the stuff in refactoring-mode comes from test-mode

9:26 by the looks of things though, proper renaming support should come in sometime this week

9:27 defn: tcrayford: this is a question you might know the answer to... is there any existing code out there for indenting clojure code presented in a single long line, and placing appropriate newlines etc.?

9:27 * tcrayford loves how clojure stores file/line number references as metadata on every var

9:27 tcrayford: defn: no

9:27 I've been meaning to write one, its not that hard

9:27 tomoj: how could you possibly guess where to put newlines?

9:27 defn: lol

9:27 tomoj: it's a delicate art

9:27 tcrayford: yep

9:27 defn: gotta treat the #() right

9:28 tcrayford: I'd do a naive one with newlines after vectors that are binding vectors (refactoring-mode can already work that out for me)

9:28 oh

9:28 better idea

9:28 bayesian inference across the whole clojure codebase

9:29 defn: tcrayford: that's a great idea actually

9:29 tomoj: is that different than a markov chain

9:29 tcrayford: somewhat, yeah

9:29 but similar principle (I think)

9:30 defn: however, the style would be a bit biased

9:30 it'd be cooler to run it on open source projects :)

9:31 tcrayford: I'd probably run it across contrib rather than clojure itself

9:31 I think

9:32 tomoj: not at a character level, right?

9:32 tcrayford: at a sexp level

9:33 code is data, remember

9:33 tomoj: but do you include extra info like "this is a binding vector" somehow?

9:33 tcrayford: I think so

9:33 refactoring-mode can work that out itself

9:33 roughly anyway

9:34 it won't work for new macros that take binding forms that people have defined

9:35 tomoj: the data seem too sparse to me

9:35 tcrayford: oh awesome

9:35 cross referencing works now in slime/swank

9:35 clojurebot: http://haacked.com/images/haacked_com/WindowsLiveWriter/IConfigMapPathIsInaccessibleDueToItsProt_1446B/works-on-my-machine-starburst.png

9:35 tcrayford: so you can hover over a function name

9:36 M-x who-calls and get a list of all the functions that call your function

9:36 tomoj: awesome!

9:36 defn: tcrayford: that's fantastic

9:37 tcrayford: it'll be a big boost to refactoring

9:37 since you can then rename a function properly

9:38 and have the rename work across files

9:39 I'm not happy with one function in it though

9:39 (defn- recursive-contains? [coll obj]

9:39 "True if coll contains obj at some level of nesting"

9:39 (some #(= % true)

9:39 (flatten

9:39 (postwalk

9:39 (fn [node]

9:39 (if (= node obj) true node))

9:39 coll))))

9:39 that one

9:39 it checks if a tree contains obj somewhere

9:39 and I don't think it is anywhere near as clean as it could be

9:42 (it needs clojure.walk and contrib.seq-utils)

9:43 defn: i feel dirty when i use flatten most of the time

9:43 it feels like im patching a mistake i dont know i made

9:44 is that neurotic?

9:45 * tcrayford shrugs

9:45 tcrayford: I feel about the same

9:45 that fn really bugs me as well

9:46 refactoring-mode uses it all over the place, but I can't see how to make it better

9:47 defn: geez i dont know... hmm

9:48 tcrayford: you could roll your own postwalk

9:48 instead of replacing the original do something else

9:48 tcrayford: that's what I used to have

9:49 it was uglier than using postwalk

9:49 defn: yeah youre probably right

9:50 tcrayford: grrr

9:50 defn: tcrayford: why postwalk instead of walk?

9:51 tcrayford: I think walk confuses me a bit

9:51 defn: oh nvm, i think im confused

9:52 postwalk certainly /sounds/ like what you want

9:58 tcrayford: grr namespacing is confusing

10:00 swank seems to be failing to find a namespace I KNOW is there

10:01 [null] #<CompilerException java.lang.ClassNotFoundException: swank.commands.xref (basic.clj:411)>


10:01 is the error I get

10:02 aha fixed

10:03 tomoj: tcrayford: what's (some #(= true %) ...) for?

10:03 tcrayford: currently, it replaces all the values in the tree that match obj with true

10:03 and leaves the others the same

10:03 tomoj: ah

10:04 tcrayford: there's a bug there that you just made me think of

10:04 arbscht: literal true

10:04 tcrayford: if 'true' is already in the tree

10:04 then recursive-contains will always return true

10:04 tomoj: is something wrong with the naive way?

10:04 i.e. recursion

10:04 tcrayford: what's the naive way?

10:04 it was more code :/

10:05 arbscht: why not just flatten and filter?

10:05 tcrayford: that should actually work fine for this use case

10:06 seeing as I'm only looking for symbols

10:06 original use case has to find seqs as well

10:06 tomoj: ooh, I see

10:07 tcrayford: cheers for that flatten/filter thing though

10:07 that's better for swank, but not for refactoring mode

10:10 defn: tcrayford: when you mentioned bayesian inference were you thinking for "outcome" values? like the number of []s found, nested and un-nested? the number of ()s found, nested and un-nested?

10:11 as input i mean...

10:11 tcrayford: something like that

10:11 I haven't actually thought about it beyond thinking that bayesian inference would make sense for this

10:13 damn

10:13 now I've broken something in swank :(

10:13 defn: tcrayford: is it something youd put into refactoring?

10:13 tcrayford: the pretty code printing?

10:13 that's probably a separate lib, that refactoring relies on

10:13 defn: yeah, is that at all interesting to you?

10:13 tcrayford: yeah its interesting

10:13 I'm unsatisfied with refactorings way of printing code atm

10:14 defn: i think i might try to do something with it

10:15 tcrayford: go for it

10:15 defn: id like something like it to take something like: (defn x [k, z, p] (+ k z p (map #(+ 3 %) [1 2 3 4]))) <-literally

10:15 and turn it into (defn x [k, z, p]\n (+ k z p...

10:15 is that what you had in mind?

10:16 tcrayford: something like that, yeah

10:16 defn: cool

10:17 tcrayford: pretty much just pretty printing of code

10:17 contrib already has a pretty code printer that I use in refactoring

10:17 but it ain't great

10:17 just newlines after binding forms would be fantastic

10:18 defn: does it do indentation and all of that? i toyed with pprint and didn't see it do any newlines. hm -- what function is that in pprint?

10:19 tcrayford: (with-pprint-dispatch *code-dispatch*

10:19 (pprint node))

10:19 is the call I use in refactoring-mode

10:19 it does newlines if your expr goes over 80 chars

10:20 cYmen: Does anybody have a working vimclojure with nailgun features?

10:20 I can't get it to work. :/

10:20 tcrayford: what's the problem

10:21 ?

10:22 cYmen: When I start vim I get an error in the messages. I can't make heads or tails of it but it seems to be a classpath problem.

10:22 Would you like me to paste it?

10:22 tcrayford: paste it into a gist or summat if its big

10:22 otherwise, sure

10:22 cYmen: http://paste.pocoo.org/show/203255/

10:23 Sorry about the formatting, that's the way I get it.

10:23 tcrayford: its fine

10:23 do you have a (ns test) thing at the top of the file?

10:23 from the looks of it vimclojure might need/want that

10:24 cYmen: oh

10:25 tcrayford: pull request sent

10:25 wop

10:26 cYmen: tcrayford: doesn't seem to make a difference if I add that

10:27 tcrayford: interesting

10:27 same error still?

10:27 cYmen: I can't see a difference.

10:28 new: http://paste.pocoo.org/show/203257/

10:28 tcrayford: you saved the file?

10:28 cYmen: I only added (ns test) at the top.

10:28 Yes.

10:28 tcrayford: and no syntax errors?

10:29 (paste the file into your pastebin as well?)

10:29 cYmen: the file says (ns test) and (+ 1 2 3) :)

10:30 I don't even know how to send it yet. It seems the keybindings don't work because it fails with that error.

10:32 tcrayford: aye

10:32 :(

10:32 I don't really have anything more to suggest

10:33 cYmen: I'll email the author.

10:38 nurv: Evening.

11:09 Jevgeni: Hi, I have desided to try clojure in emacs and I have a problem installing swank-clojure with ELPA. I have installed the ELPA (it modified my init.el), then I used package-list-packages and installed swank-clojure. I had few warnings the buffer and "hack-local-variables: Local variables entry is missing the suffix" in the mini-buffer. After that I still don't have alt+x slime available.. Any...

11:09 ...hints or directions?

11:11 rfg: Did you install slime and slime-repl as well?

11:11 Jevgeni: no, do I use the same procedure for these packages?

11:11 rfg: Yes, you'll want clojure-mode too.

11:12 Jevgeni: it's strange, ELPA shows me that slime is installed

11:12 slime-repl not

11:12 can it be that one package installs others as well?

11:12 clojure-more is said to be installed as well

11:14 rfg: Is swank-clojure definitely installed?

11:15 Jevgeni: elpa shows that is not. strange

11:16 rfg: Jevgeni: I had the same problem.

11:16 Try again and it should work.

11:18 Jevgeni: rfg: okay, thanks. I had to install it three time (& restart emacs), now it offered me to install clojure..

11:18 rfg: Cool

11:18 Jevgeni: strange :) but cool

11:19 oh. I don't have slime anymore available after restart :S

11:19 do I have to require it manually somehow?

11:19 rfg: No you shouldn't.

11:21 Could you paste your .emacs somwhere?

11:22 Jevgeni: I have init.el in .emacs.d.

11:22 rfg: http://pastebin.com/LY4VW5qE

11:23 rfg: Can you paste package-list-packages?

11:24 Jevgeni: rfg: http://pastebin.com/Sgzq0wSx

11:25 rfg: Ah, installed packages are greyed out, that doesn't help much. :)

11:25 Oh there is an installed column.

11:26 Jevgeni: there is status "installed">)

11:26 rfg: I would have thought it would just work.

11:27 What does your *Messages* buffer say after loading up emacs?

11:27 Jevgeni: rfg: http://pastebin.com/ZgQYqUa1

11:28 I guess the problem happens during the installation.. maybe autoload generation fails.

11:30 this is what happening during the swank-clojure installation in the messages : http://pastebin.com/HB33kebF and in the compile-log buffer: http://pastebin.com/0wNYrVbT

11:32 rfg: I had a few errors when installing but it should still work.

11:32 Jevgeni: right after the installation m-x slime works, but dissapears after restart

11:36 rfg: Okay M-x slime doesn't work, but can you M-x package-list-packages?

11:36 Jevgeni: yes, I can

11:37 rfg: Have you tried reinstalling multiple times?

11:37 Jevgeni: yes

11:38 each time I install - m-x slime starts working, but after restart it is no longer available

11:42 package-activated-list = (swank-clojure clojure-mode slime-repl slime emacs package erc url nxml bubbles)

11:47 rfg: I'll have a go at installing it on Windows.

11:49 Jevgeni: (package-activate 'slime '(20091016)) --> t

11:49 but no m-x slime

12:03 rfg: Jevgeni: Right, on windows I'm having the same problem as you.

12:04 Jevgeni: rfg: do you have any hints how to solve it? Or I should use manual installation instead? (I have slime+sbcl installed previously)

12:04 had*

12:06 rfg: I don't know how to fix this problem. Have you tried Clojure Box?

12:08 kzar: If you create a server with create-server in contrib how do you stop the server?

12:09 Jevgeni: rfg: clojurebox worked, probably I have to see what's done there..

12:15 kzar: OK for some reason (find-doc "server") didn't find it but the answer was just (close-server servername)

13:02 Sgeo_: Bye all! Homework now

13:04 Jevgeni: rfg: just for information, it was an ELPA bug in windows. had to patch package.el to fix it (http://groups.google.com/group/clojure/browse_thread/thread/c4d00ba0f1614c49)

14:15 I've installed leiningen on vista. lein swank gives an exception - No matching field found: getCommandLine for class org.apache.tools.ant.taskdefs.Java . Have googled for it, but no luck. Any hints?

14:19 ah, updated lib to [leiningen/lein-swank "1.2.0-SNAPSHOT"] to solve it...

14:27 cYmen: hm...so meikel hasn't responded so far..anybody here who's got a running vimclojure with nailgun and might be able to answer some questions?

15:14 Luyt: ,(doc doc)

15:14 clojurebot: "([name]); Prints documentation for a var or special form given its name"

15:55 OForero: anyone using IntelliJ EAP with clojure?

15:56 sattvik: cYmen: What's your problem?

15:57 OForero: I do not find the La Clojure plugin in the latest EAP version

15:58 is not the plugin to use any more?

16:08 Jevgeni: does clojure mode support highlighting errors/warning in the code as lisp mode does? Is it some hidden setting I have to tweak?

16:12 dnolen: Jevgeni: you won't see errors or warnings as you type, only when you compile, and that's a feature of swank-clojure not clojure-mode

16:12 Jevgeni: dnolen: okay, does swank-clojure enables it?

16:13 dnolen: Jevgeni: it should yes. You may need to build lein-swank from source.

16:13 I'm not sure if the one on Clojars has those changes yet.

16:14 pretty easy to do tho, clone the leiningen repo, cd into lein-swank, lein install

16:14 Jevgeni: I use the swank directly, from the m-x slime right now. do I have to use lein-swank for this?

16:16 tcrayford: you want m-x swank-clojure-project for that if you're dir is using lein

16:16 and you need swank-clojure in your lib directory

16:17 Jevgeni: okay, I see. I'll try this, thanks

16:18 tcrayford: though if you get to that point, you might as well use lein-swank

16:20 Jevgeni: yes, I do have installed it. I will try that as well

16:57 what about the debugger in the emacs - do you know - are there plans to hide the JVM frames and to show clojure code first in the buffer?

16:57 or, is it possible already somehow?

16:58 tcrayford: I don't think its possible atm

17:01 hiredman: look at clojure.stacktrace

17:02 tcrayford: I wish clojure had a proper proper debugger.

17:02 atm I mostly copy out the function that I'm debugging and replace bound values with actual ones, then evaluate it

17:03 dnolen: swank-clojure master has (swank/break) which is pretty useful

17:04 Jevgeni: tcrayford: yes, tracing does not show the [let] values either

17:04 dnolen: (swank/break) lets you move from breakpoint break, run code on that frame and inspect locals

17:04 breakpoint to breakpoint i mean

17:10 tcrayford: dnolen: is there a decent article on that anywhere?

17:11 dnolen: tcrayford: http://hugoduncan.org/post/2010/swank_clojure_gets_a_break_with_the_local_environment.xhtml

17:13 Jevgeni: dnolen: it's said there that JDPA integration is been tackled.. is it?

17:14 dnolen: i don't know of anyone that's working on that yet.

17:19 cYmen: sattvik: let me pastebin that for you. I can start everything but I get errors when vim tries to use nailgun

17:23 hrmpf now I can't start the nailgun server anymore

17:23 go burn in hell classpath!

17:25 sattvik: here you go http://paste.pocoo.org/show/203408/

17:29 sattvik: cYmen: Which version of VimClojure are you using?

17:30 cYmen: this is from 2.1.2

17:30 I tried getting the mercurial version but it doesn't come with the nailgun server only a dead clojars link...

17:31 sattvik: cYmen: What version of Clojure are you using?

17:32 cYmen: sattvik: 1.1.0

17:33 sattvik: cYmen: Well, your versions shoule work together fine. Judging from the error message, the vimclojure.jar or one of its dependencies is not in the server's classpath.

17:34 cYmen: The server should have Clojure 1.1, Clojure-contrib 1.1, VimClojure, all of the class/source directories for your project in its classpath.

17:36 cYmen: sattvik: http://paste.pocoo.org/show/203413/

17:37 I simply start nailgun using: java com.martiansoftware.nailgun.NGServer

17:43 sattvik: cYmen: Assuming that all of the paths in your classpath are correct, it should work… How about trying the classpath as command line argument: java -cp /Users…:/Users… com.martiansoftware.nailgun.NGServer

17:43 cYmen: sattvik: tried that

17:50 sattvik: cYmen: I'm experimenting a bit…

17:55 cYmen: I don't have a clue. I'm afraid my java experience isn't enough to figure out the error message.

17:58 harblcat: hi all

17:59 I'm looking to replace a (cond ...) with something a little more concise, and thought that a map like string -> function would work, but I've hit a snag.

18:00 hiredman: use a multimethod

18:01 cYmen: harblcat: depends on the cond I guess but it's pretty concise in most cases

18:02 harblcat: well, see, I was doing a commandline thing, and the cond is where I was switching out for different actions, but I wanted to be able to add other actions at whim while the program is running.

18:02 it was something like (cond (= "foo" input) ...)

18:03 I was thinking why not use a hash, so I could say (actions input) instead?

18:03 but I can't get it to work like I think it should.

18:04 hiredman: mutltimethod

18:04 multimethods are great for interpreters

18:04 harblcat: really?

18:04 hiredman: yes

18:05 http://clojure.org/multimethods

18:06 a lot of that is more complex than you will most likely need

18:07 sattvik: cYmen: What happens when you: echo "doc" | ng de.kotka.vimclojure.nails.DocLookup

18:07 harblcat: well, I'd like to know more about this map full of functions. I know that (actions input) returns a function, but if I try to wrap it so that the function is evaluated I get a NullPointerException

18:07 hiredman: you mean called?

18:08 harblcat: ah, nevermind on that, I figured out why.

18:08 I can't do (nil)

18:08 which is what (actions input) returns if input isn't in the map

18:08 hiredman: functions evaluate to themselves

18:08 harblcat: nil isn't callable

18:08 hiredman: to run a function you apply it

18:09 you can evaluate the application of a function

18:09 harblcat: well, I'm trying to catch invalid commands using an (or ...), so I can get either a good command, or an error like "Command not found: foo"

18:09 cYmen: sattvik: java.lang.ExceptionInInitializerError [...]

18:10 Would you like to see the details? Do I need to set anything? CLASSPATH? CLOJURE_EXT?

18:11 harblcat: on a different note, how do I change an atom to another thing?

18:11 sattvik: harblcat: You can add a third argument to your (action input) to return a default function.

18:12 hiredman: ~blip.tv

18:12 clojurebot: blip.tv is http://clojure.blip.tv/

18:12 harblcat: so (actions input #(str "foo: " %)) ?

18:12 I'll have to try that.

18:12 sattvik: cYmen: Hmm... That stack trace would be goo, to start.

18:13 cYmen: hm..somehow lisppaste is broken

18:14 sattvik: http://gist.github.com/370587

18:15 dnolen: harblcat: multimethod + a macro so you can write something like (add-action "some-str" some-fn) is the idiomatic approach. and then you don't have to mess with atoms, you can also provide a default function.

18:16 harblcat: multimethod's are there for a reason. putting fns in maps is not encouraged.

18:16 harblcat: ah

18:18 cYmen: sattvik: I managed to fix that stacktrace by recompiling clojure-contrib while specifying where clojure is.

18:19 echo "doc" | ng de.kotka.vimclojure.nails.DocLookup works now

18:19 sattvik: cYmen: OK, so you can try doing something from Vim then.

18:20 cYmen: sattvik: That still doesn't work...

18:20 sattvik: cYmen Hmmm.. same error, or something different?

18:22 cYmen: nope same error

18:24 sattvik: cYmen: Are you sure that the files in your ~/.vim directory are for VimClojure 2.1.2? I just noticed your error is looking for vimclojure.Nail, which is from the current hg head.

18:27 cYmen: sattvik: oh..that's odd maybe it didn't overwrite something I had the hg version installed before

18:28 let me manually delete stuff

18:31 wehee

18:31 sattvik: the error is gone

18:31 now I only have to figure out how to actually get a repl :)

18:33 DONE.

18:33 sattvik: Thank you, I would never have figured this out on my own!

18:33 sattvik: Are you using hg head?

18:35 sattvik: cYmen: Your welcome. I have used both the released and development versions.

18:35 cYmen: sattvik: I have to go now but if you're around tomorrow I would love to hear about building the dev version.

18:37 sattvik: cYmen: OK. I am usually around, just ping me here. I might not respond immediately, as I am often in some other window doing something.

18:38 cYmen: Great, thanks again and good night. :)

19:54 jweiss: can anyone suggest a way to expose some clojure functions I've written (say, in a namespace) via xmlrpc (or some other language agnostic protocol)? I figure I could use a java xmlrpc lib and dispatch the calls with a multimethod... there's probably an easy way to map a string xmlrpc method name to a clojure fn (assuming they have the same name)- or is there a more idiomatic or easy way?

19:56 hiredman: if you trust your channel you can just use eval

19:57 (doseq [msg (repeatedly get-message)] (eval msg))

20:29 chessguy: does clojure have an equivalent to lisp's "atom?" predicat?

20:29 jweiss: anyone know if there are plans to address common errors such as "java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn (NO_SOURCE_FILE:0)" with a clojure oriented message rather than java's message, perhaps by wrapping the exception with "attempted function call on a java.lang.Integer" . there's probably lots of places this could be done

20:30 or is there some rationale for exposing java guts to clojure programs?

20:31 dnolen: chessguy: (complement coll?) is probably the closest thing

20:31 jweiss: seems like clojure users should not need to know what an IFn is.

20:31 chessguy: dnolen, would coll? be true for a regular list?

20:31 as in, '(a b c)

20:32 dnolen: jweiss: I imagine that story will improve much more quickly when the compiler is written in Clojure instead of Java.

20:32 ,(coll? '(a b c))

20:32 clojurebot: true

20:32 chessguy: that answers that. thanks

20:32 dnolen: ,(coll? 'a)

20:32 clojurebot: false

20:32 chessguy: ,(coll? true)

20:32 clojurebot: false

20:33 jweiss: dnolen: ah so there are plans to address it although indirectly :) didn't know there was going to be a clojure ->clojure compiler

20:33 chessguy: ,(coll? 'coll?)

20:33 clojurebot: false

20:34 chouser: I don't know that much effort will be put into manual handling of various error messages anytime soon.

20:35 and IFn is a specific and important abstraction. Fits with then 'ifn?' predicate.

20:36 hiredman: right, I mean, do we really want to instrument every single possible fn call?

20:37 jweiss: chouser: important beyond java integration?

20:37 i suppose there's a balance that needs to be struck between tight java integration and standalone clojure

20:38 dnolen: jweiss: IFn is an interface. Clojure is built on interfaces, they just happen to implemented in Java at the moment, they might be implemented in Clojure later.

20:38 hiredman: there is no standalone clojure

20:38 clojure "embraces a platform"

20:39 jweiss: isn't there a clr implementation?

20:39 hiredman: it's clojureclr, not clojure

20:39 jweiss: i see

20:39 dnolen: jweiss: but I agree the error messages suck. it's a good thing Clojure is simple and encourages FP or it would be unbearable.

20:40 jweiss: it's not that big a deal, just off-putting to newcomers (which for a new language, is most people)

20:40 chouser: jweiss: yeah, IFn is Clojure's "callable" interface. If an object implements IFn, you can call it like a function.

20:40 dnolen: jweiss: totally. it's a good thing Clojure is so cool.

20:41 chouser: I do think it would be nice for the error messages to be simpler, clearer, more direct. But I see now that the language is changing at a rate that would make most effort in that direction rapidly obsolete.

20:41 jweiss: chouser: i have no problem with the existence of IFn, it's just not at all obvious what you've done wrong when you accidentally put an integer value where an IFn shoud be

20:42 dnolen: for what it's worth, Clojure error messages or no less painful then GCC error message in my opinion. What Clojure needs is really good debugging support in all the main IDEs.

20:42 jweiss: chouser: understood

20:42 glogic: chouser: same as it ever was

20:42 chouser: presumably the language's rate of change will slow down eventually, and then it'd be great to see some tidier error messages.

20:42 hiredman: but to do what you want would mean extra code generated for every call site

20:42 chouser: hiredman: just to fix the error messages?

20:42 jweiss: hiredman: how do you figure?

20:43 hiredman: chouser: right

20:43 jweiss: seems like you could just edit that 1 line in the java implementation

20:43 chouser: I've thought about some kind of top-level error handler that maps common but complex exceptions to "easy to understand" messages.

20:43 jweiss: or can that same error be thrown from lots of different places?

20:43 hiredman: ,(let [a 1] (a 1))

20:43 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn

20:44 chouser: it could catch the error, examine the stack trace, and print something pleasant. ...or even just link to a page of example errors and likely fixes.

20:44 hiredman: ,(let [a (+ 1 2)] (a 1))

20:44 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn

20:44 chouser: the benefit of that kind of solution would be that it could be done entirely outside of clojure core -- no need to get in rhickey's way

20:44 nurv: Good night.

20:44 hiredman: every possible call is potentially that exception

20:44 chouser: the downside is it would take constant effort to keep it even slightly useful. -/

20:44 :-/

20:45 hiredman: so to really deal with it you have to add code to call sites

20:45 chouser: the excpetion hanlder could be at the top of the repl call stack -- no need to muck with call sites.

20:45 hiredman: :(

20:45 dnolen: "java.lang.Integer 3 cannot be invoked as a function" would be more illuminating.

20:46 jweiss: dnolen: yeah that's what i would have thought would be wrapped around the CCE

20:46 hiredman: ,(let [a (rand-int 10)] (a 1))

20:46 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn

20:46 jweiss: hiredman: how many different call sites are there?

20:46 hiredman: jweiss: every function call is a call site

20:47 jweiss: hiredman: but, i would've thought that's handled by a single piece of java code

20:47 hiredman: clojure generates bytecode for invokevirtual clojure.lang.IFn etc etc

20:47 chouser: I still don't see what's wrong with a top-level exception handler "fixing up" the error message.

20:47 hiredman: jweiss: there is some common stuff in AFn but not all IFns are AFns

20:47 jweiss: hiredman: i see

20:47 dnolen: chouser: inc

20:47 hiredman: chouser: like clojure.stacktrace

20:48 * hiredman keeps pointing people at clojure.stacktrace

20:48 jweiss: hah, is that new?

20:48 hiredman: no

20:48 jweiss: i've been doing (.printStackTrace *e)

20:49 like my book says to do

20:49 glogic: ok you'rea ll officiall freaking me out now

20:49 chouser: glogic: ?

20:49 jweiss: ok, by "new" i mean, in the last 3-6 months?

20:49 that's not new in clojure world, i suppose :)

20:50 hiredman: Date: Wed Jun 24 00:46:54 2009 -0400

20:50 jweiss: how bout that

20:50 hiredman: moved from contrib to clojure almost a year ago

20:53 jweiss: that's good to know about but still doesn't help newbs understand this

20:53 ,(1)

20:53 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn

20:53 hiredman: *shrug*

20:53 makes sense to me (works on my machine)

20:53 jweiss: yeah i know, the reason i mention it is a coworker is trying out clojure (he's a java and python guy), he didn't know what that meant

20:53 dnolen: clojure.stacktrace is used by all the main environments. it's not that helpful.

20:53 hiredman: uh

20:54 dnolen: is it? I am not aware of any that use it

20:54 jweiss: how can a java guy not get that?

20:54 dnolen: swank-clojure uses it as far as I can tell

20:54 so does counterclockwise and I think enclojure

20:54 jweiss: hiredman: i dunno, i guess either you get the I in IFn is for interface, and Fn is for function, or you don't. kinda hit or miss with just 3 letters.

20:55 hiredman: Fn is for fn

20:55 fn, defn, fn?, ifn?, bound-fn, etc

20:56 jweiss: i know, i know, you can only cater to noobs so much

20:56 but i thought it might have been an easy fix, apparently not

20:56 * jweiss is is noob relative to a lot of people here, but not the people i'm trying to help

20:58 jweiss: by the way, anyone here use the clutch couchdb lib?

20:59 dnolen: jweiss: rhickey rarely makes mistakes so he doesn't need the error messaging to improve ;) but he might be open to a patch.

20:59 jweiss: I have a little

21:00 jweiss: dnolen: my view server keeps exiting after about 3 seconds with a JSON error. i'm pretty sure this used to work, so i'm wondering if maybe there's some version incompatibility

21:00 3 seconds after i start couchdb i mean

21:00 dnolen: I never went so far as to use clojure as the view server.

21:01 jweiss: dnolen: yeah, i may reconsider that design decision in my app

21:01 dnolen: views tend to be so simple I didn't see much of advantage of using a different lang than JS.

21:01 jweiss: dnolen: good point

21:02 chouser: hiredman: yeah, like clojure.stacktrace, except (e) sometimes obscures important details, and doesn't point to more helpful messages.

21:02 glogic: dnolen: what if i make tons of mistakes though

21:02 * glogic makes mistakes

21:02 jweiss: although, i thought i might at some point create views dynamically, and so it was tempting to use clojure

21:03 but i really don't know if i'll need to do that

21:03 hiredman: chouser: sure, I don't use it myself, I just point people who don't like reading stack traces to it

21:04 chouser: ah

21:04 dnolen: jweiss: you have to wait for the view the build so I don't see the advantage of them being dynamic.

21:05 jweiss: dnolen: well, my app is a defect tracker (among other things), lets say a user creates a new project, it might need its own views

21:05 maybe not though

21:06 dnolen: jweiss: ah yeah, that would be convenient. if a project has it's database.

21:06 project has it's own db

21:06 jweiss: dnolen: no, it'd all be in one db

21:07 but there might be something different about that project where other views were not sufficient, i don't know yet. i haven't done that design yet

21:08 seems like a user's saved searches might be nice to do as views?

21:08 dnolen: problem with views is that they operate on the entire db, so depending on your app and database size might not be nice.

21:09 filter replication into smaller dbs with their own views is useful in that case

21:09 filter -> filtered

21:09 jweiss: dnolen: good point

21:10 i thought defect tracking, how many records are we talking about here? i've never seen a db with more than 500k records (top level).

21:10 i have no idea how much cpu it would take to create a view on that date

21:11 data

21:11 red hat's has about 500k and that dates back many years. i think ubuntu's is in the several 100k range now

21:12 then again, if the db is small enough it won't matter if i use views or not :)

21:48 falconair: do clojure's sequences include stream based data, in other words, could I map or reduce over jms streams or network streams?

21:52 hiredman: falconair: you can generate a seq on top of a function call

21:53 ,(take 10 (repeatedly #(rand-int 10)))

21:53 clojurebot: (0 6 0 8 4 5 0 4 3 3)

21:53 falconair: hiredman: could you explain a bit please?

21:53 Raynes: $(let [x 1 x x x x x x x x x x x x x x] (println x))

21:53 falconair: do you mean use function as a generator (like range)?

21:53 sexpbot: 1

21:55 hiredman: falconair: no

21:56 I mean you can take a function that each time you calls it returns a Thing and you can very easily turn it into a seq of Things

21:56 see my example with rand-int

21:58 falconair: hm...so there is no concept of "push-based" collections where map/reduce/filter are fed data, rather than them "pulling" on a datastructure with first/rest?

22:00 hiredman: falconair: if you function blocks it will block

22:02 falconair: ok, different question: it looks like many functions for sequences (every?/not-any?/etc.) are not implemented using map/reduce/filter, rather they travese sequences themselves...am I correct? shouldn't every? and not-any? use map?

22:09 dnolen: falconair: can reduce be made to short circuit? (genuine question which I don't know the answer to)

22:09 _ato: falconair: take a look at fill-queue in clojure.contrib.seq-utils, that allows you to create a seq which is pushed onto in another thread, which you could then pass to map/reduce/filter etc

22:11 dnolen: _ato: ah and map/reduce/filter will block while waiting for data?

22:11 falconair: dnolen: don't know, i'm somewhat new to functional programming myself...i didn't know any of clojure's sequence combinators could short circuit (i assume short circuit means not evaluating the whole sequence due to some exception)

22:11 _ato: yep

22:12 dnolen: _ato: nice, I finally understand the point of fill-queue.

22:13 falconair: _ato: do they actually block (as in 'blocking on locks') or is the relationship inverted where map/reduce/filter a pushed their data rather than them pulling?

22:16 _ato: falconair: a blocking queue is created and they block waiting for it to be filled by the other thread. I'm having trouble envisioning how an inverted map/reduce/filter would otherwise work... they're pull things... they take one seq and transform it into another returning the new seq

22:18 falconair: _ato, i am thinking (in part) of F#'s Rx framework, which inverts the relationship between sequences and their combinators

22:19 _ato: falconair: and the reason 'every?' and friends aren't implemented in terms of map/filter may be for efficiency -- to avoid the overhead of creating a temporary lazy sequence

22:20 falconair: _ato: in other words, instead of passing a seq to map, which then takes items off of seq and passes them through a transform function, a push-map would 'subscribe' to a 'producer' and as new data is received, it is passed through the same transform function

22:21 hiredman: what is the different between that and a seq over a blocking queue?

22:21 processing of the seq is blocked and does nothing until something is placed in the queue

22:23 falconair: the problem i see with blocking is scalability, i don't think blocking queues could scales to tens of thousands of connections

22:24 hiredman: why not?

22:26 falconair: if i'm not mistaken, a blocked function is holding up a thread, and each thread takes up certain amount of memory...tens of thousands of such threads would eat up uncessary ram

22:26 hiredman: falconair: if your event handlers are all running on a single thread that is not going to scale either

22:28 _ato: you can only have a few thousand threads before their stacks exhaust memory, but this Rx thing could use a thread pool for sending its events

22:28 falconair: i suppose in a basic implementation they would be on the same thread, but usually new events are dispatched off to an executor

22:29 hiredman: right, and you can do similar processing seqs, see pmap

22:30 my Repl spins up 23 threads that just sit around blocking on seqs on queues :P

22:31 falconair: hiredman: but i am talking about processing network streams as if they were seq, which they (apparently) are not. blocking queue is one way to solve this problem, having a more general definition of seq is another...and I think better

22:32 but i'll admit, this discussion became more academic than practical :)

23:05 ha! regarding my earlier questions about stream type sequences...looks like Rich is already working on them: http://clojure.org/streams

23:07 dnolen: falconair: that's fairly old work (pre 1.0 even?) that's never made it into the mainline. cells might supercede them, but I don't think rhickey is super psyched about where that went either.

23:08 falconair: dnolen: that is disappointing, is this work simply dormant or has it been abandoned?

23:09 dnolen: from what he said at the NY Clojure Meetup, pushing 1.2 out the door is the main thing he's working on at the moment. And the next big thing will probably be allowing fns to return primitives.

23:10 falconair: he wasn't happy with the implementation, I don't remember the details, but they're somewhere in the IRC logs. cells does what streams was supposed to do and more, but I think they provide too leaky of an abstraction for rhickey's tastes.

23:11 falconair: well, i guess i'll have to keep an eye on newer versions then, thx

23:58 MadWombat: I am trying to setup emacs with slime and swank-clojure, I keep getting Debugger entered--Lisp error: (file-error "Cannot open load file" "slime") error

23:58 what am I doing wrong?

Logging service provided by n01se.net