#clojure logs

2010-03-26

00:18phren0logycan anyone give me a hand with the most recent checkout of labrepl? It seems to have broken the swank server script.
03:08underdevis there an idiom for declaring that a function has side effects?
03:09underdevi have a whole set of functions that use the Robot class, and i would like to refactor them, and convey the fact that they are not pure
03:11Chousukewell, you can add a ! to the name
03:11noidiI think that's quite common
03:11noidithat's what I do, too
03:12noidiI think that comes from scheme http://www.rscheme.org/rs/b/0.7.3.3/21/doc/x162.html
03:12Chousukeit's not always done, though
03:12underdevokay, that will work fine
03:13Chousukeoften, documenting the side-effects is good enough
03:14underdevi'm trying to work my way up several layers of abstraction, and at some point i will no longer remember that foo contains side effects
03:14underdevi know me, and trust me, i won't keep track :)
03:15underdevwon't/can't...
03:24zmilaunderdev - you may use -se postfix or prefix for side-effect functions
03:24slyphoni thought the convention was to postfix w/ !
03:48taliosevening everyone
04:04LauJensenMorning all
04:12talios'lo
04:58gkohello
05:02talios'lo
05:13taliosgrr - (json-str) is escaping /'s when it outputs "http://xxx" - annoying.
05:16taliosaltho it looks like thats valid behaviour.
06:43zmilaso quiet for friday ...
06:47unfo-zmila, YOU LIEK THIS BETTAR THEN? ^^
06:51npoektopsorry. echo check
06:55mannicheHi Lau, thanks for your inspiring talk @DKUUG on clojure. Fortunately I'll have the entire Easter holiday to dive (more) into clojure.
06:55LauJensenmanniche: Hey - My pleasure, I'm glad you decided to try it out :)
07:13noididamn, Enclojure crashes with a NullPointerException when I try to create a new Clojure project
07:14noidieven upgrading to Netbeans 6.8 didn't help
07:14LauJensennoidi: check out my blog
07:14LauJensen~google Clojure IDEs the grand tour
07:14clojurebotFirst, out of 457 results is:
07:14clojurebotClojure IDEs — The Grand Tour | BEST IN CLASS
07:14clojurebothttp://www.bestinclass.dk/index.php/2010/03/clojure-ides-the-grand-tour-getting-started/
07:15LauJensenIn the very bottom you see 2 updates to the post explaining how to fix that
07:15noidiLauJensen, ah, you got that fixed
07:15LauJensenYes ma'am
07:15noidithanks
07:16noidiI decided to give a "real" IDE a try after years of Vim and Emacs, but the first impression wasn't too good :)
07:17LauJensenTrust me, it gets better than that NPE :)
07:17noidihehe
07:28noidiyay, updating the plugins seemed to fix the NPE for me
07:38noidiafter 10 minutes it's back to Emacs for me... too many widgets, too little source code -- I can't think in an environment like that! :)
07:39noidithe problem with being able to discover everything by looking at the app, is that you have to stare at everything all the time :P
07:44LauJensen10 minutes...hmm. I think you did good :)
09:26LauJensenIt constantly surprises me that Chrome doesn't accept C-x o to switch tabs
09:29SynrGLauJensen: C-PgUp, C-PgDn :)
09:29LauJensenSynrG: fine, but how do I get C-a C-k working in the adress line?
09:29SynrGthe whole world has not yet embraced emacs, and you're surprised?
09:30SynrGi don't even know what that does :p
09:30LauJensenMove to start of the line then kill line :)
09:31SynrGC-a C-x i guess. but now you've trashed your paste buffer. hmmm
09:32SynrGbut yeah, it's annoying when your "finger memory" of things doesn't transfer well from app to app
09:33SynrGhmm, C-a Backspace
09:42_2x2lnoidi: netbeans is crap. intellij is the only way to go for java. i duno about clojure since i use emacs, but don't let netbeans taint your idea of what a good ide does.
09:42_2x2li'd imagine intellij might be half decent for clojure, and eclipse is probably halfway decent too (though i bet has a huge memory footprint).
09:44fogus_2x21: "imagine"? "probably"? "bet"? Are you not familiar with those IDEs?
09:45callenfogus: it's the internet. uninformed conjecture based on gut feeling told around a campfire all the while Alan Kay is rolling in his grave. Questions?
09:45callentoo bad Alan Kay isn't dead :D
09:45callenmaybe he sleeps in a coffin.
09:45callenyeah, that's it. he rolls in his nightly coffin.
09:46foguscallen: Only one... where are my marshmallows? http://www.campo-ongo.org/pics/campfire.jpeg
09:46callenfogus: http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=the+hated+campfire
09:48zmila,(let [ [f & r] #{2 3 4}] [f r])
09:48clojurebotjava.lang.UnsupportedOperationException: nth not supported on this type: PersistentHashSet
09:49fogus,(let [ [f & r] (seq #{2 3 4})] [f r]) ; don't count on order
09:49clojurebot[2 (3 4)]
09:52zmilatĥ fogus! i see
09:52zmilathx
09:53bsteuberfogus: so why doesn't destructuring call seq for you? too inefficient?
09:53foguszmila: np
09:54fogus,[(seq [1]) (seq [])]
09:54clojurebot[(1) nil]
09:56noidicemerick, thanks for the interesting blog post and screencast! You convinced me to start reading the maven book :)
10:01fogusbsteuber: That's a good question
10:05fogusbsteuber: I suppose because that defeats the specificities of access per collection type
10:06fogus,(let [{x 1, y 2} #{1 2 3 4}] [x y])
10:06clojurebot[1 2]
10:07fogus,(let [{x 1, y 2} {1 2 3 4}] [x y])
10:07clojurebot[2 nil]
10:07fogus,(let [{x 1, y 2} [1 2 3 4]] [x y])
10:07clojurebot[2 3]
10:08fogus,(let [{x 1, y 2} (seq [1 2 3 4])] [x y])
10:08clojurebot[nil nil]
10:08zmila8-)
10:14cemericknoidi: good to hear :-) Feel free to ping me if you have any questions. Definitely check out the clojure-maven-plugin list http://groups.google.com/group/clojure-maven-plugin, and the #maven channel is also helpful.
10:20bsteuberfogus: ic, so map destructuring only works on IFn?
10:21bsteuberbut when I think it over, it makes sense for array destructuring to only work on sequential? stuff
10:21bsteuberas you can't rely on the order otherwise
10:36wthiddendoes doseq hold on its head?
10:36wthidden*to its head
10:36chouserhm, shouldn't.
10:37wthiddenif have a (doseq [k (range 0 100000000000000)] (func 'a 'b))
10:37wthiddenthat seems to run out of memory after 24 hours or so.
10:39wthiddenwhat about leakage with java udp sockets? Anything special other than closing them when I'm done?
10:41phren0logy has anyone been using stuart halloway's LabREPL from github?
10:42gfodorwhat exactly is it? the readme wasn't clear and I didn't pull it
10:43phren0logygfodor: It's a "lab" for learning clojure. But the more recent updates seem to have jacked up the slime server interaction.
10:43phren0logygfodor: It runs a web server with tutorials, and is supposed to set up a repl to try the exercises that have some libraries available
10:44gfodori see
10:44gfodorthx
10:44phren0logysure
10:44phren0logydo you use emacs?
10:44gfodorvimclojure for me
10:44lpetit,(let [{x 1, y 2} (seq [1 2 3 4])] [x y]) ; why couldn't it result in [2 nil] ?
10:44clojurebot[nil nil]
10:45phren0logyah. well I'm trying to trouble shoot why I can't get it to work, but I'm not having much luck. Check it out, you may have better luck.
10:50bsteuber,('(1 2 3 4) 1)
10:50clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn
10:50bsteuberlpetit: so seqs are not callable
10:51bsteuberphren0logy: I didn't get it to work with swank, be the shell repl and website were okay
10:51bsteuberlein deps did the job for me
10:51phren0logybsteuber
10:52phren0logyThanks. I had it working 2 days ago, but the recent updates seem to have broken it
10:52phren0logygood to know it's not just me, I wasn't sure if I broke something
10:53hiredmanlpetit: seqs are not indexed
10:53bsteuber,(let [[x y] (seq [1 2 3 4])] [x y]) ; but they are ordered
10:53clojurebot[1 2]
10:56lpetithiredman: yes, I understand that.
10:57lpetit,(*clojure-version*)
10:57clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: PersistentArrayMap
10:57lpetit,(clojure-version)
10:57clojurebot"1.1.0-master-SNAPSHOT"
11:18licoresseThere is assoc-in, get-in and update-in, is there a dissoc-in or a similar workaround?
11:20raekdissoc-in exists in clojure.contrib.core
11:20licoresseraek: thanks!
11:26stuartsierraWhat exactly does the &env special macro argument do?
11:27Chousukestuartsierra: it contains the locals expansion environment I think
11:27Chousukelocals of the*
11:28chouserstuartsierra: gives you a map where the keys are the symbols of all the locals at the point where the macro is being expanded.
11:28stuartsierraBut not their values, it seems.
11:28chousertheir values aren't known at compile time. :-)
11:28chouserer, at macro-expand time.
11:28stuartsierraWell, they could be in the case of (let [x 1] ...) but I see the point.
11:28chouserthe values in the map are Compiler$Something objects, which I expect will change
11:28stuartsierraok
11:29stuartsierraSo basically &env lets a macro inspect its lexical context.
11:30chouseryes
11:30stuartsierraok, thanks
11:32chouserthe value is a Compiler$LocalBinding, which has fields like .isArg (true if it's a fn arg instead of a let-local), .init (a Compiler expression of the analyzed init value, like perhaps a Compiler$ConstantExpr, .tag, etc.)
11:32stuartsierrahm, ok
11:32chouserbut like I said, I think that will change to something a bit more transparent with ccinc
11:32stuartsierraright
11:32stuartsierraccinc needs a better name
11:32chouserfor now all I've been able to use &env for is to collect metadata from the local symbol itself.
11:32stuartsierraLike "nirvana"
11:33chouser(let [#^{:my :meta} i 5] ... (foo i ...))
11:33stuartsierrachouser: yes, that makes sense
11:34chouserwhere foo is a macro that at macro-expand time looks up its arg i in &env to find the let's i and from there gets at :my :meta
11:34drewro_O
11:36chouser(defmacro foo [local etc] (let [[orig-local _] (find &env local), my-meta (meta orig-local)] ...))
11:36licoresseone problem with dissoc-in is that it removes the whole branch, and not only the last leaf
11:39licoresseI have a {:upper {5 #{:d}, 15 #{:d} :lower {20 #{:x}} when dissoc -in [:lower 20] I end up with {:upper {5 #{:d}, 15 #{:d}} what I would like is {:upper {5 #{:d}, 15 #{:d} :lower {}}
11:39licoresseI don't know if this makes any sense to you guys
11:40licoresseeverything here is in a (dosync (alter ...)
11:41drewrlicoresse: I'm following you, and I think I agree
11:41licoressedrewr: :) guess a private rewrite of dissoc-in should solve it (?)
11:42drewrwhere is dissoc-in defined?
11:42Chousuke,(dissoc {:a 5} :a)
11:42clojurebot{}
11:42licoressecontrib.core
11:43licoressemy brain is kind of blasted after 5 days of clojure fun
11:44ChousukeI suppose you can do (update-in [:lower] dissoc 20) as a workaround
11:45licoresseChousuke: I'll give it a try...
11:46Chousukebut I think the asymmetry of dissoc-in with dissoc can be considered a bug
11:46licoresseChousuke: great, that works!
11:47licoressewondering why dissoc-in is in contrib and not in core?
11:48ChousukeProbably because Rich never needed it, and no-one has proposed adding it to core :)
11:48licoresseah, the benevolent dictator
11:48chouserI'm not sure how often removing the whole branch is desirable
11:49licoressejust kidding
11:56drewrfwiw, I've only ever needed update-in
11:57drewrand get-in occasionally
11:57chouserI tend to use -> instead of get-in
11:57drewrchouser++
11:58AWizzArd,(doc get-in)
11:58clojurebot"([m ks]); returns the value in a nested associative structure, where ks is a sequence of keys"
12:00AWizzArdHmm yes, I also used -> instead of get-in, but on the other hand get-in better documents the code.
12:00drewrwouldn't -?> be better than ->? (wow, that's confusing)
12:01AWizzArd,(doc -?>)
12:01clojurebotNo entiendo
12:01drewrno, drewr, get-in handles nil just fine
12:02chouserso does -> when all you're using are keywords
12:02drewrah, true
12:11lithprbegun the tweet wars about learning java has!
12:12nosswhat happens on twitter stays on twitter
12:12AWizzArdchouser: yes, it is clear what -> does, but get-in can be grepped for, and it is more specific. I find that more specific functions document the code better.
12:41rrc7cz-hmare there any tricks which allow keywords to have metadata?
12:44drewrrrc7cz-hm: what would you like to accomplish?
12:44drewra keyword is a named constant; metadata seems orthogonal
12:45rrc7cz-hmdrewr: I have nested map structures where they keys are keywords. Since they are nested, there is a sort of coordinate system based on keys. For example [:foo :bar] identifies 3 in {:foo {:bar 3}}, much like the zipper fns
12:46rrc7cz-hmdrewr: these maps represent product configurations. I'd like to add metadata to certain coordinates so that the system can identify whether it's visible or not
12:46rrc7cz-hmfor example
12:47stuartsierra,(identical? :foo :foo)
12:47clojurebottrue
12:47rrc7cz-hmI could, of course, simply add a :visible true entry to the relevant coordinate, but visibility really has nothing to do with a product configuration; it's metadata the system would use
12:47stuartsierraKeywords are singletons.
12:47raektwo keywords with the same name are always the same instance
12:48rrc7cz-hmstuartsierra: what about namespaced keywords
12:48drewrrrc7cz-hm: why not add meta to the coordinate map?
12:48drewre.g., (with-meta {:foo {:bar 3}} {[:foo :bar] :visible})
12:48rrc7cz-hm,(identical? ::foo ::foo)
12:48clojurebottrue
12:48rrc7cz-hmwell, in the same ns
12:48raekrrc7cz-hm: you could use [:foo :bar] as a key and add metadata to that
12:49rrc7cz-hmdrewr: that's my backup plan, but it's not as nice. I'd basically have a map's metadata shadowing the entire structure of the map itself
12:50drewrit seems better to me because now you have an attribute tied to an exact coordinate instead of on :foo or :bar (but maybe that's what you want)
12:50drewrthose vector keys are really useful too with update-in/get-in
12:51drewrthe other option is to not bother with the nested map and just use the meta
12:51drewr{[:foo :bar] {:visible true :val 3}} or some such
12:51rrc7cz-hmraek: I would, but I'm loading directly from couchdb, which only supports assoc arrays (no complex types as keys). I could make the translation, it would just be more work
12:52rrc7cz-hmthe vec as key is a pretty nice option. I'll just have to do a bit more translating
12:54rrc7cz-hmI'm also wondering if somebody can explain how fn equality is done
12:54rrc7cz-hm,(= range range)
12:54clojurebottrue
12:55hiredmanrrc7cz-hm: I think it's just reference equality
12:55rrc7cz-hm,(= #(range %) #(range %))
12:55clojurebotfalse
12:55rrc7cz-hmokay
12:55hiredman,(identical? range range)
12:55clojurebottrue
12:55hiredman,(identical? #(range %) #(range %))
12:55clojurebotfalse
12:59drewr,#(range %)
12:59clojurebot#<sandbox$eval__4265$fn__4267 sandbox$eval__4265$fn__4267@8690e3>
12:59drewr,#(range %)
12:59clojurebot#<sandbox$eval__4272$fn__4274 sandbox$eval__4272$fn__4274@11aed03>
12:59drewr,range
12:59clojurebot#<core$range__5186 clojure.core$range__5186@8634b6>
12:59drewr,range
12:59clojurebot#<core$range__5186 clojure.core$range__5186@8634b6>
13:00drewrrrc7cz-hm: #(..) creates a new, separate lambda each time
13:00rrc7cz-hmJust out of curiosity, what kind of issues might you run in to trying to build a logical equality operator for fns?
13:00drewrwhereas range is a Var that points to the range function
13:00rrc7cz-hmI mean, since they're just lists, wouldn't it be fairly straightforward?
13:02TalkingHeadI have a function that populates a struct, but I'm having trouble getting the struct as my return value...
13:03TalkingHeadfrom-s (geo-code from "AFRICA")
13:03TalkingHead(defstruct map-point :name :country :latitude :longitude)
13:03TalkingHeadand then geo-code populates something like this:
13:03TalkingHead(struct map-point n m lat lon )])
13:05thelatemrbquit
13:05drewrTalkingHead: paste the code
13:05drewr(not in here)
13:10TalkingHeaddrewr: http://gist.github.com/345121
13:12slyphontechnomancy: hey, i'm having a problem with AOT compilation, it seems fairly difficult to compile a bunch of custom exceptions defined with gen-class for use in other parts of my app
13:13slyphonit barfs telling me that those classes couldn't be found while i'm trying to compile those classes
13:13slyphonoh, ffs
13:14slyphonnvm, it was my "user.clj" file, i thought that only got sourced when running the REPL
13:15ipostelnikTalkingHead, (prn s) returns nil
13:16ipostelnikTalkingHead, you can do (let [s ....] (prn s) s)
13:16drewrTalkingHead: you're returning the value of doseq from geo-code, which is always nil
13:16TalkingHeadaha, thx
13:43alexyk,(map (fn [a b] [a b]) [1 2 3] (iterate inc 0))
13:43clojurebot([1 0] [2 1] [3 2])
13:43alexykis there a shorter way to write the fn?
13:44Chousukemap vector
13:45alexykha
13:45alexykcool
13:49jcromartieOK so this is pretty much awesome
13:49jcromartie(Thread. #(loop [chars (cycle "|/-\\")] (print "\r" (first chars)) (.flush *out*) (Thread/sleep 100) (recur (rest chars))))
13:50jcromartieif you find yourself in need of an ASCII-art spinner
14:56licoresseWhat is the difference between :require and :use in ns?
14:58licoressenever mind: http://stackoverflow.com/questions/871997/use-vs-require-in-clojure
15:04licoresseargh
15:04licoresseNo such var: sel/composite-selection
15:04licoresse [Thrown class java.lang.Exception]
15:06licoresseI am (ns ... (:use [something.whatever :as sel])) in the module, but it responds with this ^
15:06licoresseEverything worked a couple of minutes ago
15:06licoressenow, everywhere where I am using sel/composite-selection the compiler complains
15:07licoresse(def composite-selection ....)
15:16slyphontechnomancy: hey, i'm having a real hard time with AOT compilation and running swank
15:18licoresseI needed to (use '....) at the repl, then it worked again
15:18licoressethats hogwash
15:19licoressetrying to restart emacs to see if I can reproduce
15:23slyphonARRGH
15:24licoressehehe
15:24licoresseI know the feeling
15:25licoresserunning swank-clojure-project solves everything, only problems with lein swank
15:25licoresseor better; my lack of understanding
16:24slyphondoh! you can't attach metadata to java objects?
16:24slyphonlame!
16:24chouserheh. where would just metadata be stored?
16:24slyphonthat's someone else's problem!
16:24slyphon:D
16:25chouser:-)
16:25slyphonchouser: i'm looking at error-kit
16:25chouserhas to derive from IObj or IMeta to support metadata
16:25chouserslyphon: oh yeah? and what are you thinking?
16:25chouserare you thinking "what was he thinking!?"
16:25slyphonthe reason i was thinking the above because i was like "Oh, i'll just attach some metadata to a RuntimeException instance..."
16:25slyphonno, i understand what you were thinking
16:26chouserbecause I think that's what I think when I think about error-kit
16:26slyphonhahahahahah
16:26slyphonit's a little convoluted
16:26chouseryes
16:26chousertoo convoluted
16:26slyphonvery CL-ey
16:26slyphonbut
16:26chouserin a lot of cases contrib's condition is all you need
16:26clojurebotCL conditions is http://www.gigamonkeys.com/book/beyond-exception-handling-conditions-and-restarts.html
16:26chouserperfect for attaching a little extra data to an exception
16:27slyphonthe problem i've been having is that i can't seem to get clojure to "see" the AOT compiled Exception subclasses i make
16:27slyphonhmm
16:27slyphonyeah, i looked at that as well, and was similarly baffled
16:29chouserrhickey has said error-kit confuses him so that's, you know, a bad sign.
16:29slyphonhahahahah
16:29slyphonwell, it seems like you're implementing custom stack-unwinding or something
16:29chouseryes, in error-kit
16:30slyphonok, i just wanted to make sure i kind of grokked what was goin' on
16:30chouserbut that's only half the problem. It has a little object system in there that is ill-conceived.
16:30slyphonheh
16:31chouserbasically, error-kit is a fairly thoughtless attempt to support CL conditions in Clojure, plus an extra feature or two just because they were easy to add.
16:31slyphon:)
16:32slyphonhrm
16:33slyphonahhh
16:33slyphonok, so Condition is a Throwable that implements IMeta
16:35slyphonhmm
16:36slyphonchouser: who would i submit a doc-string patch to?
16:36slyphoni think some of the condition docs could be a little more clear
16:40technomancyslyphon: in general I'd suggest sticking with Exceptions if you're having AOT trouble with custom classes
16:40slyphonyeah, i think i was just doing it wrong
16:40technomancythen go back and replace them with your custom exceptions once you've got a better handle on things
16:41technomancyunnecessary AOT can be a huge time sink
16:41slyphoni wasn't 100% aware that you had to make a foo/MyException.clj for (ns foo.MyException {:gen-class :extends Throwable})
16:41slyphoni was trying to put multiple (ns) forms in a single file
16:42technomancyaha
16:42clojurebotPaul Graham is the creator of the other new lisp
16:42slyphonwhich is fail
16:42technomancygen-class for reasons other than -main and java interop is pretty suspect
16:42slyphonbut, i'm thinkin' ill just give clojure.contrib.condition a shot
16:45hiredmanslyphon: the problem there is the ns form, not gen-class
16:45hiredmanI would look at using gen-class directly
16:46slyphonah
16:46slyphonok, that makes sense
16:47hiredmanhttp://gist.github.com/34229 from the dawn of time
16:47slyphonoooh
16:47slyphoninteresting
16:47hiredmanyou still have to aot compile
16:58slyphonit'd be nice if there were some variant of (ns (:require [foo.bar [baz :as baz]])) to get rid of the repetition
16:58slyphonunless there is one that i just don't know about
17:01LauJensenWhats the fn to check if what Im holding is a primitive?
17:05technomancyslyphon: there's talk of adding that; someone has started prototyping it
17:05slyphonah, cool
17:05slyphonyeah, i find myself doing that *a lot*
17:05technomancysee the "ns overhaul" thread on the clojure-dev list
17:05slyphonah, cool
17:06chouserLauJensen: repl-utils expression-info
17:07slyphondo people generally just use clojure.test ?
17:07technomancyslyphon: unless you're the author of one of the competing frameworks, you're probably using clojure.test
17:07slyphon:)
17:08slyphonare any of the other competinf frameworks any good/worth checking out?
17:08slyphoncompeting* even
17:08LauJensenchouser: thanks
17:08technomancyslyphon: not yet, unless you're interested in contributing
17:09slyphonah
17:09chouserLauJensen: not it operates on forms (like macroexpand) not on return values
17:09slyphonthanks, i have enough of my own shitty code to contend with :)
17:09LauJensenchouser: Would be easier if I could check returns, any way to do that?
17:10alexyk,(map (fn [x] [x 1]) [1 2 3]) ; this works
17:10clojurebot([1 1] [2 1] [3 1])
17:10alexyk,(map (fn #([% ]) [1 2 3]) ; this doesn't -- why?
17:10clojurebotEOF while reading
17:10alexyk,(map (fn #([% ]) [1 2 3]))
17:10clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
17:10slyphonum
17:11alexyki.e., hod do we do #([% 1]) right with %?
17:11alexykhow
17:11slyphon(vec %) ?
17:13alexykI need to return new vectors of two elements, first from the original, second fixed -- here it's 1
17:13alexyksame behavior as (map (fn [x] [x 1]) [1 2 3])
17:13alexyki.e. the question is to rewrite (fn [x] [x 1]) with #(...%...)
17:14slyphon,(map #(vec (list % 1)) [1 2 3])
17:14clojurebot([1 1] [2 1] [3 1])
17:15alexykah,
17:15alexyk,(map #(vector % 1) [1 2 3])
17:15clojurebot([1 1] [2 1] [3 1])
17:15slyphonthat too :)
17:17chouserLauJensen: well, that's a problem since functions only return boxed things.
17:18LauJensenchouser: You mean rich has to provide a special form... *hint* *hint*
17:32licoresse,(map vector '1 [1 2 3])
17:32clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer
17:32licoresse,(map vector [1] [1 2 3])
17:32clojurebot([1 1])
17:32hiredmanyou have to use repeat
17:32licoresse,(map vector (repeat 1) [1 2 3])
17:32clojurebot([1 1] [1 2] [1 3])
17:32licoresseright
17:33chouserLauJensen: you should be able to use a debugger to see what the type of a local is -- primitive or otherwise
17:33alexykgood good
17:33LauJensenchouser: Yea, but this is really an area where I hope Clojure improves rapidly. The lack of reflection warnings and insight into boxing is making optimizing a very tough job
17:36RaynesLicenser: ping
17:36LicenserRaynes: pong
17:36RaynesLicenser: Was there a particular reason that 'def' was whitelisted?
17:36RaynesSeems like something one should whitelist themselves if they need it.
17:36RaynesBecause it can pollute the namespace.
17:38LicenserRaynes: It was in the lists, not in the whitelist, I guess it slipped in when we went from multiple vars to a map
17:38RaynesAh. It was in variable-fns. I removed it last night.
17:38slyphontechnomancy: if i want leiningen to compile clojure.contrib.condition.Condition, do i put :namespaces [c.c.c.C] or [c.c.c] ?
17:39RaynesAs a matter of fact, it is all that was in variable-fns. :p
17:39Licenserheh
17:39RaynesWhen I get some time, I'll go through the entire Clojure API and add stuff. I've been busy over the last couple of days.
17:41slyphontechnomancy: i have :namespaces [clojure.contrib.condition.Condition], but lein compile says "all :namespaces already compiled", but i look in classes/ and the Condition.class file isn't there
17:44technomancyslyphon: contrib should be AOT'd for you; no need to do it yourself
17:44slyphonoh
17:44slyphonduh
17:44slyphontechnomancy: i'm sorry, i'm not normally this retarded
17:45licoressehow was that :keys destructuring again?
17:47technomancyslyphon: happens to everyone at some point
17:47slyphonyeah, must be early-onset stupidity
18:02Raynes,(doc "blah")
18:02clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Symbol
18:02RaynesIs there a way to turn a string into what doc can take?
18:02Raynes,(doc (symbol "blah")) ; obviously doesn't work.
18:02clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol
18:06LicenserRaynes: find-doc
18:06Licenser,(find-doc "bla")
18:06clojurebot------------------------- hiredman.clojurebot.core/inits ([[f & r :as c]]) again I blame Chouser ------------------------- hiredman.clojurebot.factoids/inits ([[f & r :as c]]) again I blame Chouser
18:07Licenserwhat?
18:07clojurebotwhat is short for ,(doc ...)
18:07defnhi all
18:07Raynesfind-doc wont work in this situation.
18:07RaynesBecause it can return more than one result.
18:09Licenserkk
18:09slyphonit would be nice if there were a way of having some "standard" group of things that you want to use in all your namespaces
18:10RaynesHrm.
18:10slyphonlike clojure.contrib.logging
18:11technomancyslyphon: http://onclojure.com/2010/02/17/managing-namespaces/
18:11slyphonooh
18:11slyphontechnomancy: ty
18:11technomancyit's a little rough, but looks promising
18:11technomancyI've wanted something like that too
18:12slyphonyah, i was thinking of setting up a macro i can just call by default in each namespace
18:12slyphonthat would live in one location
18:17RaynesEh, looks like hiredman write a cryptic macro to work around this little issue.
18:18slyphonRaynes: link?
18:19Rayneshttp://github.com/hiredman/clojurebot/blob/master/src/hiredman/sandbox.clj#L93
18:20RaynesYeah. I miss the old doc that took a string.
18:20RaynesIt should have been moved to doc-string or something.
18:20slyphonyou could probalby use (eval) for that no?
18:20slyphonor write a macro?
18:21LicenserRaynes: thanks for adding the additional functions :)
18:21slyphonnah, you'd need eval i think
18:21RaynesLicenser: Why isn't doc whitelistable again?
18:22Licenserhmm most likely because I forgot it
18:22RaynesIt doesn't seem to work even if you whitelist it.
18:23RaynesLicenser: Nope, just confirmed. It doesn't allow it even if it's whitelisted.
18:24LicenserRaynes: ah because it is an macro then
18:24Licenser,(macroexpand '(doc "doc"))
18:24clojurebot(let* [m__1734__auto__ (clojure.core/meta (clojure.core/resolve (quote "doc"))) al__1735__auto__ (:arglists m__1734__auto__) docstring__1736__auto__ (:doc m__1734__auto__)] (if m__1734__auto__ (.replaceAll (clojure.core/str al__1735__auto__ "; " docstring__1736__auto__) "\\s+" " ") (clojure.core/-> hiredman.clojurebot.code-lookup/contrib :vars ((clojure.core/partial clojure.core/filter (clojure.core/fn [a__1737__auto__] (c
18:24Licenseroi I'm not sure if whitelisting resolve is good,
18:24RaynesLicenser: That's hiredman's special doc. Doesn't count.
18:24Licenseror meta
18:24Licenserah okay
18:24RaynesLicenser: Try doing it in your own REPL.
18:25Licenserbecause the function si called print-doc?
18:25RaynesApparently so. :o
18:25Licenserheh
18:26RaynesKay.
18:26defnany fun ideas for obfuscated clojure?
18:26RaynesLot's of commas.
18:26defn:)
18:27RaynesLicenser: I'll add print-doc to the whitelist later.
18:28defn,`@#'f
18:28clojurebot(clojure.core/deref (var sandbox/f))
18:30defn,`~*
18:30clojurebot#<core$_STAR___4526 clojure.core$_STAR___4526@1ab5fd5>
18:31defn,`~'@*
18:31clojurebot(clojure.core/deref *)
18:31defnthat could be ugly
18:35licoresseHow can I create an array of floats in Clojure? Tried (into-array Float [10.0 20.0])
18:36licoresseYes, I'm a java noob
18:36defn,(doc float-array)
18:36clojurebot"([size-or-seq] [size init-val-or-seq]); Creates an array of floats"
18:37licoressethanks defn
18:37hiredmanhiredman.clojurebot.code-lookup/contrib is broken
18:37hiredman:/
18:37defnlicoresse: I think there's a way to use into-array like you're doing above, but it needs to be Float/something for the type IIRC
18:37hiredmanreplaca_: the vars stuff in the json is empty
18:39defnlicoresse: you could do this:
18:39defn,(into-array (map float [1.0 2.0 3.0]))
18:39clojurebot#<Float[] [Ljava.lang.Float;@129f6e7>
18:42licoressedefn: that won't do it for BasicStroke
18:42licoressethe float-array works swell
18:44defn(floats (float-array [1 2 3]))
18:44defn,(floats (float-array [1 2 3]))
18:44clojurebot#<float[] [F@8e4ea6>
18:44defnlicoresse: i was curious -- that's from chouser awhile back
18:45licoressewhy cast it to floats first?
18:46licoresse(float-array [1 2 3])
18:46licoresse,(float-array [1 2 3])
18:46clojurebot#<float[] [F@fb241d>
18:49hiredmanfloats is for if you are using let in an inner loop and want to avoid array reflection
18:53licoresseI see
19:01Raynes,(let [x 3] (let [x (+ x 5)] (println x)))
19:01clojurebot8
19:02RaynesThat isn't cute.
19:06alexykRaynes: did you expect 2010?
19:07alexykRaynes: btw, rename clojure-casual to clojure-cajual
19:07alexyk...snd serve some cajun food
19:07alexykthere
19:07Raynesalexyk: No, I expected it to be like Haskell and not allow me to do that. :p
19:07RaynesAnd, psykotic didn't like the idea of cajual.
19:09hiredman,(let [x 3 x (+ x 5)] x)
19:09clojurebot8
19:09alexykso, nested x is not rebinding the outer, it's shadowing it, so all is cool, no?
19:09alexykand hiredman actually redefines it
19:09alexykso what, it's expected
19:10alexykif Haskell doesn't like it, -- deal with it, Haskell!
19:10RaynesI didn't expect it. Haskell assumptions.
19:10slyphonhas 1.2 been released yet?
19:10alexyk"Clojure: rebinding Haskell's mama"
19:10joshua-choislyphon: I don't think so
19:10slyphonbummer
19:11alexykhow do you slurp now?
19:12joshua-choiI mean, like (fn [first-arg & rest-args] ...)
19:12alexykah ok
19:12joshua-choihttp://github.com/richhickey/clojure/commit/29389970bcd41998359681d9a4a20ee391a1e07c
19:14alexyknice
19:14joshua-choiQuestion: how can you check if an object can turn into a sequence, i.e. if (seq x) will not throw an Exception?
19:15joshua-choialexyk: Yeah, that will have ramifications. It seems to me that proper named arguments are now possible in the vector arg itself
19:15chouserthere's not a particularly good way I guess because it's considered an inappropriate question.
19:16joshua-choiWell, there's ifn?.
19:16joshua-choiI want something like ifn? for sequences for a precondition.
19:17chousera precondition will throw if it fails anyway, right? so why not just use 'seq'?
19:17joshua-choiOh, right
19:17joshua-choiOf course
19:22joshua-choiWell, actually, I don't want that
19:23joshua-choiI'd like specifically an assertion error thrown, like any other precondition. If I just use {:pre #{(seq x)}}, then it won't give as useful of a message
19:24joshua-choiBut is there really no other way than to do (isa? (type x) clojure.lang.Seqable)?
19:27chouserwell, seq works on Strings but String is final and doesn't implement Seqable
19:28chouserthere's a 'seqable?' in contrib somewhere, but it has always struck me as a bit fragile.
19:30slyphonwow
19:30slyphonthe namespace stuff is hairy
19:31slyphoni'd love to use something like http://code.google.com/p/clj-nstools/ but my project is using clojure-1.1
19:32joshua-choichouser: I didn't know that String didn't implement Seqable. Although in retrospect that's obvious. clojure.contrib.core/seqable? would be what I want, although its source code does seem to be fragile. I wish there was a better way.
19:54joshua-choiIs there a core/contrib function that tests if one integer divides another? Yeah, I know I can just do (zero? (mod x y))...
19:55programble(defn divisible [x y] (zero? (mod x y)))
19:56joshua-choiprogramble: Sorry, I meant, "Is there a standard function in clojure.core or .contrib?"
19:57programble...
19:57programble(defn divisible [x y] (zero? (mod x y)))
20:02_atoI doubt it
20:02ag90(mod x 0) will kill that one. Need a check for that too.
20:11alexykliebke: is there any clustering in incanter, like k-means?
20:14defnliebke: I'm having some issues getting charts to display on Ubuntu 9.10
20:14liebkealexyk: not yet
20:14liebkedefn: what's the error?
20:15alexykkk
20:18defnliebke: the window comes up, but it's just empty -- the same code works on OSX
20:20liebkedefn: hmm, no idea
20:20defnvery weird
20:21liebketrue
20:21defnsun-awt-x11-XFramePeer is the classname of the window
20:21defnI could give you the #<ChartFrame...> in a PM if you'd like
20:28robinkDo I need to call Java's sin function to caluclate a sine in clojure?
20:48joshua-choiI'm wondering: is there a particular reason why there are no def-, defmacro-, defmulti-, or deftype- macros in clojure.core? Is hiding vars looked down upon?
20:59defnI'm trying to sort a vector of maps by a key in each map
20:59slyphonsort-by ?
21:00defn[{:foo 4 :bar 8} {:foo 7 :bar 5}] => (when sorting on :bar) => [{:foo 7 :bar 5}...]
21:01defnslyphon: how would i use sort-by there?
21:01slyphon(sort-by :bar [{:foo 1 :bar 7} {:foo 2 :bar 3}])
21:01defnhmm, i dont think that works on the vector
21:01slyphon,(sort-by :bar [{:foo 1 :bar 7} {:foo 2 :bar 3}])
21:01clojurebot({:foo 2, :bar 3} {:foo 1, :bar 7})
21:01defnhuh, nevermind
21:06defnthanks slyphon
21:06slyphonsure
21:10robinkOK, so it's in clojure-contrib
21:10robinkHow do I force clojure to include Clojure-contrib's set of functions?
21:10robinkIt's installed in /opt/local/share/clojure/lib, but clojure isn't loading it upon startup.
21:11robink/opt/local/share/clojure/lib/clojure.jar is present in that location, but it won't touch other .jars in the same directory.
21:11slyphonyou have to add them to your classpath?
21:12robinkslyphon: Tried that.
21:12slyphonyou have to explicitly require those libraries
21:12slyphonimport names from them into your namespace
21:12robink(ns user (:require [clojure.contrib.generic.math-functions :as generic))?
21:12lithprrobink: to answer this, and all subsequent similar questions, you'll need to learn about namespaces (use require refer import)
21:13lithpras you apparently have :)
21:13robinkSays it can't find clojure/contrib/generic/math_functions__init.class or clojure/contrib/generic/math_functions.clj
21:13robinklithpr: I'll learn more about namespaces.
21:15robinklithpr: What's a good reference?
21:17lithpruhm, the most concise summary i've found was in labrepl
21:17robinklithpr: Thanks
21:18robinklithpr: In the labrepl source?
21:19lithprwhen you start labrepl it uses jetty to serve the lessons from localhost
21:19robinklithpr: Ah, OK
21:19lithprso that's a lot of work to get the info
21:19robinkIndeed
21:20lithpr(ns user (:use clojure.contrib.generic.math-functions)) returns without objection in my set up
21:21robinklithpr: Doesn't work for me, something's wrong with my setup.
21:21robinklithpr: Clojure was very recently added to MacPorts, they may not have everything set up the way it should be.
21:21lithproic
21:22robinkLemme try from Gentoo
21:22robinkReturns in Gentoo :(
21:23robinkand the library location is less sane in Gentoo
21:23lithprubuntu here, so i'm no help with the mac
21:24robinkI explicitly set CLASSPATH to point to the clojure-contrib.jar and it fails
21:24lithprnever realized macs used ports... its bsd though...
21:24robinkYeah, essentially
21:25robinkMacPorts is a "distro" for OSX, it's not really part of the OS.
21:25robinkI could install Gentoo Prefix (which I may do, if I can't hammer this one out)
21:25robinkAdvantage of MacPorts is that it relies on the system libc so there's less memory usage etc
21:25robinkGentoo Prefix pulls the whole userland in
21:26lithprneat
21:26robinkI s'pose
21:27lithprevery single other member of the Pittsburgh clojure meetup had a mac...
21:27robinkHah
21:27robinkI was the only person at the Seajure meeting with a Mac.
21:27robinkWell, Brian had one, but he didn't take it out IIRC.
21:29robinkI should've attended the first Seajure meeting.
21:30robinkThere had to have been someone with a mac there.
21:31lithprhave you tried using a lein based install?
21:31defnwoo hoo! pretty graphs in incanter. this is starting to get really fun now :)
21:32lithprdefn: yeah, made one yesterday going through the labrepl labs. never played with it before. pretty slick...
21:33lithpralso never realized that the letter p is second only to s as the first letter of words in english :)
21:33defnhehe
21:34sattvikrobink: Are you still having the problem with Clojure-contrib?
21:41lithprrobink: you might consider using lein & swank clojure. If sets up a clojure and clojure contrib (and whatever) on a per project basis, and handles the classpath issues. never really appreciated the fact that i haven't experienced classpath hell since moving to clojure...
21:47phren0logyis anybody else having problems connecting to the swank server that's supposed to be started by LabREPL?
21:47lithpri didn't have a problem with it
21:48lithprare you in the right pwd when you start it?
21:50lithprfyi, in emacs, once you are in the right dir and M-x inferior-lisp, you can subsequently M-x slime-connect, and use it from slime
21:50lithpri know nothing of inferior-lisp mode, but i'm loving the slime-mode buffer/slime-repl clojure combo
21:50phren0logyyeah, I start it from the labrepl directory with script/swank (on ox X)
21:50phren0logyer, os x
21:51lithprare you getting an error?
21:51phren0logyit fires up the web server, but I get an error when I M-x slime-connect
21:51phren0logysaying there's nothing on socket 4005
21:51phren0logyand I can connect when I fire up swank from incanter
21:52phren0logyso I'm not sure what's up
21:53lithprhuh. 127.0.0.1/4005 is happy here.
21:53phren0logyis there any way to force lein to re-download all the dependencies?
21:54phren0logyIt starts, and I get the web server and I repl prompt in the terminal, just no swank server
21:54phren0logywhat platform are you on, and are you using the most recent version of labrepl? One of the updates seems to have broken mine, unless that was just coincidence.
21:55lithprubuntu 9.10, labrepl as of two days ago.
21:56lithprnot sure where i'd find a version number
21:56phren0logyWell, I don't want you to break yours, but if you try git pull let me know if it screws up.
21:56phren0logyI get: Debugger entered--Lisp error: (file-error "make client process failed" "Connection refused" :name "SLIME Lisp" :buffer nil :host "127.0.0.1" :service 4005)
21:57phren0logyTo get a version, try "git log" from the labrepl directory
21:57phren0logy(if you cloned the git repo)
21:58lithpryeah, i cheated. i just downloaded it as a tar.gz. kinda a hg man...
21:58phren0logythe most recent commit's SHA1 starts with db97156, with the commit message "reorg README"
21:58phren0logyAh. Ok, cool. Thanks anyway.
22:00lithpr"relevance-labrepl-e978d2e"
22:02phren0logylithpr: OK, cool, that seems to be before a change to the startup script
22:02phren0logyI'll roll mine back
22:06phren0logylithpr: That fixed it, thanks.
22:07phren0logyI'm sure hg does pretty much the same thing, but "git checkout e978d2e" took me right to it. DVCS is awesome.
22:13lithprno git hatred here, just ignorance.
22:13lithprseems like clojure, like ruby, prefers git, so i'm going to have to improve that situation
22:14lithprthe guys on FLOSS weekly seem to be enthusiastic about it too
22:17phren0logylithpr: I really haven't picked a side, it's just that all the cools stuff is on github. At a glance, hg actually seems much more humane and sensible.
22:20lithprphren0logy: is it working for you now?
22:22phren0logylithpr: yes, it's working great
22:23lithprcool
22:24robinklithpr: How can I examine the contents of the Java CLASSPATH to see if Java can get at clojure-contrib?
22:24robinklithpr: I don't know if this is a problem with Java, MacPorts or somehow my build of Clojure.
22:25somnium(System/getProperty "java.class.path")
22:26robinksomnium: Thanks
22:26robinksomnium: Can I examine Clojure jars with Java?
22:26somniumrobink: not sure what you mean
22:27robinksomnium: Maybe I don't either
22:27robinksomnium: OK, so the only thing in the CLASSPATH is clojure.jar
22:27robinkThat's a start
22:27phren0logyrobink: I have been using homebrew, and I installed leiningen with it. It has been working very well for me. Just something to consider if MacPorts is giving you trouble.
22:27robinkphren0logy: OK, I will
22:28lithprphren0logy: seconded
22:28robinkphren0logy: Yeah, even when I mention clojure-contrib in the CLASSPATH environment variable, it doesn't show in Java's runtime classpath.
22:29phren0logyWith leiningen, I haven't had to worry about classpaths nearly as much. Which is great, becuase that always seems to be a headache.
22:29bb_ozrobink: you could start clojure with -cp
22:31bb_ozjava -cp $JLINE_JAR:$CLOJURE_JAR:$CLOJURE_CONTRIB_JAR:$MORE_CLASSES jline.ConsoleRunner clojure.main
22:32MecHas anyone by chance made a JTree out of nested maps?
22:34lithprMec, i hope someone gives you a magic link, because i can only think of about a 1000 nifty things to do with that off hand...
22:34MecI know right, I'll deffinitly have to publish it if I dont kill myself first
22:34lithprthat would be worth the effort
22:46MecAssuming every key is a node in the tree, how would you represent the leaf key values (if at all)
22:49lithpryou'ld essentially need to decide whether the key value only serves to host the structure, or have it do double duty as a label
22:50lithpris my knee-jerk response
22:50MecI was going to have it be label as well, else where would you put the key-label links
22:52robinkbb_oz: Thanks
22:54lithprwell, {:foo [[:label "bar" :other-stuff "baz"] {:biz ...
22:55lithpragain, i'm not really thinking deeply here, and it's thought-worthy...
22:56robinkOK, fixed it, but I have to call clojure from Java per bb_oz' suggestion.
22:56lithprrobink: excellent. glad to hear it
22:56robinklithpr: I'd still like to just be able to fire up clojure.
22:56Meccan you assosciate metadata with just a key inside a map
22:56robinkOh, clj is a script
22:56lithprMec.. ooh, that's nice
22:57lithprkeeps it generic
22:57lithprthe structure you're modeling with the JTree i mean
22:57Meclike {(with-meta :foo {:label "bar" :other-stuff "baz"}) {next-level-of-tree}}
22:58robinkIs it a bad thing to pull in clojure-contrib every time?
22:58robinkclj looks in ~/.clojure and adds anything there to the classpath.
22:59Mecis it possible to do what i typed?
22:59lithprrobink: there are two kinds of people- those that mess with classpaths and those that tool them. I was of the former, and it gave me a lot of advantagesrelative to my peers. I am now the later, and probably worse for it :)
23:00robinklithpr: Heh, it seems to me to be better to tool your classpath, but I don't know jack about Java or handling deps in OO languages.
23:01lithprmec, i have not ever actually used metadata, but the usecase for it that rich talked about is exactly the one you have here
23:01lithprlike exactly, that is metadata to the structure
23:01Mecya
23:02Mecand that why you can even embed your own listeners
23:02Mecbut can you add meta to a keyword
23:02lithprso i don't know if your code is syntacticly perfect, but conceptually it is definitely spot on
23:02Mecand the answer is nope
23:02Mecwhich really sucks
23:03lithpryou can add it to a symbol
23:03lithprbut not a keyword?
23:03Meccan you add it to a symbol or just the value the symbol is representing
23:04Mec,(with-meta 'test {:test true})
23:04clojurebottest
23:04Mec,(meta (with-meta 'test {:test true}))
23:04clojurebot{:test true}
23:04Mec\
23:04Mec,(with-meta :test {:test true})
23:04clojurebotjava.lang.ClassCastException: clojure.lang.Keyword cannot be cast to clojure.lang.IObj
23:05brweber2does anyone know if there is an akka bridge or equivalent erlang style actor library for clojure?
23:06Mecso maybe instead of maps, the structure can be vectors with metadata
23:08robinkClojure docs have you getting pi via (. Math PI). Is this optimal?
23:08robinkIt seems to be relying on Java. I still haven't figured out Java calls.
23:08Mec,Math/PI
23:08clojurebot3.141592653589793
23:09Mecshorthand for static members
23:09robinkMec: Thanks.
23:14Mec,#^{:label "Root"} [#^{:label "brach1"} 'leaf?]
23:14clojurebot[leaf?]
23:14MecThat doesn't look too bad, but what should be used to represent leaf nodes
23:17slyphonjeez
23:17slyphonthe fact that 'defmacro' is a fn just blows my mind
23:18Meca macro is just a function with a macro flag in its metadata
23:21slyphonyeah, i mean, it has to be a function, but at some level, that's just more meta than i can easily comprehend
23:22Mecmost simply a macro is just a function that doesnt evaluate its args
23:32MecI guess it doesnt matter what the leaf node actually is since all we want is it's metadata
23:43Mecbah meta cant be applied to string either :x
23:47Mecwhich representation looks better, or is there another I havnt considered? http://gist.github.com/345693
23:49Mec,(meta (with-meta (keyword "test") {:test true}))
23:49clojurebotjava.lang.ClassCastException: clojure.lang.Keyword cannot be cast to clojure.lang.IObj
23:51somniumyeah keywords are interned singletons :/, Ive settled on using a wrapper type for strings/numbers for the same problem, though its not very satisfying
23:52Mecsymbols will work right?
23:52_atoyes
23:53Mec,(meta (with-meta (symbol "test") {:test true}))
23:53clojurebot{:test true}
23:53Mecsymbols it is
23:54Mechttp://gist.github.com/345693