#clojure logs

2009-11-27

01:09burnyis there an easy way to reduce a list of hash-maps to one hash-map of all elements?
01:10_mst,(apply merge [{:hello 1} {:world 2}])
01:10clojurebot{:world 2, :hello 1}
01:11burnyawesome, thanks
01:18piccolinoIs there some way that two namespaces can see each other's private defs, but not other namespaces?
01:19_atopiccolino: not as far as I know, but you can have one namespace across two files by using load
01:19piccolinoHm, that's what I thought. Thanks.
01:33piccolinoIs there some way to do like a dynamically scoped variable?
01:34hiredman
01:34hiredmanseriously?
01:34hiredmanhttp://clojure.org/vars
01:36piccolinoYeah, 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.
01:40_ato,(binding [not identity] (odd? 3))
01:40clojurebotfalse
01:40_ato,(binding [not identity] (odd? 2))
01:40clojurebottrue
01:40_ato^ dynamic scoping
01:40_atowe rebind "not" to be the identity function
01:41piccolinoHmn, that is how I would expect that to behave.
01:41hiredmanwell did you read the vars page?
01:41piccolinoI guess maybe then odd? has to have its own view of not somewhere before it will compile. Is that a declare?
01:41_atoyes
01:41_atoyou'll need to declare or def a var before you can use it in binding
01:41piccolinoYes I did.
01:42piccolinoIt's probably really clear to someone who already understands it.
01:44piccolinoThanks _ato
01:45_atopiccolino: you got it working?
01:46piccolinoYeah, the doc string for binding made me think that you could make it work by using binding without having def'd that variable first.
01:48piccolinoWhat happens if different threads use a var simultaneously without having first used binding to make their own copy?
01:49hiredmanwhat do you mean by "use"
01:49piccolinoAlter it.
01:49hiredmanset! doesn't work unless the var is bound via binding
01:49piccolinoI see, thanks.
01:50_ato,(set! not identity)
01:50clojurebotjava.lang.IllegalStateException: Can't change/establish root binding of: not with set
02:21Jomyootis twitter-clj "THE" twitter library for clojure?
02:25JomyootI would like clojure libary that helps scan twitter public timeline
04:21ordnungswidrighi
04:25AWizzArdMoin ordnungs
04:32ordnungswidriganybody online with deeper knowledge on protocols?
04:39AWizzArdWhat would you ask this person if he/she were online?
04:42ordnungswidrigI'm implementing this HTTP decision graph on top of compojure: http://thoughtpad.net/alan-dean/http-headers-status.html
04:43ordnungswidrigBasically 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:
04:44ordnungswidrig{ :generate-etag (fn [req] (-> req :params "articleId")) :exists? (fn [req] (db-exists-key (-> req :params "articleId"))) }
04:48AWizzArdprotocols will help when you want to do something depending on the type/class of a objet
04:50ordnungswidrigthere 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).
04:52AWizzArdProtocols 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.
04:52AWizzArdOtherwise if you want to dispatch on the value of one or many args then multimethods would be the right tool.
04:53AWizzArdIn some weeks there might be MultiProtocols which then could also help.
04:54AWizzArdordnungswidrig: do you have about 25-30 deftype forms in your code? Or do you use as many jvm classes?
04:54JomyootWhat is "the" twitter library for clojure?
04:54Jomyootwith most complete features?
05:05ordnungswidrigAWizzArd: The dispatch on a single value, the "resource"
05:06ordnungswidrigAWizzArd: I thought, I'd deftype each resource which each implement the resource protocol.
05:06ordnungswidrigAWizzArd: so the number of resource will be the number of deftypes. and the protocol the declare about 30 functions.
05:11AWizzArdordnungswidrig: if you have a deftype for each resource and need to act on those then protocols could be a good way to do this
05:13ordnungswidrigAWizzArd: however I see no advantage over maps when the type will be defined specially to represent a resource. Maybe method lookup would be faster
05:17AWizzArdordnungswidrig: Protocols were mainly implemented for giving performance. Those protocol methods can be called with full jvm speed.
05:17ordnungswidrigme is confused. where is a test library for clojure? leining uses clojure.test which I cannot find
05:17AWizzArdthis comes with Clojure
05:17ordnungswidrigAWizzArd: but the api docs do not mention it
05:18AWizzArdin the past there was a clojure.contrib.test-is lib, but this went into clojure directly now
05:18ordnungswidrigI see
05:18ordnungswidrigso the docs of test-is will help?
05:18AWizzArdYou can simply (require '[clojure.test :as test])
05:19AWizzArdordnungswidrig: 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
05:23ordnungswidrigAWizzArd: thanks. that helps :)
05:25ordnungswidrigAWizzArd: last question. How does leining find out about tests?
05:30_atoordnungswidrig: Leiningen just calls (run-tests) on every namespace in: your-project/test/
05:31ordnungswidrig_ato: ok. It runs now :-)
05:31ordnungswidrig_ato: is there a verbose mode so that I can see which tests ran?
05:32_atonot yet, Dan Larkin is working on improving Lein's test output
05:32ordnungswidrigok
05:32_atoordnungswidrig: are you using emacs or something else?
05:33ordnungswidrig_ato: what do you mean, "else". Is there something else than emacs?
05:33_atogood answer. :)
05:33_atotechnomancy wrote a nice clojure-test-mode
05:33_atoit's in ELPA
05:33_atoit highlights assertions that failed in red
05:33ordnungswidrig_ato: I did not find out how it works. I keeps saying that I'm outside a test
05:34AWizzArdwhat is this strange elpa thing?
05:34_atoah you tried it? hmm
05:34_atoit "just worked" for me
05:35_atoAWizzArd: http://tromey.com/elpa/
05:36ordnungswidrig_ato: hmm, now it runs. but nothing happens :-)
05:37_ato:-/
05:37ordnungswidrig_ato: ok, clojure-test-run-tests work ...run-test fails.
05:38_atoto use run-test you have to have the cursor inside a (deftest ...) form
05:38ordnungswidrig_ato: even then...
05:39_ato:/
05:39_atohttp://github.com/ato/clojars-web/blob/couchdb/test/clojars/test/utils.clj
05:39_ato^ this is what my tests look like
05:39_atoseems to work fine with that
05:40ordnungswidriglike mine, the only difference is that I use (deftest x (testing "..." (is ...)))
05:41ordnungswidrig_ato: sweet you're using couchdb for clojars?
05:43_atoyeah, 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
05:44ordnungswidrig_ato: can you elaborate on why you've chosen clutch?
05:45_atoover clojure-couchdb? three reasons:
05:45_ato1. clojure-couchdb's function names are all backwards: document-get, document-update etc. :-P
05:46ordnungswidriggood point
05:46_ato2. 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.
05:47ordnungswidrigah, I didn't see that one.
05:47_ato3. 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)
05:47ordnungswidrigok, 3 is a nice point but not so important to me.
05:48_atoI'm not completely happy with either of them. I've already tweaked clutch a bit and will probably do so some more
05:50_atoI'm a complete CouchDB newbie though, so take what I say with a grain of salt ;-)
05:52ordnungswidrig_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.
05:53_atoI think both of them are missing a way to deal with update conflicts
05:54ordnungswidrig_ato: how do they react?
05:54_atoI haven't tested, but I think clojure-couchdb throws an exception, like it does with everything
05:54ordnungswidrigpff
05:54_atoClutch doesn't seem to even consider it
05:54_atoI think it should work similarly to clojure atoms, automatic retry with pure functions
05:55ordnungswidrig_ato: yes, that would make more sense.
05:55ordnungswidrig_ato: or you specify a stragety
05:55_atoyeah
05:57ordnungswidrighmm, how do I invoke a static method
05:57_ato(ClassName/methodName)
05:58ordnungswidrigah, thanks
06:01ordnungswidrigsoo, pickung up the monster from the playschool
08:58ordnungswidrigre
11:44savanniHey, guys. I have a question. And I know it is going to sound like heresy, but...
11:45savanniIs there a way to put static type checking into clojure?
11:45dnolentechnomancy: can you specify other repos easily to lein? for example jogl is hosted a different m2 repo then central.
11:46dnolensavanni: not really, use function pre and post conditions if you need something like that.
11:46savannidnolen: k. Thanks.
12:29JomyootLooking for twitter api for clojure
12:29Jomyootclojure lib for twitter
12:30triyoanyone know of any clojure or java api that can convert ms doc, excel to pdf?
12:35cgrandtriyo: a long time ago, I have done that using an headless OOo
12:38triyoIcgrand: 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:47ohpauleezJomyoot: There exists a twitter lib
12:47ohpauleezhttp://github.com/mattrepl/clojure-twitter
12:47Jomyootthanks
12:47ohpauleezYou can also use URLs and RSS to rig up your own
12:47ohpauleeznp
12:48Jomyoothow large is scala vs. clojure community now?
12:48ohpauleezNo idea, but the clojure community is booming now. And everyone is extremely knowledgeable and helpful
12:49ohpauleezThere are some overlap members
12:49Jomyootwhat ide to most people use?
12:49the-kennyJomyoot: Emacs
12:49ohpauleezI use vim
12:50Jomyootnot jetbrain?
12:50Jomyootor netbeans?
12:50notallamai use emacs + clojure mode. usually with slime.
12:50ohpauleezI hear some people of using it Jomyoot, there is clojure support
12:50the-kennyJomyoot: My impression is that it's Emacs.
12:50the-kennyEmacs with slime is an excellent development environment for every type of lisp.
12:50froogemacs+slime is great
12:50ohpauleezI use emacs for common lisp and have been using vim with clojure (I edit everything else in vim)
12:51Jomyootdo i miss out if i cannot use emacs?
12:51the-kennyJomyoot: Not really, but you should try it.
12:51Jomyootlearning curve
12:51Jomyootif u code clojure in emacs. when u switch to java stuff. do u still use emacs?
12:51Jomyootor do that in other ides?
12:51ohpauleezI also know of one person who edits clojure in eclipse because of work
12:52ohpauleezI use vim for just about everything
12:52the-kennyJomyoot: 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:52rsynnottemacs/slime is very nice, especially if you're already used to it from common lisp
12:53notallamawell, 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:53Jomyoothow does emacs fair. if i want to also code Java in it too? I know wrong channel.
12:53Jomyootbut emacs works wonder for clojure i know. but my project requires jumping clojure to java to ruby
12:53Jomyootwould be nice to do all in same ide
12:53ohpauleezI think it's a pretty appropriate question. Emacs and Vim are both super powerful editors
12:54ohpauleezand like the-kenny said, if you learn justa subset and go from there, you'll be golden
12:54the-kennySimple editing is much more easier in emacs than in vim, in my opinion. (No Edit-Mode etc.)
12:55the-kenny(I mean if you're new to emacs/vim)
12:55the-kennySorry.. bad english
12:55notallamaemacs 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:56the-kennynotallama: Depends on the mode for the language
12:56froogI have high hopes for this project: http://www.emacswiki.org/emacs/EmacsEclim
12:56the-kennyI think there's even a swank-backend for ruby... but I'm not sure
12:57froogre: emacs - java
12:57ohpauleezahhh, ok. vim will do omnicompletion for most languages, but I really only use emacs for Common Lisp
12:58the-kennyohpauleez: Simple completion based on the words in open buffers is supported natively in emacs.
12:59the-kennyExtended completion like knowing which keywords, functions etc. a specific language has is a concern for the specific mode for the language
13:00the-kennyThe completion for lisps provided by slime is very very powerful.. but I wouldn't say this is limited to lisp-like languages.
13:01notallamahas 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:02AWizzArdWhat was the name of the function which is like list but which evals its args in parallel?
13:02AWizzArdoh wait, pvalues i think
13:03the-kennyAWizzArd: It starts with a p, I'm sure of that ;)
13:03AWizzArdyes yes, it's pvalues
13:03AWizzArd,(doc pvalues)
13:03AWizzArdclojurebot down...
13:52AWizzArdIs there a way to find out how many jobs are still scheduled for a given agent?
13:53carki use a queue and a wakeup call when i need this
13:54AWizzArdwhich queue class do you use?
13:54cark,PersistentQueue.EMPTY
13:54carkhum
13:54AWizzArdok
13:55carkhey but i didn't reasearch this toroughly, there might be some way
13:56carkit's actually clojure.lang.PersistentQueue/EMPTY
14:55thehcdreamerHi 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:59the-kennythehcdreamer: "clj"? I've never heard of that
15:00r2q2the-kenny: You haven't heard of clj?
15:00thehcdreamerthe-kenny: I installed it via macports and also seen it on a tutorial. It correcly invokes the shell woth no arguments
15:01the-kennyAh, found it in the wiki.
15:22ohpauleezthehcdreamer: do you still have the issue?
15:22thehcdreamerohpauleez: I'm reinstalling clojure following a more updated guide
15:23ohpauleezI was going to suggest that, and you can also check running scripts against the jar itself
15:23ohpauleezI hand installed it on my mac, so if you have any issues, just holler
15:24thehcdreamerohpauleez: I've found this very interesting project http://github.com/citizen428/ClojureX
15:25ohpauleezthat's cool, I still prefer to do it by hand. It's not terribly difficult
15:59polypusyou 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:18thehcdreamerIt's a shame that clojure is not listed in the sphere online judge website https://www.spoj.pl
17:15cgordonlisppaste8: hello
17:15lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
17:15lisppaste8cgordon pasted "ClassCastException" at http://paste.lisp.org/display/91177
17:16cgordoncan anyone tell me why "(machine "foo")" gives me: java.lang.Boolean [Thrown class java.lang.ClassCastException]?
17:17cgordonit tells me the exception is thrown from " #((cond (empty? str) true"
17:18the-kennycgordon: I think there's a () too much
17:18the-kennycgordon: Macroexpand-1 of the part you've mentioned gives: (fn* [] ((cond (empty? str) true :else false)))
17:18cgordonah, hrm
17:19cgordonthe-kenny: aha, that fixes it
17:19cgordonthe-kenny: I had an extra paren after the anonymous function form
17:19cgordonthanks!
17:19the-kennycgordon: trying to call a boolean like a function doesn't work really good ;)
18:46dnolenwhat do people use to modify .jars?
18:46dnolenI just want delete a file out of a jar
18:47slashus2You may have to unpack the jar, remove the file, then repack the jar.
18:47dnolenslashus2: yeah I tried that. My java ignorance is an obstacle again. The repacked jar isn't executable anymore.
18:48dnolenerg, this seems like a trivial feature that Eclipse or Netbeans should support but no.
18:51dreishIs it possible you removed something essential?
19:00ohpauleezdnolen: you need to make sure the manifest file points to the main class to execute
19:00ohpauleezthat's how a jar is executable
19:00ohpauleezI assume you're getting some sort of Main Class Not Found error or exception
19:01ohpauleezwhen 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:01ohpauleezor you can use leiningen
19:02ohpauleezwhich will auto build the jars for you
19:07j3ff86is it possible to call map on a function that takes a collection and a variable (not a collection) as inputs?
19:08rlbj3ff86: can you elaborate?
19:08j3ff86i have a function, say function [coll point]
19:08j3ff86i want to call (map function coll point)
19:08j3ff86that doesnt work
19:09rlbj3ff86: should each call to function get the same point?
19:09j3ff86yes
19:09j3ff86actually the point is a collection, a vector
19:09j3ff86like [0 1]
19:09rlb(map #(function % point) coll)?
19:09j3ff86ah cool
19:09dreishYou could do (map function coll (repeat point))
19:10rlbthat too
19:14j3ff86that worked, thanks
19:37michaeljaakahi people!
19:37michaeljaaka,(reduce #(merge-with vector %1 %2) {} [ { :one "2332" } { :one "4334" } { :one "3443"}])
19:37michaeljaaka,(reduce #(merge-with vector %1 %2) {} [ { :one "2332" } { :one "4334" } { :one "3443"}])
19:37michaeljaakahmmm, why it is not printing the result?
19:37michaeljaaka(doc let)
19:38michaeljaaka,(+ 2 3)
19:38dreishClojurebot is not logged in.
19:38michaeljaakaok
19:38michaeljaakabtw
19:38michaeljaakathe resoult from above function is
19:38michaeljaaka{:one [["2332" "4334"] "3443"]}
19:39michaeljaakaI would prefer to have {:one ["2332" "4334" "3443"]}
19:39michaeljaakahow to modify about expression?
19:40dreishThat's a nice puzzle. Hmm.
19:40dreishProbably want to write a vec-or-conj function.
19:40dreishThen merge-with that.
19:40michaeljaakayeah, something like this
19:41michaeljaakahmmm, but maybe there is already something like this?
19:41dreishDoubt it.
19:41michaeljaakaok, I will write it
19:41michaeljaakathanks!
19:42dreish#(if (vector? %1) (conj %1 %2) (vector %1 %2))
19:43hiredmanclojure.contrib.seq-utils/flatten
19:43hiredman,(update-in {:one [["2332" "4334"] "3443"]} [:one] flatten)
19:43clojurebot{:one ("2332" "4334" "3443")}
19:44hiredman,(update-in {:one [["2332" "4334"] "3443"]} [:one] (comp vec flatten))
19:44clojurebot{:one ["2332" "4334" "3443"]}
19:44dreishThat rewrites the whole vector, though.
19:44dreishO(N^2)
19:44dreishOr whatever.
19:44_ato,(apply merge-with into (map #(fmap vector %) [{:one "2332" } {:one "4334"} {:one "3443"}]))
19:44clojurebot{:one ["2332" "4334" "3443"]}
19:44michaeljaakawowowo :)
19:45michaeljaaka(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:45michaeljaaka:)
19:45michaeljaakabut your is better :)
19:45michaeljaakaof course :)
19:45_atoor perhaps
19:45_ato
19:45_ato,(apply merge-with #(flatten (vector %1 %2)) [{:one "2332" } {:one "4334"} {:one "3443"}])
19:45clojurebot{:one ("2332" "4334" "3443")}
19:45_atothe flatten way is probably slower though
19:46michaeljaakafmap is in seq-utils?
19:46_atofmap is hidden under clojure.contrib.generic.functor
19:47_atoI really wish it was in seq-utils instead
19:47defnhey all
19:47_atothough there is a reason to why it's there, it doesn't deal with seqs, it deals with functors
19:47_atoeg
19:47_ato,(fmap inc [1 2 3])
19:47clojurebot[2 3 4]
19:48_ato,(fmap inc '(1 2 3))
19:48clojurebot(4 3 2)
19:48Chousukehmm. curious result :P
19:48michaeljaaka;)
19:49_atowoah... okay I think that last one is wrong
19:49the-kenny,(class '(1 2 3))
19:49clojurebotclojure.lang.PersistentList
19:49slashus2,(map inc '(1 2 3))
19:49clojurebot(2 3 4)
19:50ChousukeI suppose it just uses conj internally
19:50Chousukebut conj to a list adds to the front :/
19:50_atoyeah
19:50_ato~def fmap
19:51hiredmanshould use into
19:51the-kennyIt uses into
19:51_ato,(into '() (map inc '(1 2 3)))
19:51clojurebot(4 3 2)
19:51the-kennyhttp://github.com/richhickey/clojure-contrib/blob/bdc813a0d39cb3c6184c4e123d847458e9c77711/src/clojure/contrib/generic/functor.clj#L20
19:51hiredmanhmmm
19:51the-kennyline 26
19:52hiredmaninteresting
19:54slashus2,(into '() '(1 2 3))
19:54clojurebot(3 2 1)
19:55the-kennyinto uses conj internally
19:55hiredmanyes
19:56dreishAnd conj!
19:56somnium,(seq '(1 2 3))
19:56clojurebot(1 2 3)
19:57chouserin order to make a list "forwards" instead of "backwards", you either do it lazily or have to reverse it
19:57chouser,(apply list [1 2 3])
19:57clojurebot(1 2 3)
19:58chouserthe 'list' fn reverses internally
19:58chouser,(concat [1 2 3] [4])
19:58clojurebot(1 2 3 4)
19:58_atoyeah, makes sense. That just surprised me, I was expecting fmap to work like map. :-)
20:00chouseryeah, I wonder if Konrad would consider that a bug.
20:00chouserfmap produces a non-lazy thing, so it doesn't seem like revering the input should be out of the question
20:02michaeljaakabtw how to use use ?
20:02michaeljaaka(use 'clojure.contrib.seq_utils :only [flatten])
20:03michaeljaakadoesn't work
20:03michaeljaakadoc has no examples
20:03michaeljaakaso it is hard to guess
20:03michaeljaakaespecially for newbee
20:03dreishThe doc for fmap is awfully loose. Could technically return an empty v after dorunning (map f v), and still be within the definition.
20:03ohpauleezhttp://java.ociweb.com/mark/clojure/article.html#Namespaces
20:03ohpauleezmichaeljaaka: ^^
20:04ohpauleez(ns com.ociweb.demo (:require [clojure.contrib.str-utils :as su]))
20:04ohpauleezis the short answer
20:05ohpauleezthen you would do something like (su/str-join ":" [1 2 3 4 5])
20:06hiredmanmichaeljaaka: (use '[clojure.contrib.seq_utils :only (flatten)])
20:06michaeljaakahmmm
20:06michaeljaaka(use '[clojure.contrib.seq_utils :only (flatten)])
20:06_atoand seq-utils not seq_utils
20:06michaeljaakauser=>
20:06michaeljaaka#<CompilerException java.lang.Exception: namespace 'clojure.contrib.seq_utils' not found after loading '/clojure/contrib/seq_utils' (NO_SOURCE_FILE:0)>
20:06michaeljaaka:)
20:06michaeljaakaok
20:07michaeljaakathanks!!!
20:07ohpauleezis it bad style to use use like that?
20:08ohpauleezI was under the impression you should only really use it with the ns macro and that require should be preferred to use
20:08somnium`not at the repl
20:08ohpauleezahh, true, nvm
20:09michaeljaakadamn
20:10michaeljaaka_ato: how long do you program in clojure?
20:10michaeljaakaChousuke: the same question
20:10_atohmmm, I'm not sure. Perhaps 2 or 3 months.
20:10defnmichaeljaaka: It's important to ask how long they'd programmed in lisp or functional langauges
20:11defnthey've*
20:11the-kennydefn: Yeah, I was going to say that just now
20:11michaeljaakaI wanted to ask it as second after reading 2 3 moths ;)
20:11defnI feel awfully slow compared to most people in here, but I've never touched lisp before this
20:12_atoI'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:13michaeljaakaI feel that imperative programing is like playing with mouse and FP like learning key shortcuts
20:13the-kenny_ato: It's basically the same for me :) Just replace C with C++
20:14michaeljaakaonce learned can be faster invoked to achive some results
20:14_atoOh and I've used Java a fair bit, but never out of choice. ;-)
20:15the-kennymichaeljaaka: 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:15the-kenny(In fact, I hate it even with eclipse)
20:15michaeljaakayeah I know that
20:15michaeljaakagood IDE is a must have
20:15somnium`there's CEDET :)
20:16michaeljaakawell
20:16michaeljaakaif you try to program in dynamic language like python a middle sized program with 3 or 4 people
20:16michaeljaakait is also very hard
20:16defnI really want to learn more C
20:16the-kennyI never tried cedet
20:16michaeljaakareacaftoring is a nighmare
20:16KirinDaveThe sidebar aspect of cedet is cool.
20:16defnIt's hard for me to justify having seen the future with Clojure and such
20:17somnium`its kind of like eclipsemacs
20:17michaeljaakaI wonder if the same is for clojure
20:17defnthere's a project called eclim i believe
20:17defnwhich aims to integrate parts of eclipse into emacs
20:17KirinDavemichaeljaaka: The style of functional programming tends to make refactoring not-as-hard.
20:17_atoyou definitely need paren matching and auto indentation with Clojure
20:18_atobut you don't need the full blown IDE stuff
20:18KirinDaveYeah, paredit is a godsend
20:18_atoSLIME is nice to have, but optional
20:18the-kennyparedit ftw :)
20:18defnSLIME is too nice to not have
20:18defnIMHO
20:18KirinDavemichaeljaaka: The biggest pain really is when you change your nouns.
20:18KirinDavemichaeljaaka: That's why most common lisps make a functional abstraction over their structures, something Clojure doesn't really od.
20:18KirinDaveErr, do
20:18the-kenny(But I've seen some issues with paredit and {} and [])
20:18defnthe-kenny: that's an old issue IIRC
20:19defn}{ was a problem IIRC
20:19KirinDaveYeah, get a new paredit.
20:19defnbut not anymore
20:19the-kennydefn: No, it works fine except for M-{ or M-[
20:19defnah-ha, that's what it was
20:19the-kennyReally
20:19the-kenny?
20:20somnium`anyone tried ergoemacs?
20:20defnThat it's fixed?
20:20defnsomnium`: no
20:20the-kennyWow, I thoght I got the newest paredit
20:20KirinDaveI fixed my paredit long ago, but it's an old version I've been hacking on for years.
20:20_atoyeah... M-[ is undefined and M-{ jumps back a paragraph or something. I should override the bindings, that annoys me as well
20:20rlbI'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:21defnthe-kenny: M-[ works
20:21defnM-{ doesnt
20:21defnbut that just might be my ignorance of how to use it
20:21rlb:in (sysx "xargs" ...)))
20:21the-kennydefn: What's your paredit version?
20:21defnthe-kenny: i dont...know
20:22michaeljaakahmm is it possible in clojure to make behaviour like agent is reciving some data and yelds them as a sequence
20:22michaeljaakalazy sequence readed by someone else
20:22defnthe-kenny: paredit-20
20:22the-kennydefn: Okay, that's strange. I'm using 21
20:22michaeljaakaand once when codition readed agent ends sequnce?
20:22somnium`22
20:22defnthat is really strange :)
20:23_atomichaeljaaka: check out: http://clj-me.cgrand.net/2009/11/18/are-pipe-dreams-made-of-promises/
20:23rlbmichaeljaaka: not sure - if you just want to handle reading output from a process with buffering, but without blocking, you could use fill-queue.
20:23KirinDavemichaeljaaka: Check out http://clj-me.cgrand.net/2009/11/18/are-pipe-dreams-made-of-promises/
20:23_atoand also fill-queue in clojure.contrib.seq-utils
20:23KirinDave_ato: Oh shit, get out of my brain. :)
20:23_ato:D
20:23the-kennyM-[ is undefined in 22 too :(
20:24michaeljaakaoh
20:24the-kennyhm.. I'll hack it together
20:24michaeljaakathat is exactly what i need
20:24michaeljaakathe pipe
20:24michaeljaakafrom that blog
20:25KirinDaveYeah thats a beautiful piece of code.
20:25KirinDaveI must confess I do not entirely understand it.
20:25KirinDaveI need to stop clinging to my guns, religion, and clojure-1.0.0
20:26rlb(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:26michaeljaakahmm buf fill-queue may be also usefull
20:27rlb... (filter foo (sysx "xargs" "grep" "bar" ... :in (sysx "find" ...)))
20:31the-kennyhah awesome :) Hacking paredit is pleasing
20:39slashus2I 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_atoslashus2: I generally do this instead of -i: java -cp 'src:classes:lib/*' clojure.main -e "(use 'myproject.core) (main)"
20:44KirinDaveHum, I really like promise/deliver.
20:44slashus2_ato: I have a macro that refers to a var... doing the method that you just mentioned doesn't find the var.
20:45_atoslashus2: I suspect your macro is referring to the var in the wrong way then
20:45_atoif you pastebin it I'll take a look
20:46slashus2It worked fine before I wanted to do the circular reference stuff.
20:46_atoslashus2: what do you mean by circular reference? One namespace uses another which in turn uses the first?
20:47slashus2I have a function in one that uses a function in the other and the other way.
20:47_atoin the same namespace? then that should be fine. Just (declare other-fn) before the first one.
20:47slashus2different namespaces
20:48_atoin that case, import your namespaces with 'require' instead of 'use'
20:48_atoalso
20:48carkone way to do this is to pass your first function as a parameter tu the second function when you call it
20:48carkand remove the dependency
20:49_atoalso, don't start your program from the top-level. Have a main function instead
20:49slashus2The function is called from within a macro.
20:49carkso what ?
20:49carkor you could have a var in your second namespace, set it once the first function is defined
20:49carkset it to your first function i mean
20:50carkor you could use multimethods
20:50carkdefine a multimethod in your second namespace
20:50carkthen make an implementation of it in your first namespac
20:51carkthe possibilities are endless to fix this kind of trouble =)
20:51_atoyou 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:52carkthat's code smell you have here, it means you have a mistake in your design
20:52slashus2right
20:53carki'm being a bit harsh, sorry forget that
20:53carkusually when i see this in my code, that's because i didn't anticipate i needed a callback
20:55slashus2http://gist.github.com/244330
20:55slashus2cark: This is the macro that is probably causing all of the problems.
20:56slashus2Each of my plugins in my plugins folder is loaded. They all use this macro.
20:56slashus2Everytime it loads a plugin, I wanted it to add its doc info and name to a command list.
20:56slashus2every time*
20:56carki guess this plugin code is refered to from com.clojbot.clojbotcore
20:57slashus2I actually have this code in the com.clojbot.utilities namespace.
20:57slashus2I guess I should move it to clojbotcore..
20:58_atoyes, that'd probably be the simplest solution
20:58_atonormally your utils should be self-contained
20:58carki'd move it to a plugins namespace
20:58_atothey shouldn't rely on other parts of your program
20:58_atootherwise they're not really utilities
20:58slashus2I just put it there because conceptually it makes sense to me.
20:59carkand (def plugin-add-to-command-list (atom nil))
21:00slashus2cark: So set it off to the side and put it in the plugin's namespace?
21:00carkfrom core : (defn add-to-command-list ..... ) then (reset! plugin-add-to-command-list add-to-command-list)
21:00slashus2That is what my function does.
21:00slashus2in the core that is
21:00carkthen in your macro : ~(@plugin-add-to-commandl-list .....à
21:01carkthat's one way to do it
21:02carkanother way : don't make plugin-add-to-command-list an atom, but use a binding form when you actually load the plugins
21:02carkthough that wouldn't work
21:02slashus2I may come back later. I probably need to rethink my design. Thank you for your suggestions.
21:02_atoyeah. 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:02carkgood luck =)
21:03carkcoming from an oo language where you think a lot about events, it's hard to do what you say ato
21:04carklots of lower level stuff needs to callback anyways
21:04_atoright, but usually you should register callbacks somehow rather than having the lower layer call into the higher one directly
21:05carktrue
21:06_atoin 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:06carkahwell you have interfaces for this in java
21:06carkanonymous classes too
21:06_atoyeah
21:07carkquite the same, only the ceremony is different
22:13notallamaanyone 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:14JAS415hmm
22:14funkenblattflatland
22:14JAS415DEMONSAUCE
22:14derefedhow about
22:14derefednotalamegame2d
22:15funkenblattalso a good book
22:16JAS415idk
22:16JAS415i guess it depends on what type of 2d game engine it is
22:17JAS415is it like side scroller or 2 1/2 d (like starcraft or roguelike games) or something else
22:18rlbWhat's the clojure equivalent of (procedure? foo)?
22:19chouser,(ifn? (fn [] 123))
22:19clojurebottrue
22:19rlbahh, thanks.
22:19chouser,(ifn? {:a 1})
22:19clojurebottrue
22:20JAS415--- maybe flatjure
22:20notallamait'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:20JAS415oh wow
22:21notallamaso, sort of like love, but functional, i guess.
22:22rlb(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:23JAS415game engines must be challenging to name
22:28notallamai was thinking "peace" or "respect", since "love" and "unity" already exist. they're kindof generic and not so good for searches, though.
22:29JAS415well its love, but functional
22:29JAS415so some concatenation of that
22:29JAS415or throw in lambda, those are fun
22:30notallamais it considered code smell if your library doesn't have a j in the name?
22:30JAS415haha
22:30technomancynotallama: more of a "code aroma"
22:31JAS415i always thought that it was kind of weird that everything clojure ends up with a J in the name
22:31JAS415lovejure
22:31rlbSo, given a preceeding (in-ns 'clojure.contrib.shell-out), why can't the code see the "defn-" function parse-args?
22:31technomancyplease... we've had enough *jure or clo* names.
22:31JAS415:-)
22:31JAS415clove
22:32notallamai kindof like that one, actually. : p
22:32JAS415technomancy: agreed :-P
22:32rlbIs in-ns not viable if (while developing) you want to extend a namespace with new functions?
22:33technomancytime to start getting unique, like the guy on the mailing list who named his project "chlamydia"
22:34JAS415promiscuity
22:35JAS415its got a c and a u so its like clojure
22:36_msttechnomancy: possibly even more difficult to spell than leiningen :)
22:37rlboh, wait nevermind -- wrong directory.
22:38JAS415does anyone know of the top of their head if the pattern matcher in clojure-contrib matches in a nested manner?
22:41notallamamy sister suggested "schuhsenkel" (german for shoelace)
22:41JAS415cool
22:41JAS415will be easy to google for
22:42notallamaas long as you remember how to spell it : p
22:42technomancymy next project will be called Orestes, provided I can come up with code awesome enough to merit that title
22:42JAS415oh
22:44technomancyor possibly Thursday/Gabriel Syme if danlarkin does not use that name
22:50JAS415,(= :GET :get)
22:50clojurebotfalse
23:04dnolentechnomancy: is there anything special that needs to be done with lein to specify the library path JNIs when creating jars ?
23:08technomancydnolen: I don't really know anything about JNI.
23:09dnolentechnomancy: neither do I :) I imagine I'll figure this out eventually. One question tho...
23:09dnolenlein uberjar - does that use maven functionality or something to create the single jar?
23:10technomancyno, it's implemented in leiningen
23:10technomancywell, actually it used lancet in 0.5.0, but it's been refactored since
23:10dnolenok
23:11technomancyit's quite possible that there's no way to do JNI jars right now
23:11technomancyif so, please bring it up on the mailing list
23:12technomancyactually, bring it up either way; if it works we should document it
23:13dnolenasking in #java :D
23:14dnolennever stepped in there before