#clojure log - Nov 27 2009

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

1:09 burny: is there an easy way to reduce a list of hash-maps to one hash-map of all elements?

1:10 _mst: ,(apply merge [{:hello 1} {:world 2}])

1:10 clojurebot: {:world 2, :hello 1}

1:11 burny: awesome, thanks

1:18 piccolino: Is there some way that two namespaces can see each other's private defs, but not other namespaces?

1:19 _ato: piccolino: not as far as I know, but you can have one namespace across two files by using load

1:19 piccolino: Hm, that's what I thought. Thanks.

1:33 Is there some way to do like a dynamically scoped variable?

1:34 hiredman:

1:34 seriously?

1:34 http://clojure.org/vars

1:36 piccolino: Yeah, but when I was doing that, I'd get a compile error in another function that referenced it that was not lexically scoped, but would have been in the call stack underneath.

1:40 _ato: ,(binding [not identity] (odd? 3))

1:40 clojurebot: false

1:40 _ato: ,(binding [not identity] (odd? 2))

1:40 clojurebot: true

1:40 _ato: ^ dynamic scoping

1:40 we rebind "not" to be the identity function

1:41 piccolino: Hmn, that is how I would expect that to behave.

1:41 hiredman: well did you read the vars page?

1:41 piccolino: I guess maybe then odd? has to have its own view of not somewhere before it will compile. Is that a declare?

1:41 _ato: yes

1:41 you'll need to declare or def a var before you can use it in binding

1:41 piccolino: Yes I did.

1:42 It's probably really clear to someone who already understands it.

1:44 Thanks _ato

1:45 _ato: piccolino: you got it working?

1:46 piccolino: Yeah, the doc string for binding made me think that you could make it work by using binding without having def'd that variable first.

1:48 What happens if different threads use a var simultaneously without having first used binding to make their own copy?

1:49 hiredman: what do you mean by "use"

1:49 piccolino: Alter it.

1:49 hiredman: set! doesn't work unless the var is bound via binding

1:49 piccolino: I see, thanks.

1:50 _ato: ,(set! not identity)

1:50 clojurebot: java.lang.IllegalStateException: Can't change/establish root binding of: not with set

2:21 Jomyoot: is twitter-clj "THE" twitter library for clojure?

2:25 I would like clojure libary that helps scan twitter public timeline

4:21 ordnungswidrig: hi

4:25 AWizzArd: Moin ordnungs

4:32 ordnungswidrig: anybody online with deeper knowledge on protocols?

4:39 AWizzArd: What would you ask this person if he/she were online?

4:42 ordnungswidrig: I'm implementing this HTTP decision graph on top of compojure: http://thoughtpad.net/alan-dean/http-headers-status.html

4:43 Basically it is a fixed algorithm with a lot if if-else decisions. I model a RESTful resource as a buch of those decision implementation functions. I'm unsure if protocols will help here. At the moment I have a simple map:

4:44 { :generate-etag (fn [req] (-> req :params "articleId")) :exists? (fn [req] (db-exists-key (-> req :params "articleId"))) }

4:48 AWizzArd: protocols will help when you want to do something depending on the type/class of a objet

4:50 ordnungswidrig: there will be about 30 functions to be implemented. I expect that usually about 25 will be default implementations. Can protocols help with behaviour inheritance here? Basically I do a (merge default-implementation-map resource-function-map).

4:52 AWizzArd: Protocols are about methods which dispatch on the type/class of their first argument. If those 25-30 functions will all take at least one argument A1, and do something which depends the type of A1 (but not on the types of A2, A3, ... An) then protocols can help.

4:52 Otherwise if you want to dispatch on the value of one or many args then multimethods would be the right tool.

4:53 In some weeks there might be MultiProtocols which then could also help.

4:54 ordnungswidrig: do you have about 25-30 deftype forms in your code? Or do you use as many jvm classes?

4:54 Jomyoot: What is "the" twitter library for clojure?

4:54 with most complete features?

5:05 ordnungswidrig: AWizzArd: The dispatch on a single value, the "resource"

5:06 AWizzArd: I thought, I'd deftype each resource which each implement the resource protocol.

5:06 AWizzArd: so the number of resource will be the number of deftypes. and the protocol the declare about 30 functions.

5:11 AWizzArd: ordnungswidrig: if you have a deftype for each resource and need to act on those then protocols could be a good way to do this

5:13 ordnungswidrig: AWizzArd: however I see no advantage over maps when the type will be defined specially to represent a resource. Maybe method lookup would be faster

5:17 AWizzArd: ordnungswidrig: Protocols were mainly implemented for giving performance. Those protocol methods can be called with full jvm speed.

5:17 ordnungswidrig: me is confused. where is a test library for clojure? leining uses clojure.test which I cannot find

5:17 AWizzArd: this comes with Clojure

5:17 ordnungswidrig: AWizzArd: but the api docs do not mention it

5:18 AWizzArd: in the past there was a clojure.contrib.test-is lib, but this went into clojure directly now

5:18 ordnungswidrig: I see

5:18 so the docs of test-is will help?

5:18 AWizzArd: You can simply (require '[clojure.test :as test])

5:19 ordnungswidrig: yes those docs would help, but why don't you just look at http://github.com/richhickey/clojure/blob/master/src/clj/clojure/test.clj

5:23 ordnungswidrig: AWizzArd: thanks. that helps :)

5:25 AWizzArd: last question. How does leining find out about tests?

5:30 _ato: ordnungswidrig: Leiningen just calls (run-tests) on every namespace in: your-project/test/

5:31 ordnungswidrig: _ato: ok. It runs now :-)

5:31 _ato: is there a verbose mode so that I can see which tests ran?

5:32 _ato: not yet, Dan Larkin is working on improving Lein's test output

5:32 ordnungswidrig: ok

5:32 _ato: ordnungswidrig: are you using emacs or something else?

5:33 ordnungswidrig: _ato: what do you mean, "else". Is there something else than emacs?

5:33 _ato: good answer. :)

5:33 technomancy wrote a nice clojure-test-mode

5:33 it's in ELPA

5:33 it highlights assertions that failed in red

5:33 ordnungswidrig: _ato: I did not find out how it works. I keeps saying that I'm outside a test

5:34 AWizzArd: what is this strange elpa thing?

5:34 _ato: ah you tried it? hmm

5:34 it "just worked" for me

5:35 AWizzArd: http://tromey.com/elpa/

5:36 ordnungswidrig: _ato: hmm, now it runs. but nothing happens :-)

5:37 _ato: :-/

5:37 ordnungswidrig: _ato: ok, clojure-test-run-tests work ...run-test fails.

5:38 _ato: to use run-test you have to have the cursor inside a (deftest ...) form

5:38 ordnungswidrig: _ato: even then...

5:39 _ato: :/

5:39 http://github.com/ato/clojars-web/blob/couchdb/test/clojars/test/utils.clj

5:39 ^ this is what my tests look like

5:39 seems to work fine with that

5:40 ordnungswidrig: like mine, the only difference is that I use (deftest x (testing "..." (is ...)))

5:41 _ato: sweet you're using couchdb for clojars?

5:43 _ato: yeah, switching to it from sqlite. Couchdb seems to be a better fit as I generally just work with whole jar and user metadata documents, normalizing everything into an SQL db sucks for this kind of usage

5:44 ordnungswidrig: _ato: can you elaborate on why you've chosen clutch?

5:45 _ato: over clojure-couchdb? three reasons:

5:45 1. clojure-couchdb's function names are all backwards: document-get, document-update etc. :-P

5:46 ordnungswidrig: good point

5:46 _ato: 2. I got really sick of the way clojure-couchdb throws exceptions all over the place when documents aren't found. A document not being found is not an exceptional circumstance, and it's not very clojurish to do that.

5:47 ordnungswidrig: ah, I didn't see that one.

5:47 _ato: 3. Clutch provides a Clojure view server, so you can write your views in pure Clojure (although generating javascript with scriptjure is also not bad, but pure clojure is even better)

5:47 ordnungswidrig: ok, 3 is a nice point but not so important to me.

5:48 _ato: I'm not completely happy with either of them. I've already tweaked clutch a bit and will probably do so some more

5:50 I'm a complete CouchDB newbie though, so take what I say with a grain of salt ;-)

5:52 ordnungswidrig: _ato: I'm using couchdb for some time now. prototyped some REST services with ruby and couchdb. Now implementing in clojure and I wasn't happy clojure-couchdb eihter.

5:53 _ato: I think both of them are missing a way to deal with update conflicts

5:54 ordnungswidrig: _ato: how do they react?

5:54 _ato: I haven't tested, but I think clojure-couchdb throws an exception, like it does with everything

5:54 ordnungswidrig: pff

5:54 _ato: Clutch doesn't seem to even consider it

5:54 I think it should work similarly to clojure atoms, automatic retry with pure functions

5:55 ordnungswidrig: _ato: yes, that would make more sense.

5:55 _ato: or you specify a stragety

5:55 _ato: yeah

5:57 ordnungswidrig: hmm, how do I invoke a static method

5:57 _ato: (ClassName/methodName)

5:58 ordnungswidrig: ah, thanks

6:01 soo, pickung up the monster from the playschool

8:58 re

11:44 savanni: Hey, guys. I have a question. And I know it is going to sound like heresy, but...

11:45 Is there a way to put static type checking into clojure?

11:45 dnolen: technomancy: can you specify other repos easily to lein? for example jogl is hosted a different m2 repo then central.

11:46 savanni: not really, use function pre and post conditions if you need something like that.

11:46 savanni: dnolen: k. Thanks.

12:29 Jomyoot: Looking for twitter api for clojure

12:29 clojure lib for twitter

12:30 triyo: anyone know of any clojure or java api that can convert ms doc, excel to pdf?

12:35 cgrand: triyo: a long time ago, I have done that using an headless OOo

12:38 triyo: Icgrand: I see also that POI has some cool updated stuff in this space. Just need to see if POI has the pdf export feature of some sort.

12:47 ohpauleez: Jomyoot: There exists a twitter lib

12:47 http://github.com/mattrepl/clojure-twitter

12:47 Jomyoot: thanks

12:47 ohpauleez: You can also use URLs and RSS to rig up your own

12:47 np

12:48 Jomyoot: how large is scala vs. clojure community now?

12:48 ohpauleez: No idea, but the clojure community is booming now. And everyone is extremely knowledgeable and helpful

12:49 There are some overlap members

12:49 Jomyoot: what ide to most people use?

12:49 the-kenny: Jomyoot: Emacs

12:49 ohpauleez: I use vim

12:50 Jomyoot: not jetbrain?

12:50 or netbeans?

12:50 notallama: i use emacs + clojure mode. usually with slime.

12:50 ohpauleez: I hear some people of using it Jomyoot, there is clojure support

12:50 the-kenny: Jomyoot: My impression is that it's Emacs.

12:50 Emacs with slime is an excellent development environment for every type of lisp.

12:50 froog: emacs+slime is great

12:50 ohpauleez: I use emacs for common lisp and have been using vim with clojure (I edit everything else in vim)

12:51 Jomyoot: do i miss out if i cannot use emacs?

12:51 the-kenny: Jomyoot: Not really, but you should try it.

12:51 Jomyoot: learning curve

12:51 if u code clojure in emacs. when u switch to java stuff. do u still use emacs?

12:51 or do that in other ides?

12:51 ohpauleez: I also know of one person who edits clojure in eclipse because of work

12:52 I use vim for just about everything

12:52 the-kenny: Jomyoot: I "learned" to use a simple subset of emacs in approx. one night. You'll learn more and more if you use it constantly.

12:52 rsynnott: emacs/slime is very nice, especially if you're already used to it from common lisp

12:53 notallama: well, sometimes i just use gedit and a repl + jline, and that's fine too. emacs + slime is really handy for telling you order of arguments and indenting and such, though.

12:53 Jomyoot: how does emacs fair. if i want to also code Java in it too? I know wrong channel.

12:53 but emacs works wonder for clojure i know. but my project requires jumping clojure to java to ruby

12:53 would be nice to do all in same ide

12:53 ohpauleez: I think it's a pretty appropriate question. Emacs and Vim are both super powerful editors

12:54 and like the-kenny said, if you learn justa subset and go from there, you'll be golden

12:54 the-kenny: Simple editing is much more easier in emacs than in vim, in my opinion. (No Edit-Mode etc.)

12:55 (I mean if you're new to emacs/vim)

12:55 Sorry.. bad english

12:55 notallama: emacs is alright as an ide for non-lisps. it generally knows the syntax better than other ides (for indenting and such), but you don't get code completion and docs for non-lisps, as far as i know.

12:56 the-kenny: notallama: Depends on the mode for the language

12:56 froog: I have high hopes for this project: http://www.emacswiki.org/emacs/EmacsEclim

12:56 the-kenny: I think there's even a swank-backend for ruby... but I'm not sure

12:57 froog: re: emacs - java

12:57 ohpauleez: ahhh, ok. vim will do omnicompletion for most languages, but I really only use emacs for Common Lisp

12:58 the-kenny: ohpauleez: Simple completion based on the words in open buffers is supported natively in emacs.

12:59 Extended completion like knowing which keywords, functions etc. a specific language has is a concern for the specific mode for the language

13:00 The completion for lisps provided by slime is very very powerful.. but I wouldn't say this is limited to lisp-like languages.

13:01 notallama: has anyone had to deal with time in clojure/java before? i'm trying to write a game loop, but i hear System/nanoTime and System/currentTimeMillis are both buggy/inaccurate in windows. are there any alternatives?

13:02 AWizzArd: What was the name of the function which is like list but which evals its args in parallel?

13:02 oh wait, pvalues i think

13:03 the-kenny: AWizzArd: It starts with a p, I'm sure of that ;)

13:03 AWizzArd: yes yes, it's pvalues

13:03 ,(doc pvalues)

13:03 clojurebot down...

13:52 Is there a way to find out how many jobs are still scheduled for a given agent?

13:53 cark: i use a queue and a wakeup call when i need this

13:54 AWizzArd: which queue class do you use?

13:54 cark: ,PersistentQueue.EMPTY

13:54 hum

13:54 AWizzArd: ok

13:55 cark: hey but i didn't reasearch this toroughly, there might be some way

13:56 it's actually clojure.lang.PersistentQueue/EMPTY

14:55 thehcdreamer: Hi guys, I have installed clojure, but if I try to run the file foo.clj with the command: clj foo.clj, I get a java exception Exception in thread "main" java.io.FileNotFoundException: --foo.clj (No such file or directory) - anyone has an idea of what could be the cause?

14:59 the-kenny: thehcdreamer: "clj"? I've never heard of that

15:00 r2q2: the-kenny: You haven't heard of clj?

15:00 thehcdreamer: the-kenny: I installed it via macports and also seen it on a tutorial. It correcly invokes the shell woth no arguments

15:01 the-kenny: Ah, found it in the wiki.

15:22 ohpauleez: thehcdreamer: do you still have the issue?

15:22 thehcdreamer: ohpauleez: I'm reinstalling clojure following a more updated guide

15:23 ohpauleez: I was going to suggest that, and you can also check running scripts against the jar itself

15:23 I hand installed it on my mac, so if you have any issues, just holler

15:24 thehcdreamer: ohpauleez: I've found this very interesting project http://github.com/citizen428/ClojureX

15:25 ohpauleez: that's cool, I still prefer to do it by hand. It's not terribly difficult

15:59 polypus: you guys know if rhickey's talk at the nyc semantic web meetup is available in any form anywhere? google isn't giving me much

16:18 thehcdreamer: It's a shame that clojure is not listed in the sphere online judge website https://www.spoj.pl

17:15 cgordon: lisppaste8: hello

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

17:15 cgordon pasted "ClassCastException" at http://paste.lisp.org/display/91177

17:16 cgordon: can anyone tell me why "(machine "foo")" gives me: java.lang.Boolean [Thrown class java.lang.ClassCastException]?

17:17 it tells me the exception is thrown from " #((cond (empty? str) true"

17:18 the-kenny: cgordon: I think there's a () too much

17:18 cgordon: Macroexpand-1 of the part you've mentioned gives: (fn* [] ((cond (empty? str) true :else false)))

17:18 cgordon: ah, hrm

17:19 the-kenny: aha, that fixes it

17:19 the-kenny: I had an extra paren after the anonymous function form

17:19 thanks!

17:19 the-kenny: cgordon: trying to call a boolean like a function doesn't work really good ;)

18:46 dnolen: what do people use to modify .jars?

18:46 I just want delete a file out of a jar

18:47 slashus2: You may have to unpack the jar, remove the file, then repack the jar.

18:47 dnolen: slashus2: yeah I tried that. My java ignorance is an obstacle again. The repacked jar isn't executable anymore.

18:48 erg, this seems like a trivial feature that Eclipse or Netbeans should support but no.

18:51 dreish: Is it possible you removed something essential?

19:00 ohpauleez: dnolen: you need to make sure the manifest file points to the main class to execute

19:00 that's how a jar is executable

19:00 I assume you're getting some sort of Main Class Not Found error or exception

19:01 when you pack the jar, if you pack it so auto builds the manifest file, you'll need to pass in the args for the main class flag

19:01 or you can use leiningen

19:02 which will auto build the jars for you

19:07 j3ff86: is it possible to call map on a function that takes a collection and a variable (not a collection) as inputs?

19:08 rlb: j3ff86: can you elaborate?

19:08 j3ff86: i have a function, say function [coll point]

19:08 i want to call (map function coll point)

19:08 that doesnt work

19:09 rlb: j3ff86: should each call to function get the same point?

19:09 j3ff86: yes

19:09 actually the point is a collection, a vector

19:09 like [0 1]

19:09 rlb: (map #(function % point) coll)?

19:09 j3ff86: ah cool

19:09 dreish: You could do (map function coll (repeat point))

19:10 rlb: that too

19:14 j3ff86: that worked, thanks

19:37 michaeljaaka: hi people!

19:37 ,(reduce #(merge-with vector %1 %2) {} [ { :one "2332" } { :one "4334" } { :one "3443"}])

19:37 ,(reduce #(merge-with vector %1 %2) {} [ { :one "2332" } { :one "4334" } { :one "3443"}])

19:37 hmmm, why it is not printing the result?

19:37 (doc let)

19:38 ,(+ 2 3)

19:38 dreish: Clojurebot is not logged in.

19:38 michaeljaaka: ok

19:38 btw

19:38 the resoult from above function is

19:38 {:one [["2332" "4334"] "3443"]}

19:39 I would prefer to have {:one ["2332" "4334" "3443"]}

19:39 how to modify about expression?

19:40 dreish: That's a nice puzzle. Hmm.

19:40 Probably want to write a vec-or-conj function.

19:40 Then merge-with that.

19:40 michaeljaaka: yeah, something like this

19:41 hmmm, but maybe there is already something like this?

19:41 dreish: Doubt it.

19:41 michaeljaaka: ok, I will write it

19:41 thanks!

19:42 dreish: #(if (vector? %1) (conj %1 %2) (vector %1 %2))

19:43 hiredman: clojure.contrib.seq-utils/flatten

19:43 ,(update-in {:one [["2332" "4334"] "3443"]} [:one] flatten)

19:43 clojurebot: {:one ("2332" "4334" "3443")}

19:44 hiredman: ,(update-in {:one [["2332" "4334"] "3443"]} [:one] (comp vec flatten))

19:44 clojurebot: {:one ["2332" "4334" "3443"]}

19:44 dreish: That rewrites the whole vector, though.

19:44 O(N^2)

19:44 Or whatever.

19:44 _ato: ,(apply merge-with into (map #(fmap vector %) [{:one "2332" } {:one "4334"} {:one "3443"}]))

19:44 clojurebot: {:one ["2332" "4334" "3443"]}

19:44 michaeljaaka: wowowo :)

19:45 (reduce (fn[x y] (merge-with (fn[a b] (if (vector? a) (conj a b) (vector a b))) x y)) {} [ { :one "2332" } { :one "4334" } { :one "3443"}])

19:45 :)

19:45 but your is better :)

19:45 of course :)

19:45 _ato: or perhaps


19:45 ,(apply merge-with #(flatten (vector %1 %2)) [{:one "2332" } {:one "4334"} {:one "3443"}])

19:45 clojurebot: {:one ("2332" "4334" "3443")}

19:45 _ato: the flatten way is probably slower though

19:46 michaeljaaka: fmap is in seq-utils?

19:46 _ato: fmap is hidden under clojure.contrib.generic.functor

19:47 I really wish it was in seq-utils instead

19:47 defn: hey all

19:47 _ato: though there is a reason to why it's there, it doesn't deal with seqs, it deals with functors

19:47 eg

19:47 ,(fmap inc [1 2 3])

19:47 clojurebot: [2 3 4]

19:48 _ato: ,(fmap inc '(1 2 3))

19:48 clojurebot: (4 3 2)

19:48 Chousuke: hmm. curious result :P

19:48 michaeljaaka: ;)

19:49 _ato: woah... okay I think that last one is wrong

19:49 the-kenny: ,(class '(1 2 3))

19:49 clojurebot: clojure.lang.PersistentList

19:49 slashus2: ,(map inc '(1 2 3))

19:49 clojurebot: (2 3 4)

19:50 Chousuke: I suppose it just uses conj internally

19:50 but conj to a list adds to the front :/

19:50 _ato: yeah

19:50 ~def fmap

19:51 hiredman: should use into

19:51 the-kenny: It uses into

19:51 _ato: ,(into '() (map inc '(1 2 3)))

19:51 clojurebot: (4 3 2)

19:51 the-kenny: http://github.com/richhickey/clojure-contrib/blob/bdc813a0d39cb3c6184c4e123d847458e9c77711/src/clojure/contrib/generic/functor.clj#L20

19:51 hiredman: hmmm

19:51 the-kenny: line 26

19:52 hiredman: interesting

19:54 slashus2: ,(into '() '(1 2 3))

19:54 clojurebot: (3 2 1)

19:55 the-kenny: into uses conj internally

19:55 hiredman: yes

19:56 dreish: And conj!

19:56 somnium: ,(seq '(1 2 3))

19:56 clojurebot: (1 2 3)

19:57 chouser: in order to make a list "forwards" instead of "backwards", you either do it lazily or have to reverse it

19:57 ,(apply list [1 2 3])

19:57 clojurebot: (1 2 3)

19:58 chouser: the 'list' fn reverses internally

19:58 ,(concat [1 2 3] [4])

19:58 clojurebot: (1 2 3 4)

19:58 _ato: yeah, makes sense. That just surprised me, I was expecting fmap to work like map. :-)

20:00 chouser: yeah, I wonder if Konrad would consider that a bug.

20:00 fmap produces a non-lazy thing, so it doesn't seem like revering the input should be out of the question

20:02 michaeljaaka: btw how to use use ?

20:02 (use 'clojure.contrib.seq_utils :only [flatten])

20:03 doesn't work

20:03 doc has no examples

20:03 so it is hard to guess

20:03 especially for newbee

20:03 dreish: The doc for fmap is awfully loose. Could technically return an empty v after dorunning (map f v), and still be within the definition.

20:03 ohpauleez: http://java.ociweb.com/mark/clojure/article.html#Namespaces

20:03 michaeljaaka: ^^

20:04 (ns com.ociweb.demo (:require [clojure.contrib.str-utils :as su]))

20:04 is the short answer

20:05 then you would do something like (su/str-join ":" [1 2 3 4 5])

20:06 hiredman: michaeljaaka: (use '[clojure.contrib.seq_utils :only (flatten)])

20:06 michaeljaaka: hmmm

20:06 (use '[clojure.contrib.seq_utils :only (flatten)])

20:06 _ato: and seq-utils not seq_utils

20:06 michaeljaaka: user=>

20:06 #<CompilerException java.lang.Exception: namespace 'clojure.contrib.seq_utils' not found after loading '/clojure/contrib/seq_utils' (NO_SOURCE_FILE:0)>

20:06 :)

20:06 ok

20:07 thanks!!!

20:07 ohpauleez: is it bad style to use use like that?

20:08 I was under the impression you should only really use it with the ns macro and that require should be preferred to use

20:08 somnium`: not at the repl

20:08 ohpauleez: ahh, true, nvm

20:09 michaeljaaka: damn

20:10 _ato: how long do you program in clojure?

20:10 Chousuke: the same question

20:10 _ato: hmmm, I'm not sure. Perhaps 2 or 3 months.

20:10 defn: michaeljaaka: It's important to ask how long they'd programmed in lisp or functional langauges

20:11 they've*

20:11 the-kenny: defn: Yeah, I was going to say that just now

20:11 michaeljaaka: I wanted to ask it as second after reading 2 3 moths ;)

20:11 defn: I feel awfully slow compared to most people in here, but I've never touched lisp before this

20:12 _ato: I'd used Common Lisp and Scheme a little tiny bit (wrote one or two programs in each) but not much. I'd used Haskell a little bit more (for university assignments). But more so C, Python, Ruby.

20:13 michaeljaaka: I feel that imperative programing is like playing with mouse and FP like learning key shortcuts

20:13 the-kenny: _ato: It's basically the same for me :) Just replace C with C++

20:14 michaeljaaka: once learned can be faster invoked to achive some results

20:14 _ato: Oh and I've used Java a fair bit, but never out of choice. ;-)

20:15 the-kenny: michaeljaaka: If you try to write a java-program which is a little more complex than a simple hello world without ides like eclipse, you want to shoot yourself ;)

20:15 (In fact, I hate it even with eclipse)

20:15 michaeljaaka: yeah I know that

20:15 good IDE is a must have

20:15 somnium`: there's CEDET :)

20:16 michaeljaaka: well

20:16 if you try to program in dynamic language like python a middle sized program with 3 or 4 people

20:16 it is also very hard

20:16 defn: I really want to learn more C

20:16 the-kenny: I never tried cedet

20:16 michaeljaaka: reacaftoring is a nighmare

20:16 KirinDave: The sidebar aspect of cedet is cool.

20:16 defn: It's hard for me to justify having seen the future with Clojure and such

20:17 somnium`: its kind of like eclipsemacs

20:17 michaeljaaka: I wonder if the same is for clojure

20:17 defn: there's a project called eclim i believe

20:17 which aims to integrate parts of eclipse into emacs

20:17 KirinDave: michaeljaaka: The style of functional programming tends to make refactoring not-as-hard.

20:17 _ato: you definitely need paren matching and auto indentation with Clojure

20:18 but you don't need the full blown IDE stuff

20:18 KirinDave: Yeah, paredit is a godsend

20:18 _ato: SLIME is nice to have, but optional

20:18 the-kenny: paredit ftw :)

20:18 defn: SLIME is too nice to not have

20:18 IMHO

20:18 KirinDave: michaeljaaka: The biggest pain really is when you change your nouns.

20:18 michaeljaaka: That's why most common lisps make a functional abstraction over their structures, something Clojure doesn't really od.

20:18 Err, do

20:18 the-kenny: (But I've seen some issues with paredit and {} and [])

20:18 defn: the-kenny: that's an old issue IIRC

20:19 }{ was a problem IIRC

20:19 KirinDave: Yeah, get a new paredit.

20:19 defn: but not anymore

20:19 the-kenny: defn: No, it works fine except for M-{ or M-[

20:19 defn: ah-ha, that's what it was

20:19 the-kenny: Really

20:19 ?

20:20 somnium`: anyone tried ergoemacs?

20:20 defn: That it's fixed?

20:20 somnium`: no

20:20 the-kenny: Wow, I thoght I got the newest paredit

20:20 KirinDave: I fixed my paredit long ago, but it's an old version I've been hacking on for years.

20:20 _ato: yeah... M-[ is undefined and M-{ jumps back a paragraph or something. I should override the bindings, that annoys me as well

20:20 rlb: I'm toying with an api for sub-processes that makes it easier to integrate them into sequences. Any suggestions about how to handle process failures? imagine (filter pred (sysx "grep" "foo" :out (fn [out err] (line-seq out))

20:21 defn: the-kenny: M-[ works

20:21 M-{ doesnt

20:21 but that just might be my ignorance of how to use it

20:21 rlb: :in (sysx "xargs" ...)))

20:21 the-kenny: defn: What's your paredit version?

20:21 defn: the-kenny: i dont...know

20:22 michaeljaaka: hmm is it possible in clojure to make behaviour like agent is reciving some data and yelds them as a sequence

20:22 lazy sequence readed by someone else

20:22 defn: the-kenny: paredit-20

20:22 the-kenny: defn: Okay, that's strange. I'm using 21

20:22 michaeljaaka: and once when codition readed agent ends sequnce?

20:22 somnium`: 22

20:22 defn: that is really strange :)

20:23 _ato: michaeljaaka: check out: http://clj-me.cgrand.net/2009/11/18/are-pipe-dreams-made-of-promises/

20:23 rlb: michaeljaaka: not sure - if you just want to handle reading output from a process with buffering, but without blocking, you could use fill-queue.

20:23 KirinDave: michaeljaaka: Check out http://clj-me.cgrand.net/2009/11/18/are-pipe-dreams-made-of-promises/

20:23 _ato: and also fill-queue in clojure.contrib.seq-utils

20:23 KirinDave: _ato: Oh shit, get out of my brain. :)

20:23 _ato: :D

20:23 the-kenny: M-[ is undefined in 22 too :(

20:24 michaeljaaka: oh

20:24 the-kenny: hm.. I'll hack it together

20:24 michaeljaaka: that is exactly what i need

20:24 the pipe

20:24 from that blog

20:25 KirinDave: Yeah thats a beautiful piece of code.

20:25 I must confess I do not entirely understand it.

20:25 I need to stop clinging to my guns, religion, and clojure-1.0.0

20:26 rlb: (The main thing I was wondering about was how people might want process errors to be handled, i.e. non-zero exit codes, when you basically have a pipeline.)

20:26 michaeljaaka: hmm buf fill-queue may be also usefull

20:27 rlb: ... (filter foo (sysx "xargs" "grep" "bar" ... :in (sysx "find" ...)))

20:31 the-kenny: hah awesome :) Hacking paredit is pleasing

20:39 slashus2: I am using clojure.main and -i to load my clojure files, but I am having circular reference problems. The -i loads the scripts in order of how I have them. Any easy way to get around that?

20:41 _ato: slashus2: I generally do this instead of -i: java -cp 'src:classes:lib/*' clojure.main -e "(use 'myproject.core) (main)"

20:44 KirinDave: Hum, I really like promise/deliver.

20:44 slashus2: _ato: I have a macro that refers to a var... doing the method that you just mentioned doesn't find the var.

20:45 _ato: slashus2: I suspect your macro is referring to the var in the wrong way then

20:45 if you pastebin it I'll take a look

20:46 slashus2: It worked fine before I wanted to do the circular reference stuff.

20:46 _ato: slashus2: what do you mean by circular reference? One namespace uses another which in turn uses the first?

20:47 slashus2: I have a function in one that uses a function in the other and the other way.

20:47 _ato: in the same namespace? then that should be fine. Just (declare other-fn) before the first one.

20:47 slashus2: different namespaces

20:48 _ato: in that case, import your namespaces with 'require' instead of 'use'

20:48 also

20:48 cark: one way to do this is to pass your first function as a parameter tu the second function when you call it

20:48 and remove the dependency

20:49 _ato: also, don't start your program from the top-level. Have a main function instead

20:49 slashus2: The function is called from within a macro.

20:49 cark: so what ?

20:49 or you could have a var in your second namespace, set it once the first function is defined

20:49 set it to your first function i mean

20:50 or you could use multimethods

20:50 define a multimethod in your second namespace

20:50 then make an implementation of it in your first namespac

20:51 the possibilities are endless to fix this kind of trouble =)

20:51 _ato: you might need to namespace qualify the function in your macro with foo/bar. It's hard to say what the problem is and best solution without more detail about your code

20:52 cark: that's code smell you have here, it means you have a mistake in your design

20:52 slashus2: right

20:53 cark: i'm being a bit harsh, sorry forget that

20:53 usually when i see this in my code, that's because i didn't anticipate i needed a callback

20:55 slashus2: http://gist.github.com/244330

20:55 cark: This is the macro that is probably causing all of the problems.

20:56 Each of my plugins in my plugins folder is loaded. They all use this macro.

20:56 Everytime it loads a plugin, I wanted it to add its doc info and name to a command list.

20:56 every time*

20:56 cark: i guess this plugin code is refered to from com.clojbot.clojbotcore

20:57 slashus2: I actually have this code in the com.clojbot.utilities namespace.

20:57 I guess I should move it to clojbotcore..

20:58 _ato: yes, that'd probably be the simplest solution

20:58 normally your utils should be self-contained

20:58 cark: i'd move it to a plugins namespace

20:58 _ato: they shouldn't rely on other parts of your program

20:58 otherwise they're not really utilities

20:58 slashus2: I just put it there because conceptually it makes sense to me.

20:59 cark: and (def plugin-add-to-command-list (atom nil))

21:00 slashus2: cark: So set it off to the side and put it in the plugin's namespace?

21:00 cark: from core : (defn add-to-command-list ..... ) then (reset! plugin-add-to-command-list add-to-command-list)

21:00 slashus2: That is what my function does.

21:00 in the core that is

21:00 cark: then in your macro : ~(@plugin-add-to-commandl-list .....à

21:01 that's one way to do it

21:02 another way : don't make plugin-add-to-command-list an atom, but use a binding form when you actually load the plugins

21:02 though that wouldn't work

21:02 slashus2: I may come back later. I probably need to rethink my design. Thank you for your suggestions.

21:02 _ato: yeah. It is possible to do circular references, but as you've discovered you have to be careful about it. Wherever possible it's better to structure your program in layers so that higher-level layers depend on lower layers but not vice-versa.

21:02 cark: good luck =)

21:03 coming from an oo language where you think a lot about events, it's hard to do what you say ato

21:04 lots of lower level stuff needs to callback anyways

21:04 _ato: right, but usually you should register callbacks somehow rather than having the lower layer call into the higher one directly

21:05 cark: true

21:06 _ato: in languages like C and Java this can be a bit annoying due to the lack of first-class functions (at least you've got function pointers in C)

21:06 cark: ahwell you have interfaces for this in java

21:06 anonymous classes too

21:06 _ato: yeah

21:07 cark: quite the same, only the ceremony is different

22:13 notallama: anyone have ideas for a name for a (2d) game engine? i'm far enough into making it now that it should probably have a name.

22:14 JAS415: hmm

22:14 funkenblatt: flatland


22:14 derefed: how about

22:14 notalamegame2d

22:15 funkenblatt: also a good book

22:16 JAS415: idk

22:16 i guess it depends on what type of 2d game engine it is

22:17 is it like side scroller or 2 1/2 d (like starcraft or roguelike games) or something else

22:18 rlb: What's the clojure equivalent of (procedure? foo)?

22:19 chouser: ,(ifn? (fn [] 123))

22:19 clojurebot: true

22:19 rlb: ahh, thanks.

22:19 chouser: ,(ifn? {:a 1})

22:19 clojurebot: true

22:20 JAS415: --- maybe flatjure

22:20 notallama: it's more general than that. basically, it's some wrapping for jframes and such to make events and drawing seq based. (and later sound will be too), plus assorted functions that are handy for games. like some physics stuff, image loading, etc.

22:20 JAS415: oh wow

22:21 notallama: so, sort of like love, but functional, i guess.

22:22 rlb: (BTW, for the process exit status -- perhaps just launch a thread that calls (.waitFor proc) and throws an exception if the result is non-zero...)

22:23 JAS415: game engines must be challenging to name

22:28 notallama: i was thinking "peace" or "respect", since "love" and "unity" already exist. they're kindof generic and not so good for searches, though.

22:29 JAS415: well its love, but functional

22:29 so some concatenation of that

22:29 or throw in lambda, those are fun

22:30 notallama: is it considered code smell if your library doesn't have a j in the name?

22:30 * technomancy has decided not to pick any more names that aren't from literary characters

22:30 JAS415: haha

22:30 technomancy: notallama: more of a "code aroma"

22:31 JAS415: i always thought that it was kind of weird that everything clojure ends up with a J in the name

22:31 lovejure

22:31 rlb: So, given a preceeding (in-ns 'clojure.contrib.shell-out), why can't the code see the "defn-" function parse-args?

22:31 technomancy: please... we've had enough *jure or clo* names.

22:31 JAS415: :-)

22:31 clove

22:32 notallama: i kindof like that one, actually. : p

22:32 JAS415: technomancy: agreed :-P

22:32 rlb: Is in-ns not viable if (while developing) you want to extend a namespace with new functions?

22:33 technomancy: time to start getting unique, like the guy on the mailing list who named his project "chlamydia"

22:34 JAS415: promiscuity

22:35 its got a c and a u so its like clojure

22:36 _mst: technomancy: possibly even more difficult to spell than leiningen :)

22:37 rlb: oh, wait nevermind -- wrong directory.

22:38 JAS415: does anyone know of the top of their head if the pattern matcher in clojure-contrib matches in a nested manner?

22:41 notallama: my sister suggested "schuhsenkel" (german for shoelace)

22:41 JAS415: cool

22:41 will be easy to google for

22:42 notallama: as long as you remember how to spell it : p

22:42 technomancy: my next project will be called Orestes, provided I can come up with code awesome enough to merit that title

22:42 JAS415: oh

22:44 technomancy: or possibly Thursday/Gabriel Syme if danlarkin does not use that name

22:50 JAS415: ,(= :GET :get)

22:50 clojurebot: false

23:04 dnolen: technomancy: is there anything special that needs to be done with lein to specify the library path JNIs when creating jars ?

23:08 technomancy: dnolen: I don't really know anything about JNI.

23:09 dnolen: technomancy: neither do I :) I imagine I'll figure this out eventually. One question tho...

23:09 lein uberjar - does that use maven functionality or something to create the single jar?

23:10 technomancy: no, it's implemented in leiningen

23:10 well, actually it used lancet in 0.5.0, but it's been refactored since

23:10 dnolen: ok

23:11 technomancy: it's quite possible that there's no way to do JNI jars right now

23:11 if so, please bring it up on the mailing list

23:12 actually, bring it up either way; if it works we should document it

23:13 dnolen: asking in #java :D

23:14 never stepped in there before

Logging service provided by n01se.net