#clojure logs

2010-04-26

00:32remleduffIf I've got m {a 1, b 2, c 3}, is there a better way to do: (map (juxt key (comp inc val)) m) to get {a 2, b 3, c 4} ?
00:33hiredman,(fmap inc '{a 1, b 2, c 3})
00:33clojurebot{a 2, b 3, c 4}
00:33hiredman,`fmap
00:33clojurebotclojure.contrib.generic.functor/fmap
00:34cp2woah
00:34cp2thats funky
00:34remleduffAh, thank you. Still learning core, hadn't got to contrib ;)
00:36leifwis there a clojure priority queue implementation?
00:36leifwI found one on google code but it looks unmaintained and probably unfinished
00:37leifwI could use a java class but it would be nice if there were an idiomatic one, and doubly nice if it were all functionalified to be side-effect-free and persistent and such
00:39cp2leifw: http://github.com/hiredman/clojurebot/blob/master/src/hiredman/pqueue.clj
00:40cp2although hiredman is here, so i would listen to him :D
00:41leifwneato, thanks
00:46defnid like to take serialize a ref to a file, and then be able to read it back in as a ref later -- should i just (with-out-writer file (pr-str @my-ref))?
00:46defnhow does it get read back in?
01:07defnLicenser_: you around?
01:08defnLicenser_: why wrap dorun in a (fn [] (dorun (map blah (blah blah))))
01:20AntonyBlakeyAnyone seen this: "Wrong number of args passed to: core$-cache-protocol-fn" with 1.2.-master-SNAPSHOT?
02:43yairiny,`fmap
02:43clojurebotclojure.contrib.generic.functor/fmap
02:47yairinyand when I call it with (range 2 100000) it stack overflows
02:47yairinyremove-mults is non-recursive and I can't see why there should be too deep a call stack...
03:29LauJensenMorning all
03:31patrkrisgodmorgen lau
03:38bendlashi folks
04:06Raynesmmarczyk: Heh. I answer a question correctly, and you come in 30 minutes later and answer it 10 times better. Want to trade brains, sir? :p
04:14cYmenhow do I append to a list?
04:15mikem,(concat '(1 2 3) '(4))
04:15clojurebot(1 2 3 4)
04:16cYmenmikem: thanks!
04:16mikem,((fn [l x] (concat l (list x))) '(1 2 3) 4)
04:16clojurebot(1 2 3 4)
04:26ChousukeNote that such concats shouldn't be a frequent operation. performance degrades pretty quickly due to laziness.
05:05stilkovHi there; how can a program find out the version of Clojure it runs under?
05:10patrkrisstilkov: look at the *clojure-version* variable
05:10patrkrisstilkov: http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/*clojure-version*
05:10stilkovpatrkris: thanks, exactly what I was looking for
05:27stilkovIf you were to pick your favorite 5 Clojure blogs, what would they be? Here's my initial attempt: http://www.bestinclass.dk/index.php/blog/ http://technomancy.us/ http://stuartsierra.com/ http://blog.fogus.me/ http://kotka.de/blog/
05:27sexpbot"Blog | BEST IN CLASS"
05:42LauJensenWow thanks :)
06:42vu3rddslightly OT. Can someone recommend a good book on SQL or in general designing proper tables etc?
06:44cemerickvu3rdd: "The Art of SQL" is a good read if you already know the basics, etc.
06:45vu3rddcemerick: Thanks. I have never used databases but have done a bit of playing around with mysql on my machine. But that is all. Have not done any real stuff. I will take a look at "The art of SQL".
06:47cemerickvu3rdd: in that case, that recommendation probably won't work out for you :-)
06:47vu3rddcemerick: Oh.. ok
06:48cemerickI don't know what the good beginner RDBMS books are these days.
06:48cemerickNever did, really.
06:48vu3rddWhat I am looking for mainly the considerations to be given while designing tables and their relations.
06:50zmilaone may always start from corresponding wikipedia article, and then follow links
06:58AWizzArdBtw, how deeply developed is an implementation of Clojure in JavaScript?
07:11zmilaif i'm not mistaken - last commit to ClojureScript is Jan 2009?
07:17bendlasam i right, that ring sessions stay in memory indefinitely, if you don't delete them manually?
07:21cemerickzmila: yeah, it hasn't been worked on in some time. That'll likely change as more and more clojure is written in clojure.
07:22cemerickbendlas: If I'm not mistaken, ring just uses the servlet container's session store. Jetty's default is in-memory, with a variety of configuration parameters.
07:35bendlascemerick: not exactly, it stores the sessions in an (atom {})
07:35bendlasand i can't find the place where a timeout would delete the session
07:40licoresseanyone using la clojure (idea) with 1.2?
07:45cemerickbendlas: hrm, yes, you're right (it's a ref in compojure 0.3.2). Now I remember why I stuck to using the servlet sessions.
08:05_extermIs the ASM library included in clojure just a repackaged org.objectweb.asm or are there significant changes? I'd like to let the clojure compiler generate other things than JVM Bytecode, therefore messing with clojure ASM.
08:05_exterm-changes +differences
08:06rhickey_exterm: clojure's ASM is just a re-packaging, no changes
08:07jwr7How can I override a dependency in leiningen (project.clj) with my own fork pushed to Clojars?
08:09_extermrhickey: thanks!
08:10_extermrhickey: which version of asm is it?
08:10rhickey_exterm: old, 2.something
08:11_extermok, that should help - thanks!
08:14vu3rddrhickey: Debian made some changes (some < 5 lines) so that it uses the asm3 on the classpath. I see that your todo list has such a goal. Do you want such a patch before 1.2?
08:15rhickeyvu3rdd: dunno, it's under consideration
08:15vu3rddok
08:45rhickeyare we ready for #^ becoming ^ ? (#^ will remain around for compatibility)
08:49AWizzArdyes
08:49AWizzArdBut how long will #^ survive?
08:51rhickeyAWizzArd: 42 days
08:51LauJensenperfect
08:57chouserrhickey: I assumed you'd want a release with #^ deprecated.
08:57rhickeychouser: at some point, no rush on that I think
08:57rhickeyi.e. you could go out with ^ working and #^ not yet deprecated
08:58AWizzArdrhickey: can you make ^ so that it can optionally support many type hints? ^{:jvm BigInteger, :clr SuperInt, :common-lisp bigint}
08:58AWizzArdWith editors that hide/unhide type hints, or only display those for the current plattform, this would look nice in the editor.
08:58chouseroh, sorry, I'm confused. Let me try again: I assumed you'd want a release with ^ deprecated.
08:58rhickeyAWizzArd: ^ just attaches metadata, it doesn't determine its use
08:59rhickey^rest
08:59rhickey,^rest
08:59clojurebotnil
08:59rhickeyaargh
08:59AWizzArd,*clojure-version*
08:59clojurebot{:interim true, :major 1, :minor 1, :incremental 0, :qualifier "master"}
08:59rhickeyWARNING: reader macro ^ is deprecated; use meta instead
09:00chouseroh, was that in 1.1? perfect.
09:00rhickeyah, not deprecated in 1.1, fooey
09:00chouserclojurebot is pre-1.1
09:01chouserOk, looks like 1.1 way early May 2009. ^ was deprecated early Dec 2009
09:02chouser-way +was
09:02chouserbut as for me, I'm ready.
09:02rhickeyhttp://www.assembla.com/spaces/clojure/tickets/215-deprecate-%5E-reader-macro
09:02sexpbot"#215 - Deprecate ^ reader macro (Fixed) | Clojure | Assembla"
09:02chouser~chouser
09:02clojurebotWho??
09:02chouser~chouser
09:02clojurebotWho??
09:02chouserbah, nm.
09:03rhickeyis it deprecated in 1.1 or not?
09:04chouserthe dates I listed above are from the git log. I'd trust that over manual flags in Assembla, so I think was not deprecated in 1.1.
09:04chouserI should keep 1.1 built somewhere... :-/
09:04rhickey1.1 was not May
09:05chouseroh
09:05rhickeyhttp://github.com/richhickey/clojure/blob/1.1.x/changes.txt
09:05chouseroh, great!
09:05rhickeyso, already deprecated, good to go
09:05rhudsonIt's deprecated in 1.1
09:06chouseroh, 1.0.0 was may
09:06chouserI was misunderstanding the commit messages.
09:06rhickeybut get rid of for one release, then redefine?
09:06LauJensenYea, just confirmed that its deprecated in the 1.1 download from clojure.org (featured)
09:07rhickeyotherwise we go directly from one (deprecated) semantic to a different one
09:07chouserwith releases at this pace, I think deprecated in a single release is fine.
09:08chouserIt seems sane to recommend people upgrading from 1.0 try 1.1 along the way instead of jumping directly to 1.2.
09:08rhickeyis anyone using 1.0?
09:09LauJensenrhickey: sure there are some legacy solutions here and there
09:09fogusrhickey: Thanks for the annotation support. This may help clear the final hurdle for using Clojure in my team's mainline source!
09:09rhickeyfogus: great! I'll try to get parameter annotations in today
09:10fogusrhickey: Great. I'll hold off on my pitch slides then. :-)
09:10rhickeyanyone want to work up a patch to use them in gen-class as well?
09:11chouserProgramming Clojure still points to http://github.com/stuarthalloway/programming-clojure which still refers to SVN revision numbers for Clojure and contrib.
09:11chouserI don't know if that means there may be learners still using 1.0?
09:12rhickeycould be
09:13chouseranyway, it seems unlikely there's much maintained code still expecting 1.0
09:15rhickeyremoving it for one release prior to repurposing seems most prudent, but...
09:17zmilaClojure course on RubyLearning is procrastinated to 30th, is it?
09:18chouserI think most uses of ^ as meta will still be reported: java.lang.IllegalArgumentException: Metadata must be Symbol,Keyword,String or Map
09:19rhickeychouser: I don't know about that (let [x ^y z 42] ...) will yield error completely unrelated to metadata
09:19chousermany will, anyway, though others will be reported as reader errors -- unexpected ) etc.
09:20chouserhm.
09:20Chousukemaybe have a "lint" mode that simply reports any ^ use?
09:21Chousukeso that it can be checked if it's up-to-date or not
09:27defnstill pretty shaky but a bit of a redesign to walton: http://getclojure.org:8080/examples/concat
09:27sexpbot"concat"
09:27rhickeywhat does it take to get clojure-mode to highlight ^ as it currently does #^ ?
09:27defnenjoy
09:29AWizzArdrhickey: there are just three occurrences of #^ in clojure-mode, in regexps. I guess only those need to be edited. So, like 30 seconds.
09:33rhickeywhere does elpa put things?
09:34mannicheon clean setup, elpa uses .emacs.d/elpa
09:34mannicheplease insert 'a' in it's proper place in the above
09:34rhickeymanniche: thanks
09:34mannichenp
09:35defnrhickey: technomancy is a good guy to talk to about elpa-related stuff, fwiw.
09:37rhickeyAWizzArd: so what are the three new regex strings that support both #^ and ^ ?
09:38AWizzArdhttp://github.com/technomancy/clojure-mode/blob/master/clojure-mode.el#L297
09:38AWizzArdand Lines 438 and 486
09:38AWizzArdthough some escaping might be required in the regexps
09:40sattvikrhickey: I'll add annotations to gen-class, if you like.
09:41rhickeysattvik: great! please assign the issue to yourself: http://www.assembla.com/spaces/clojure/tickets/318-add-annotation-support-to-gen-class
09:41sexpbot"#318 - add annotation support to gen-class (New) | Clojure | Assembla"
09:44sattvikrhickey: No problem. I will look into it later today and submit a patch soon.
09:48a_strange_guyhi there
09:49a_strange_guyhow do i call an IFn that is a static field?
09:49chouserhehe
09:51a_strange_guy,(clojure.lang.PersistentList/creator 1 2 3 4)
09:51clojurebotjava.lang.IllegalArgumentException: No matching method: creator
09:51chouser,((clojure.lang.PersistentList/creator) 1 2 3 4)
09:51clojurebot(1 2 3 4)
09:52a_strange_guythat was just a bad example xD
09:53chouserI'm not disagreeing that it was a bad example. But my point is that putting parens around a static field name still just returns the value, which if it is an IFn can then be called.
09:53chouser,(clojure.lang.PersistentList/creator)
09:53clojurebot#< clojure.lang.PersistentList$1@74bcd3>
09:53a_strange_guyok
09:54a_strange_guylearned something new ^^
09:54a_strange_guyseems undocumented
09:55chouser,((. clojure.lang.PersistentList creator) 1 2 3 4)
09:55clojurebot(1 2 3 4)
09:55chouserthat one's documented. :-/
09:56a_strange_guyah, and (Class/fld) -> (. Class fld)
09:58a_strange_guyi was kindof confused because Class/fld also gets turned into a field access
09:58a_strange_guyexcept if it is at the beginning of a form
10:00chousera_strange_guy: yes, that's why I laughed when you first posted your question. The thought of an IFn in a static field had never occured to me.
10:01chouserIt's almost a pun
10:01a_strange_guyyeah it came to my mind because the new deftypes have no constructor fns
10:02rhickeya_strange_guy: they have ctors though
10:02chouserthey don't have static fields either, do they?
10:03a_strange_guythat aren't function though
10:04AWizzArdrhickey: btw, do we go with (Foo. ..) for now, without (Foo/create ..) and (create-Foo ...) ?
10:04rhickeyAWizzArd: I found those lines, looking for *new* regexes to use
10:05a_strange_guyif we had static fields, then we could put a creator fn in there
10:05rhickeya_strange_guy: or just write a function
10:06a_strange_guythat is what i do for now
10:06a_strange_guyi wrote a macro that does a defrecord and creates a create-Type fn
10:07a_strange_guybut it seems kinda messy
10:08lessthantristanI have compiled a class with gen-class with a static method, when i call (package.name.ClassName/staticMethod input) it works fine, but if i (import ...) (ClassName/staticMethod input) it throws me an unsupported operation exception. any ideas?
10:12AWizzArdrhickey: you need to edit these three lines. Replace the hash with two backslashes. Line 486 for example will after that operation look like this: ("\\^\\sw+" 0 font-lock-type-face)
10:12a_strange_guylessthantristan: is there any reason using the static method instead of the defn that is in your namespace anyway?
10:14a_strange_guylike (-staticMethod input) ?
10:14AWizzArdrhickey: or you can put between the # and the ^ in #^ just a questionmark, so that these three will look like: #?^
10:14AWizzArdIn that case it will highlight #^String but also ^FileInputStream
10:14lessthantristanhmmm. maybe not. let me think about that
10:22naeucan anyone explain why (seq? '#(%)) ;=> true
10:23AWizzArd,'#(%)
10:23clojurebot(fn* [p1__11767] (p1__11767))
10:23naeuwhat does fn* mean?
10:23chouserdoesn't matter in this case.
10:23a_strange_guyit's 'fn without destructuring
10:23chouserwhat matters is that #() expands at read-time to (...)
10:24chouser' quotes that so that the (...) list is passed to 'seq?'
10:24lessthantristana_strange_guy: i think i'll go with that, it'll probably work out better now i think about it.
10:24chouserlists are seqs, so 'seq?' returns true.
10:24AWizzArd'#(%) ==> list with three elements
10:24naeuah ok
10:24naeuI'm still trying to get my head around the different behaviours of -> and ->>
10:24naeuI understand them in an algebraic sense
10:25naeubut I'm now trying to get a practical working understanding of their usecases
10:25AWizzArd,(seq? (eval '#(%))) ; this is:
10:25clojurebotDENIED
10:25AWizzArdokay, false would be the result
10:25AWizzArdclojurebot: (enable 'eval) ;-)
10:25clojurebotHuh?
10:25AWizzArdrhickey: did that work out for you? Can you now see ^YourTypeHint colored?
10:26a_strange_guy,(->> (range 10) (map #(* % %)) (reduce +))
10:26clojurebot285
10:26naeu(-> [1 2 3] #(* 2 %) #(+ 5 %)) vs (-> >[1 2 3] #(* 2 %) (+ 5 %))
10:26a_strange_guydont use -> and ->> with function literals
10:26naeuoops: (-> [1 2 3] #(* 2 %) #(+ 5 %)) vs (->> [1 2 3] #(* 2 %) #(+ 5 %))
10:26naeua_strange_guy: why?
10:27chouserit's almost certainly not what you mean
10:27naeuthe ->> works as I expected
10:27a_strange_guybecause ->> and -> transform source code
10:27chouser,(-> 1 (* 2) (- 5))
10:27clojurebot-3
10:27naeueach el in the list is doubled then incd by 5
10:27chouser,(->> 1 (* 2) (- 5))
10:27clojurebot3
10:28AWizzArdchouser: do you know why we want to replace #^ with just ^?
10:28chouser,(macroexpand-1 '(->> [1 2 3] #(* 2 %)))
10:28clojurebot(fn* [p1__11785] (* 2 p1__11785) [1 2 3])
10:28chouserAWizzArd: ^ is less ugly
10:28a_strange_guy(macroexpand '(-> [1 2 3] #(seq %)))
10:28AWizzArdk
10:28a_strange_guy, (macroexpand '(-> [1 2 3] #(seq %)))
10:29clojurebot(fn* [1 2 3] [p1__11789] (seq p1__11789))
10:29naeuI thought one of the main uses of ->> was to transform source code to a more readable form in certain cases
10:29a_strange_guyyeah but thos macros ignore the semantics of special forms like fn an dlet
10:30defnnaeu: http://getclojure.org:8080/examples/-&gt;&gt; and http://getclojure.org:8080/examples/-&gt;
10:30sexpbot"->>"
10:30a_strange_guy,(macroexpand '(->> [1 2 3] #(* 2 %) #(+ 5 %)))
10:30naeua_strange_guy: so are there any guidlines of when to use them?
10:30clojurebot(fn* [p1__11794] (+ 5 p1__11794) (clojure.core/->> [1 2 3] (fn* [p1__11793] (* 2 p1__11793))))
10:30defnit is loading up right now so you might need to reload a few times but you can see some ideas of use
10:30naeuor is it just a tacit notion of good and bad for a give usecase
10:31chousernaeu: -> and ->> are simple macros, not high-order functions. This just rearrange the code a bit.
10:31chouser-This +They
10:31chouserthe only reason not to use #() in them is that it probably isn't what you mean.
10:31defnquestion: is it obvious on the above links that you should click the example to expand it and show its result?
10:31a_strange_guyhttp://vimeo.com/8474188
10:31AWizzArdnaeu: this is the idea behind macros. Allow the dev to write down the code in a way that is easier to read (and write) for humans. Not only true for ->>
10:31sexpbot"Episode 5 - Expression Threading on Vimeo"
10:32stuartsierraGood morning.
10:32stuartsierraI did this over the weekend: http://github.com/stuartsierra/need
10:33defnstuartsierra: cool
10:33chouserstuartsierra: I like it.
10:34stuartsierrathanks
10:34a_strange_guyawesome
10:34chouserstuartsierra: which way does :rename go?
10:34stuartsierrachouser: Same as refer; {original-name new-name}
10:39naeuout of interest, does the implementation of the ->> macro even need this clause: (with-meta `(~(first form) ~@(next form) ~x) (meta form))
10:40naeuseems like the seq? test is superfluous
10:40naeuand the 2-arity version could just be: ([x form] (list form x))
10:45chousernaeu: that would transform (->> 5 (+ 2)) into ((+ 2) 5), wouldn't it?
10:47naeuI'm just assuming that `(~(first form) ~@(next form)) is equivalent to (form)
10:47naeuperhaps I'm wrong...
10:47chouseroh, perhaps it could be `(~@form ~x)
10:48chouserthough the metadata-copying is important too
10:51a_strange_guystuartsierra: does (need [java.util.concurrent as juc]) work too?
10:52stuartsierrano
10:52a_strange_guymy bad
10:52stuartsierraIt doesn't do Java class imports; I explain why in the readme
10:52a_strange_guydidn't read that you didn't support imports
10:53stuartsierraI thought about it, but it's impossible to do :as, :all, or :exclude with Java packages.
10:53naeuchouser: so what's the difference between `(~@form ~x) and (list form x)
10:53naeufrom within a macro context?
10:54chouser,(list '(1 2) 3)
10:54clojurebot((1 2) 3)
10:54chouser,`(~@'(1 2) 3)
10:54clojurebot(1 2 3)
10:56naeuah, ok
10:57a_strange_guystuartsierra: shouldn't it be (defmacro need [& args] `(apply need* ~args)) instead of an apply at macroexpansion time?
10:58stuartsierranope
10:58stuartsierraThat would evaluate the arguments.
10:58chouserthe purpose of the 'seq?' test is to allow non-list parts.
10:58chouser,(5 inc inc inc)
10:58clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
10:59chouser,(-> 5 inc inc inc)
10:59clojurebot8
11:00a_strange_guybut (if *var* (need [this ...]) (need [that ...])) will load both this and that
11:00stuartsierrathat's true
11:00stuartsierraIt should probably be `(apply need* ~(map quote args))
11:01Chousukehmmh
11:01cemerickstuartsierra: nice spike. Eliminating prefix lists gets a big +1 from me.
11:01Chousukethat won't work either, quote is not a function
11:01stuartsierraright, got to do (map (fn [x] (list 'quote x)) args)
11:02Chousukeand then you could just splice in the args anyway and remove apply
11:02a_strange_guy`(need* ~@(map (partial list 'quote) args))
11:02rhickeyAWizzArd: #?^ doesn't work. I would like to highlight both #^ and ^
11:02stuartsierraalthough `(apply need* '~args)) might work too
11:03stuartsierraand that's a lot simpler
11:03stuartsierrayeah, that works
11:04a_strange_guyas long as there are no side-effects at compiletime everything is fine
11:05stuartsierrafixed and pushed
11:05stuartsierraThanks, strange guy.
11:06a_strange_guythis needs to go to c.c.ns-utils at least
11:07AWizzArdrhickey: are you using a fresh checkout? i.e. http://github.com/technomancy/clojure-mode/blob/master/clojure-mode.el
11:07AWizzArdrhickey: I just replaced my old clojure-mode.el with this new one, replace the three #^ with #?^ and can now see #^String and ^FileInputStream highlighted.
11:08rhickeyAWizzArd: no, does it matter?
11:08stuartsierraa_strange_guy: I'm reluctant to add any more confusion to use/require/refer
11:09AWizzArdrhickey: depends on the version you use, but in principle it should work with older versions too, which use the same regexps. You need to restart emacs, so that the new clojure-mode.el is used. The highlightning happens in source files, not in the repl.
11:11a_strange_guyit seems to unify require/use/refer well enough to replace those in the future
11:12stuartsierraa_strange_guy: but it won't be supported in 'ns'
11:12stuartsierranot yet anyway
11:14rhickeyAWizzArd: ok works now, I had a clojure-mode.elc in there
11:14rhickeyAWizzArd: thanks!
11:17AWizzArdgreat
11:34stuartsierraAnyone else think Clojure mode should always indent 2 spaces, regardless of the first item in the list?
11:34lpetityes
11:35rhickey#^ -> ^ swap done in core
11:35rhickeymuch cleaner looking
11:36rhickeylet's get those editor/IDE patches in place
11:37stuartsierradidn't know this was a 1.2 feature
11:37rhickeyit is now
11:37Chousukeheh
11:37cemerickzing :-)
11:37stuartsierradoes #^ still work?
11:37rhickeyyes
11:37stuartsierraook
11:37stuartsierraok
11:39rhickeydoing it now is better for the books
11:39rhickeyIMO
11:39stuartsierraah
11:39cemerickIs there another that is impending?
11:39stuartsierraSo you're saying I have to edit that chapter now? :)
11:39rhickeystuartsierra: yes please
11:40rhickeycemerick: are you waiting for something?
11:40djpowellbtw I thought that deftype was intended to be a bit host-neutral? Does adding annotations there conflict with that?
11:41cemericknot at all -- I've just seen books (plural) a couple of times, and I'm not aware of another besides JoC that is close to publication.
11:41stuartsierra"Practical Clojure" is in final edits
11:41cemerickah
11:41cemerickThat totally flew under my radar.
11:42stuartsierratell me about it
11:42rhickeydjpowell: annotations are an interop feature, yes, but there will be no semantics for them other than interop, i.e. I'm not making them a Clojure feature
11:42stuartsierrait's so far under the radar, even I don't know when it's getting published
11:42cemerick"if something happens, and isn't tweeted about it, does it make a noise?"
11:42rhickeyheh
11:44rhickeydjpowell: annotations present on platforms that don't have annotations do nothing
11:44rhickeyjust like some hints will do nothing on JavaScript
11:44djpowellah ok
11:45chouserstuartsierra: ah, congrats -- I didn't know it was that close to done.
11:45djpowellare .net annotation sufficiently similar to java ones that they will be implementable do you know? I don't know much about them
11:45stuartsierrachouser: thanks
11:51djpowellcemerick: re the contrib.io stuff, it would probably be cool if the URL->Reader stuff used the content-type header where possible to get the charset - I might have a go at that later
11:52stuartsierradjpowell: http.agent does that I think, if you want an example
11:54djpowellstuartsierra: is that a contrib lib?
11:55stuartsierrayes
11:56cemerickdjpowell: Yes, that would be a better default for the URL/reader impl. Should be straightforward, I'd think.
11:57djpowellcool. i'll check that it complies to my obsessive conformance to mime/http/xml rfcs
11:57cemerickOr, wait, except for HTTP URLs, in which case you'll go mad for the next four days. :-P
12:00djpowellstuartsierra: hmm I don't think it does. getContentEncoding, doesn't get the charset - it gets the http content-encoding header, which is blank, or something like 'gzip' or 'deflate'
12:00djpowelli'll take a look later...
12:02stuartsierradjpowell: oh, maybe I punted on that; I forget
12:07technomancyhopefully in a couple weeks there will be a combined swank/clo-mo release
12:07stuartsierrayay!
12:07technomancythe debug-repl stuff is to good to leave to snapshots
12:08rhickeytechnomancy: TIA for ^
12:11technomancysure, gotta keep up with the frentic pace of clojure =)
12:11technomancyactually I'm surprised how *little* stuff in my code I haven't touched in a year is still working fine in 1.2-snapshot
12:11technomancyI mean how little brok
12:11technomancyee
12:12technomancyit's practically all been contrib changes
12:12rhickeytechnomancy: yeah, sometimes I hate to see people categorize it as 'Clojure is changing all the time' since change == newness, not breakage
12:13rhickeyhopefully we'll be fixing the 1.2 contrib breakage
12:13stuartsierra~def flatten
12:13clojurebotI don't understand.
12:13djpowellthere have been very few breaking changes in clojure. only ones I can think of other than this are the vectors around bindings normalisation for doseq and friends, and lazy-cons - and both of those were prior to 1.0
12:13technomancymy stuff breaking in light of the contrib changes is 100% justified IMO
12:14djpowellother than clojure.core name clashes with user var names
12:14technomancyhigher rate-of-churn is what contrib is for
12:14cemerick+1 technomancy
12:15cemerickI really don't like the idea of carting around fundamentally dead code (for how long) to support folks that use contrib as a supported stdlib. *shrug*
12:15stuartsierraBut they're going to complain when 1.2 breaks everything.
12:16rhickeycemerick: one release as deprecated seems fair
12:17stuartsierrayes
12:17cemerickrhickey: I really don't think that's going to satisfy anyone, but we'll see.
12:17AWizzArdtechnomancy: please look into your priv
12:17technomancyright, leaving the old namespaces in place with deprecation warnings is definitely worth doing for a season just because it's not much work
12:17rhickeycemerick: there are certainly things between change now and change never
12:19cemerickrhickey: Sure, I know, but I've never heard someone come in and say "could you hold off on eliminating X, Y, or Z from contrib for a year? That'd help me out a bunch." I've only heard "This is the standard library, it must not break compatibility forever."
12:19cemerickagain, *shrug*
12:19rhickeycemerick: yeah, forever isn't very useful either
12:20cemerickI've never really seen a community that's handled deprecations gracefully.
12:20rhickeyconsideration != permanent accommodation
12:21cemerickPython is often cited, but the population holding onto 2.x would seem to suggest otherwise.
12:21jweissyou'd think clojure with its homoiconicity would make it easy to automatically upgrade existing code
12:21jweissor at least i'd think that :)
12:21technomancytime to implement M-x precate (opposite of deprecate)
12:23stuartsierrajweiss: It's not just names that have changed; it's behavior too.
12:23jweissah, that's a bit more complex then :)
12:23cemerickThere's also almost always more code to fix in libraries you depend upon than in your own codebase.
12:25replacacemerick: as things mature, there's no reason not to let folks "stay behind" on old releases if they meet their needs
12:25dnolencemerick: tho that's a different problem. for end users Python 3k is not *that* much better. compare to Clojure 1.1 to 1.2, too much good stuff to not move. you know things are slowing down for a language when most people and libraries aren't excited about following.
12:34djpowellsomewhere in the world the elimination of #^ line noise will make someone not give up on trying clojure
12:34slyphonheh
12:34slyphonit that dissuades you, you need to grow a pain
12:34slyphonpair*
12:35somniumgrow a perl?
12:35djpowellha - I showed someone a defrecord one-liner today, and I had to put type hints in for parity, and that #^ grated with me even
12:35technomancy"They see me coding, they hating. They're just upset cause I'm deprecating." -- http://twitter.com/tenderlove/status/11069179490
12:35sattvikrhickey: There is no way to create a no-arg constructor with deftype, correct?
12:36sattvikrhickey: Assuming there are fields for the type, of cours.e
12:39chousersattvik: but you can write your own no-arg factory fn
12:40chouserI think almost every defrecord and deftype will end up with a hand-written factory fn
12:41sattvikchouser: True, but that won't work in an inter-op scenario that expects a no-arg constructor.
12:41chousertruwe
12:41chouseralso, true.
12:42chouserfor interop you still pretty often need gen-class
12:42cemericksattvik: Last I knew, factory fns were going to be the way forward.
12:44sattvikchouser: That's what I thought. I just wanted to be sure I had not overlooked anything.
12:45chouserif you have control of the spec, I'd recommend pushing users toward static factory methods rather than no-arg ctors.
12:46chouserI think a 'gen-static' is planned that would make such things easy to create.
12:50lpetitI remember an idea along the lines of allowing syntactic sugar for "#^String foo" "^String foo" : "foo^String". Still relevant ?
12:51chouserlpetit: rhickey has grown increasingly cold toward suffix metadata
12:51lpetitok, no pb, just wanted to update my knowledge
12:51chouserI think ^String foo is what we get
12:56stuartsierrasuffix metadata would be a pain to parse
12:57rhickeystuartsierra: yeah
12:58mmarczykis the table of contents for "Practical Clojure" available anywhere?
12:58cemerickThere was the String:foo craziness I threw out there an age ago. :-P
12:58mmarczykand an excerpt from the text would be totally cool, of course
12:59stuartsierrammarczyk: There are 4 chapters on apress.com, not a very good sample
12:59stuartsierrano table of contents anywhere
13:00mmarczykstuartsierra: do you mean in the 'alpha'?
13:00stuartsierrayeah
13:00mmarczykoh :-(
13:00mmarczykit's $35 up front without a sample :-(
13:00stuartsierraI know
13:00stuartsierraWish Apress were better about that.
13:01ordnungswidrigIs there anything like haskell's "tying the knot" in clojure?
13:09slyphonso, i create a hierarchy w/ make-hierarchy, but when i pass the :hierarchy option to defmulti, it barfs with a ClassCastException
13:11wthiddenWhat is the form for adding meta data to a defrecord?
13:11chouserslyphon: ugh. at first glance looks like a regression
13:11slyphon:/
13:15fogusstuartsierra: When do you get your name on the cover?
13:15chouserslyphon: well, I spoke too soon as usual.
13:15slyphonhah
13:16chouserslyphon: not a regression I think, just weakly documented.
13:16slyphonchouser: what's the deal?
13:16slyphonoh?
13:16chouserIt looks like you have to put your hierarchy in an IRef of some kind.
13:16slyphonohhh
13:16slyphonand hand in the reference?
13:17slyphonweird, because derive works fine
13:17chouserright, defmulti expects an IRef
13:17hiredmanseems odd that make-hierarchy doesn't just return what you need
13:17chouseryeah
13:17slyphonyeah, can i do (dosync) at the top-level?
13:17chouserI can't tell yet if it matters what kind of IRef
13:18chouserglobal-hierarchy is a var
13:18slyphonhrm
13:18chouserweird. 2-arg derive mutates global state. 3-arg derive is a pure function
13:18slyphonwell i have (def *send-msg-hier* (make-hierarchy))
13:19slyphonchouser: that makes sense
13:19slyphonb/c it's mutating the global hierarchy
13:19slyphonhow do i hand in the var itself?
13:19chouserso if you want derive to change *send-msg-hier* you need to mutate it yourself. (alter-var-root #'*send-msg-hier* derive tag parent)
13:20hiredmanthere is a whole special form for getting vars
13:20chouserand (defmulti ... :hierarchy #'*send-msg-hier*)
13:20slyphonahh
13:20slyphonchouser: odd, it *seemed* to work without htat
13:20slyphonfor derive, but i'll try it that way
13:20chouserseems like a through discussion of multimethods ought to include this.
13:21chouserslyphon: well, derive will return your new heirarchy without that, but the change wouldn't "register"
13:21slyphonhiredman: oh, right, i hadn't really clued in that's what that does
13:21slyphonchouser: ah!
13:21slyphonchouser: sneaky!
13:22chouserpure function
13:22chouserthat's only the second example I've noticed of a clojure function being pure or not based on arity.
13:23chouserthe other is re-find -- one-arg is statefule, two-args pure.
13:23chousermakes me nervous
13:24slyphonso (def derive-send-msg (partial alter-var-root #'*send-msg-hier* derive))
13:24slyphonwould work, no?
13:24chousersounds about right
13:24slyphonyay! i grok partial!
13:24slyphon:)
13:25chouser:-)
13:28chouser,(-> "Unknown %s of type %s at line %s" (format "message" "Foo" 5) Exception. throw)
13:28clojurebotjava.lang.Exception: Unknown message of type Foo at line 5
13:28chouserabuse of -> ?
13:31Chousukechouser: :P
13:31chouserthat's not really an answer...
13:32cemerickchouser: yeah, probably
13:32cemerickthough I've used -?> to optionally toss exceptions sometimes, so who am I to talk.
13:45mmarczykum, sorry, I seem to be behind the curve on this: what's the authorship situation with "Practical Clojure"?
13:46chousermmarczyk: I think Luke Van der Hart wrote a bunch and then stuartsierra stepped in and wrote some chapters.
13:47chouserBut I'm not entirely sure.
13:47technomancyit's the dark, mysterious clojure book
13:48stuartsierraI wrote 6 chapters out of 14
13:48stuartsierraLuke VanderHart wrote the rest
13:48mmarczykoh, that's good to know
13:48rsynnottThere's a SECOND clojure book? :)
13:49chouserrsynnott: I know of 4
13:49stuartsierrasame here
13:49mmarczykthat definitely makes me want to read it :-)
13:49stuartsierrammarczyk: thanks
13:49rsynnottAh, I've only seen the PragProg one
13:50slyphondoes the author of "Programming Clojure" hang out in here?
13:50mmarczykI don't suppose any of your chapters would be in the alpha at this point?
13:50slyphonstuart halloway
13:50stuartsierrammarczyk: no, to my chagrin
13:50stuartsierraslyphon: occasionally, but not often
13:50chouserrsynnott: Halloways on v1.0 (published), Sierra's on v1.2 (complete but not printed?), Rathore's (incomplete, some chapters available) and Fogus's (incomplete, some chapters available)
13:50slyphonthat's the one i've been using most
13:50rsynnottah
13:50stuartsierrachouser: correct as far as I know
13:51mmarczykoh bother, must Apress have such disheartening policies :-(
13:52chouserI don't know what Rathore is targetting. Fogus's will have 1.2 content with perhaps some notes about earlier versions, depending on release timing.
13:52mmarczykchouser: I like the way you say "Fogus's" :-)
13:53chousermmarczyk: credit and blame. :-)
13:53rfgMy train has broken down.
13:53mmarczyk:-)
13:54rhickeyparameter annotation support is up, definterface annotaiton now up to snuff with deftype/record
13:54stuartsierracool
13:54stuartsierramaybe I can integrate with JUnit now
13:56cemerickouch, any ideas about this: java.lang.NoSuchFieldError: lastClass
13:56ordnungswidrigstuartsierra: you're really obsessed by unit test, right? :-)
13:56cemerickI suspect a lib that is AOT-compiled with an older snapshot of 1.2...
13:56chousereven if you don't buy the book, I think Fogus's first chapter (free) is likely quite useful.
13:56rhickeycemerick: sounds right
13:56stuartsierraordnungswidrig: just a little :)
13:57ordnungswidrigstuartsierra: what about quickcheck like stuff? I know there are at least two halfly done libs in clojure.
13:57stuartsierraordnungswidrig: it's on my agenda, but farther down the list
13:58stuartsierraI've never used a quickcheck-like library, so I have to learn more about it.
13:58ordnungswidrigstuartsierra: classification tree method?
13:58ordnungswidrigi'd love support for that.
13:59ordnungswidrigI'm just asking before doing it myself :)
14:00stuartsierraI don't know what that is.
14:04ordnungswidrigstuartsierra: a method for systematic testing. you decompose the input parameters of the subject under test into a tree of independent parameters (e.g. color of the object vs. shape vs. material). The tools then help generating small test sets that cover e.g. each pairwise combination of two parameters.
14:05stuartsierraah
14:05stuartsierrayeah that would be useful
14:06ordnungswidrigstuartsierra: it's a bit like quickcheck but when the execution of a single test takes long or has to carried out manually. For some problems you just don't want test all combinations of parameters :)
14:06ordnungswidrigsut
14:07ordnungswidrigstuartsierra: if you like the topic you can try CTE, a free java application http://www.systematic-testing.com/functional_testing/cte.php
14:07sexpbot"Systematic Testing"
14:08stuartsierraI'll check it out
14:09stuartsierraRight now I'm still focused on getting the syntax right for specs/assertions/contexts
14:09stuartsierraThen I'll finish the work on continuous testing.
14:26ordnungswidrigstuartsierra: ist lazytest master usable?
14:26ordnungswidrigstuartsierra: or loose ground?
14:26stuartsierrausable, but not stable
14:26stuartsierrasyntax may change
14:33algorifficwhen using the clojure.zip api, can branch nodes have data that is not a children of the node?
14:40technomancystuartsierra: are you OK with relicensing your swank-clojure commits under the EPL?
14:40stuartsierrayes
14:40technomancygreat; thanks
14:40stuartsierradon't remember making any commits
14:40technomancyany other swank contributors in the channel that would like to chime in?
14:41technomancystuartsierra: I'm just going over raw commit numbers, so build changes are mixed in with the rest of it.
14:41stuartsierraoh, ok
14:43mattreplwhat's change for? but yes, I'm ok with that
14:43mattreplpackaging with Clojure?
14:43technomancymattrepl: no, just for general deployments
14:44algorifficanyone with experience using clojure.zip to build trees?
14:44technomancybecause some of our deployments at work may be considered "distributing", we're currently unable to use swank outside dev scope.
14:44technomancyplus matching licenses with the host environment is just fewer things to worry about
14:44technomancymattrepl: thanks
14:44mattrepleww, yeah, that's a good point
14:48slyphonhrm, what would be a way to represent a jms MessageConsumer as an infinite seq?
14:48slyphon(repeatedly (.receive consumer)) ?
14:48slyphonoh duh
14:48slyphonwell
14:48slyphonsomething like that?
14:49slyphonit would be best if after the consumer's session is shut down, the seq only returns nil
15:00slyphonso, if you do send-off on an agent, it queues up the action to be taken on the agent?
15:01slyphoni.e. are you guaranteed order?
15:02stuartsierraI think so
15:02slyphonhttp.agent is designed that way
15:02stuartsierraagent actions occur in the order they are received
15:02somniuma terse little pattern matcher inspired by PLT Scheme's match >> http://github.com/somnium/yap, comments welcome
15:03slyphonright, but if you do (send-off agent first-thing) (send-off agent second-thing) ...
15:03stuartsierrafirst-thing happens first
15:03slyphonkk
15:03slyphonok, that's what i thought
15:04stuartsierraBut if another thread is sending actions, you can't know that first-thing will be immediately followed by second-thing.
15:04slyphonright, of course
15:04slyphoni want to, in a single thread, set up a sequence of actions that will take place
15:06mmarczykwoo-hoo! just got a Clojure-related GSoC spot! :-D
15:06mmarczykhttp://socghop.appspot.com/gsoc/student_project/show/google/gsoc2010/omii_uk/t127230761862
15:06sexpbot" Show Student Project"
15:07somniumslyphon: if you just want actions executed in sequence in another thread I think future might be appropriate
15:07slyphonsomnium: hrm
15:08technomancymmarczyk: wow, that's a lot of acronyms.
15:09mmarczyktechnomancy: yeah, the project is very proud of them ;-))
15:10mmarczyka better description of what this is about:
15:10mmarczykhttp://www.omii.ac.uk/wiki/OgsaDaiDqpClojure
15:10sexpbot" OMII-UK: Ogsa Dai Dqp Clojure"
15:13technomancycool
15:13mmarczyk:-)
15:24Hali_303hi! how to give JVM parameters to leiningen?
15:24technomancyHali_303: JAVA_OPTS should do it
15:24Hali_303technomancy: thanks!
15:24technomancynp
15:50slyphonyou know, the stack traces thrown when 'ns' horks could be more helpful
16:01slyphoncan you send-off inside an agent modifying function?
17:00chouserslyphon: sure, but the send-off is held until the current action completes.
17:00slyphonchouser: that's perfect, actually
17:01slyphonan
17:01slyphonman
17:01slyphon"Wrong number of args passed to: PersistentHashMap"
17:02hiredmanmaps are functions
17:02slyphonhrm
17:02hiredman,({} 1)
17:02clojurebotnil
17:02hiredman,({} 1 2)
17:02clojurebot2
17:02hiredman,({} 1 2 3)
17:02clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: PersistentArrayMap
17:02slyphonoh, weird
17:02hiredman,((hash-map) 1 2 3)
17:02clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: PersistentArrayMap
17:03chouserheh
17:03chousergotcha!
17:03hiredman
17:03slyphon:D
17:03slyphontries*
17:03chouserslyphon: so really, you're probably calling a map where you mean to be calling something else
17:04hiredman(defn x [map] (map foo bar baz))
17:04patrkrisslyphon: have you tried clojure.stacktrace/e?
17:04slyphoni've got like 20 layers of anonymous function wrapping
17:04slyphonpatrkris: i don't think so
17:04chouserslyphon: you can name your "anonymous" functions, which can help understand stack traces
17:05slyphonoh, that shows up in the stacktraces?
17:05slyphonnice
17:05chouseryes
17:05slyphoncool
17:05chousermangled, but they show up
17:06hiredmanmaybe clojure.stacktrace could include a de-mangler
17:08slyphongak!
17:08rhickeydoes clojurescript have a js reader for clojure data?
17:09chouserno, clojurescript relies on clojure's own reader and analyzer
17:10hiredmanmy reader written in clojure could be bootstrapped :)
17:10chouserrhickey: perhaps clojurescript still works well enough to produce a js version of one of the clojure-readers-in-clojure? :-)
17:10slyphonchouser: this is a clojure interpreter in javascript?
17:10rhickeychouser: too many moving parts, a reader is so easy
17:11chouserslyphon: no, it's a java program that compiles clojure source to javascript.
17:11chouserrhickey: ok
17:11slyphonwoah
17:11rhickeyespecially a reader for data
17:11chouserslyphon: clojure pre-1.0 source to javascript.
17:12slyphonyou guys are fucking crazy
17:12slyphon:D
17:13chouserWe won't give up until the only thing stopping Clojure from working on every conceivable platform are Apple EULAs.
17:13rhickeyhah
17:14hiredmanI guess the most complicated thing in the reader is syntax-quote, which you don't need for data
17:14slyphonchouser: hah!
17:14chouserrhickey: you're going to write a clojure reader in js??
17:14rhickeychouser: write sane web apps?
17:15chouserare you asking if I ever have? No. I've tried but they always end up crazy...
17:15rhickeydunno really, just seems like JSON is much less expressive than Clojure data
17:15chouserah
17:15rhickeychouser: no, not asking, speculating what I would do
17:16rhickeywhat do the current clojure->json thingies do with, e.g. sets?
17:18hiredman,(encode-to-str #{})
17:18clojurebot"[]"
17:18hiredman,(encode-to-str #{:a :b})
17:18clojurebot"[\"a\",\"b\"]"
17:18hiredmanbleh
17:28eyerisI have a regex that uses grouping. Is there a way, with the Clojure regex API, to get the indexes of the matching groups?
17:28dakroneanyone have a link to that image that explains which one agent/atom/ref/var to use depending on the concurrency needed?
17:28eyerisThis corresponds to the Java Matcher .start(int group) and .end(int group) members.
17:31Chousukeeyeris: I think you need to just use the matcher object directly
17:32eyerisChousuke: Okay, thanks.
17:50neotykI'm trying to build server that can server multiple REPLs at same time, can you guys advice me on how to do that?
17:51neotykand I would like those repls be separate, so if (def a 42) is executed on one it is not visible on second
17:52bendlasHave you looked into swank-clojure?
17:52hiredmanyou'll need either multiple jvms or classloader magicing
17:53neotykalso would like not to depend on executing in same thread, if I could store state of repl somehow for later "resuming"
17:53neotykmultiple jvm sound very inefficient
17:53neotykthan class loader magic it will be
17:54neotykat what level I'll stick it ? in my own reader?
17:55technomancysounds like you also want serializable continuations?
17:56slyphontechnomancy: don't we all
17:56neotyktechnomancy: something like that, so I could persist it and later resurect
17:56technomancyslyphon: =)
17:57neotykbendlas: no I haven't yet looked at it, was looking at hiredman's clojurebot sandbox
17:58neotyk,(def a 42)
17:58clojurebotDENIED
17:58bendlasI've written a timer with restartable delay, comments and advice on idiomaticness, etc. would be helpfull http://gist.github.com/379981
17:58neotykbut would like to be able to do that from multiple clients
17:59bendlasdifferent namespaces are not an option?
18:00neotykwould like to provide users real feel of clojure
18:00bendlasfeel free to tell me if that's stupid, I'm noob to clojure
18:01neotykso (ns ...) woudl be honored as well
18:01hiredmanyou could possibly patch Namespace.java to persist things to a database
18:01bradfordanyone know the fastest way to do a remove-at on a vec?
18:01bradfordI'm currently doing two subvecs and then a concat - which feels bad, since it must the be vec'd again to get the result.
18:02bendlasright, you want to enforce separation
18:02neotykyes, something like execution context
18:03bendlaslike a sandbox (in a sandbox it would be then :)
18:03neotykso two clients execute same (def a 42) but it ends up in different contexts
18:04neotyksandbox has one context
18:04bendlasyeah, but maybe there are frameworks to run multiple sandboxed environments in the same vm?
18:05neotykwell, are there any?
18:05djpowellbradford: i'm surprised there isn't a remove function for vectors
18:06bradforddjpowell: me too but I can't find one
18:06djpowellbradford: i'd guess subvec would work
18:06bradforddjpowell, I am using two subvecs and a concat now - but then i have to call vec on the result and it feels like there must be a better way.
18:08technomancyIIUC vectors aren't designed to be resized easily (apart from conjing on the end)
18:09djpowelland popping off the end
18:09bradfordtechnomancy, djpowell: yea, but they are designed for subvec, so remove-at should be similar
18:10technomancysubvec is ... kind of a hack
18:10bradfordit's just the normal structure sharing trickery, right?
18:10technomancyyeah, but it doesn't let the original get GC'd
18:11technomancyunlike most persistent operations
18:11bradfordah, i see
18:11bendlasisn't it the same issue with substring?
18:11bradfordinteresting.
18:12bendlaslike .getSubstring
18:13djpowellyeah Java's .substring shares the underlying array
18:14_brian2_noob question> Is there an easy idiomatic way to to convert between various kinds of collections? ie to convert a list into a set seems to require a name to a reference and doseq through the list
18:14lancepantz_brian2_: i think you're looking for into
18:15_brian2_oh, ok, thanks
18:15djpowelland if you want to convert to the same collection type, but don't know the type, then (into (empty c) (f c))
18:35dsantiagoHow exactly does the extend macro add to an existing class?
18:55kmqathey all, i'm trying to build labrepl under netbeans via maven. maven can't find the clojure and clojure-contrib 1.2.0 master snapshot jars, even though the build.clojure.org/snapshots repository is specified in the pom and i can find the jars there if i browse manually. thoughts?
19:39defnhttp://groups.google.com/group/clojure/browse_thread/thread/e704414cf36ef2aa : Could anyone comment on whether or not this information is still relevant? (Namely, chouser and rhickey's posts at the end)
19:41defnim trying to serialize a ref containing a map a couple levels deep
19:54kmqatfixed my labrepl problem. just had to switch from netbeans embedded maven 3 to maven 2 and delete my local repository. odd.
20:01chouserdefn: yeah, you need to using binding with *print-dup*
20:02dsantiagoWhen you call extend, can your functions in the map of implementations be compiled functions? Or do they need to be the source?
20:03chouserdsantiago: they're regular function objects, so they can come from anywhere.
20:03dsantiagoHm, that's what I thought.
20:03dsantiagoI keep getting "Unable to resolve symbol: this in this context" as an exception.
20:04chouseryou need to accept 'this' as an initial argument
20:05dsantiagoYeah, I am.
20:09dsantiagoOh, does the protocol have to be a symbol? It appears to a map containing all the data of the protocol.
20:09defndo i understand correctly that instead of using def instead of a defn i should be using alter-var-root or something like that?
20:09defns/instead/inside
20:10defni'd like to do something like (defn foo [] (def *x* "foo"))
20:10defnand have it be accessible everywhere
20:12chouserI don't think it's ever recommended to put def inside a defn
20:12kzarWhat kind of pause do you leave between pages when you're scraping a website?
20:13_atodefn: yep, use (def foo) (defn foo [] (alter-var-root foo "foo")) -- I assume this is for initialization
20:13defn_ato: it is, thanks
20:13chouserdsantiago: a protocol is just a map with specific keys/values
20:13technomancyhow is it that Stuart H was able to co-teach a class with rhickey and still not learn how Clojure is pronounced? =)
20:14defntechnomancy: haha
20:14_ato,(doc alter-var-root)
20:14clojurebotDENIED
20:14hiredman./jrepl.sh
20:14hiredmanwhoops
20:14dsantiagochouser: Yeah. It's just weird, I get different errors when I write it all out myself, vs when I try to extend in my little macro.
20:14defnklo-jerr
20:15defnalso technomancy -- thanks to you for that info on refactoring mire -- that's where i remember reading about using alter-var-root, nice write up
20:15_atodefn: whoops you'll probably need to #' quote the var and pass it a function, but yeah you'll figure it out
20:15technomancydefn: great. I hope it doesn't make you go off and actually start using alter-var-root all over the place though. =)
20:16technomancybut it is good to know about
20:16chouser(extend AType AProtocol {:foo (fn [this x y] ...)}) should do it. Where are you getting "undefined 'this'"?
20:16technomancyit helps to start thinking of vars as reference types; it's easy to miss that
20:16defntechnomancy: haha certainly not -- this is just for reading in some serialized stuff -- mainly this is just for the ease of the user
20:18dsantiagoI have a list of protocol->{:map of-fns} pairs, and I try to splice that into extend just like you have it. Main difference being that the functions are compiled. Then it throws up that exception.
20:18dsantiagoI realize it's clearly my macro, I just checked all the arguments and it appears to be what you'd want.
20:20chouserdsantiago: perhaps paste your macroexpand output somewhere?
20:20defntechnomancy: _ato alluded to using #' and passing a function -- here is what im doing: (def *foo*) (defn init-foo [] (alter-var-root #'foo (ref (do some stuff here)))
20:21defnerr #'*foo'
20:21defnthat doesnt seem to work -- i get a "No message" error
20:21dsantiagochouser: I'd love to, but the exception happens before macroexpand outputs anything.
20:21chouserheh. ok, paste your macro?
20:21dsantiagoOK.
20:22chouserlisppaste8: url?
20:23technomancydefn: I don't know if earmuffs are appropriate here
20:23technomancythey generally signal rebinding at runtime
20:24defnnoted
20:24technomancyas long as you feel your mutability is constrained enough not to cause issues
20:25defnis the way im writing that correct in general? or do i need to lose parens around ref? something isn't right there...
20:25dsantiagochouser: https://gist.github.com/af5bd3ad714a11eb58d4
20:25technomancydefn: well alter-var-root takes a function as its second arg
20:26technomancyso maybe you meant something like (alter-var-root #'foo #(assoc %1 %2) :stuff-from-file)?
20:26defnyeah i dropped the parens around ref so it is (alter-var-root #'myvar ref (deserialize stuff))
20:27technomancyif myvar is already a ref then you should use ref semantics to alter it
20:27defnit is not a ref yet, it is just (def myvar)
20:27defni was going to make it a ref when i deserialized the file
20:28technomancyright, but if it's going to be a ref in the end why not make it a ref pointing to nil up front?
20:28defngood point :)
20:28technomancythis is why I debated even mentioning alter-var-root =)
20:28defnhaha
20:31currivantest
20:33currivanDoes anyone know how to set -Xmx type parameters from 'lein swank'?
20:34defncurrivan: yes
20:34defncurrivan: M-x customize-group swank-clojure
20:34technomancyactually doing it from Emacs will only affect M-x swank-clojure-project
20:34currivanBut I'm running lein swank from the command line and connecting, not launching through emacs.
20:34defnunder swank-clojure-extra-vm-args you can do (list "-Xms256m" "-Xmx1024m") or whatever
20:34defnoh yeah good point
20:34technomancycurrivan: try setting the JAVA_OPTS environment variable for lein swank
20:35sattvikrhickey: Should gen-class support annotations on fields? At the moment, it seems like the only field the user has much control over is the state field.
20:35currivanThat's an environment var or can it be set in project.clj?
20:35technomancycurrivan: no way to set it in Clojure since it must be set before the JVM launches
20:35technomancyso yeah, env var
20:36currivanOk, thanks, I'll try that.
20:36defnit would be nice if there was some sort of config in the lein project dir where we could set variables like that
20:36chouserdsantiago: you're printing the (concat ...) output. that doesn't really look like the forms extend takes...
20:36lancepantztechnomancy: i think i saw you talking about adding a leinrc at one point, is that still in the cards?
20:37technomancylancepantz: depends on demand I guess. it'll be a couple releases out if it happens.
20:37technomancyif you're volunteering naturally that changes things... =)
20:37dsantiagoOh.
20:37lancepantz:) it would be useful, but there's other solutions to the problem, so i agree its a low priority
20:38technomancylancepantz: what we need more of is people wandering in here thinking, "I am trying to learn Clojure, but I need a good problem to get started with."
20:38technomancy"delegated!"
20:39lancepantzhopefully thats on the rise!
20:39dsantiagochouser: Not sure I see what you mean.
20:40currivanRelated question, is there any way to reconnect to a lein repl after disconnecting from emacs?
20:40Raynestechnomancy: Doesn't seem to be.
20:41technomancyRaynes: oh, it's started?
20:41Raynestechnomancy: 3 days ago.
20:41defntechnomancy: we're a rare breed, we irc'ers
20:41technomancycurrivan: I think that might be impossible due to a bug
20:41technomancyneeds investigation
20:42chouserdsantiago: (count (concat ...)) is 1
20:42defnlol technomancy im still struggling on this alter-var-root thing, (def foo (ref nil)) (alter-var-root #'foo (dosync (ref-set foo (deserialize myfile))))
20:42chouserdsantiago: I think you want the count to be even
20:43technomancydefn: M-s is your friend
20:43dsantiagoRight, right.
20:43dsantiagoOK, thanks.
20:43defntechnomancy: :)
20:43technomancythat is: get rid of (alter-var-root #'foo
20:43defnoh my god -- what was i thinking!?
20:44hiredmangood
20:45technomancy=)
20:45dsantiagoThanks a lot, chouser. I wasn't seeing that.
20:54currivananyone there
21:00chouserdsantiago: np
21:10rhickeysattvik: no, not until gen-class has fields more like deftype does
21:14sattvikrhickey: Thanks, do you have a few minutes? I have a number of questions about what annotations should be supported and how. Or would it be better for me to write an e-mail, comment on the ticket, or post on the dev mailing list?
21:14rhickeysattvik: shoot
21:15sattvikrhickey: Constructor annotations? If so, I am guessing something like {^{Deprecated true} [String] []}
21:16rhickeysattvik: I guess that's ok, if it's easy
21:18sattvikrhickey: How about method annotations? At first I thought it would be done like deftype, but what about inherited/overridden methods? It seems like the annotation would have to be read from the implementing function.
21:20rhickeysattvik: let's leave out inherited/overriden for now.
21:21rhickeyjust support the methods in :methods
21:23sattvikrhickey: OK, that's fine. Then I won't worry about :init, :post-init, :exposes, and :exposes-methods either, for now.
21:23rhickeyright
21:24sattvikrhickey: However, parameters for methods should be supported. I think you did this earlier today. Wasn't there something else?
21:25rhickeyparameters for methods are up now. So, types, methods, params, fields
21:26sattvikOK, sounds good. For gen-class, it will support types, non-overriding methods, and method params. I have types working. Perhaps I'll finish the rest tomorrow.
21:27rhickeysattvik: cool - thanks!
21:29sattvikNo problem. It is a fun task. Thanks for your input.
21:56currivanAnyone here? What's a better server?
22:03livingstonif i have a java string array in the form of k1 v1 k2 v2 ... obviously I can get that into a clojure seq but what's the fastest easiest way to turn that into a map
22:03defncould anyone comment on the appropriate use of earmuffs?
22:04defnnote: i will roll my eyes at you if you say something about wearing them when it's cold outside.
22:04livingstonobviously I could do that with recur and conj but I bet there is something slicker
22:04defnlivingston: some interleave zipmap combination or something?
22:05lancepantzthats what i was about to say
22:05hiredman,(let [x (into-array [1 2 3 4])] (zipmap (take-nth 1 x) (take-nth 2 x)))
22:05clojurebot{2 3, 1 1}
22:05chouser,(apply hash-map (into-array [1 2 3 4]))
22:05clojurebot{1 2, 3 4}
22:07livingston(into-array [1 2 3 4])
22:07livingstonwhoops wrong window
22:07chouserdefn: earmuffs are for vars that you intend to be thread-locally bound with 'binding'
22:07Blktdoes anyone know where to find a good clojure.contrib.sql example? (already looked at sql tests)
22:08remleduffIf I have collections a and b, where b is either the same size as a, or nil, is there an elegant way to map over both of them without some sort of if?
22:09Blktwhat function do you have to map?
22:09remleduff(map + [1 2 3] [1 2 3])
22:09remleduff(map + [1 2 3])
22:09Blkt,(map + [1 2 3])
22:09clojurebot(1 2 3)
22:10Blkt,(map + (1 2 3) (4 5 6))
22:10clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
22:10remleduffI'm calling an enlive template function that either takes "items" or "items" and "ranks"
22:10Blkt,(map + [1 2 3] [4 5 6])
22:10clojurebot(5 7 9)
22:11remleduff,(map + [1 2 3] nil)
22:11clojurebot()
22:11remleduffThat's my problem
22:11Blkt,(map (lambda (x y) (cons x y)) [1 2 3] [4 5 6])
22:11clojurebotjava.lang.Exception: Unable to resolve symbol: lambda in this context
22:11defnlambda!? :)
22:11Blktsorry
22:11Blktthat's true
22:11defnhaha it's fine i know wha tyou mean
22:11livingstonchouser: hiredman: apply hash-map is probably effecient enough, that's probably not cons-ing up too much compared to the zipmap solution, I don't thing, right? over the zipmap option (which seems more confusing)
22:12Blkt(map (fn (x y) (cons x y)) [1 2 3] [4 5 6])
22:12Blkt,(map (fn (x y) (cons x y)) [1 2 3] [4 5 6])
22:12clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
22:12livingstonBlkt: nice, I think that way still too ;)
22:12defn,(map #(fn [x y] (cons x y)) [1 2 3] [4 5 6])
22:12clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--11884$fn
22:12Blkt:D
22:12defnblech
22:13Blkt,(map (fn (x y) (cons (list x) (list y))) [1 2 3] [4 5 6])
22:13clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
22:13Blkt...
22:13livingston,(map (fn [x y] (cons x y)) [1 2 3] [4 5 6])
22:13clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer
22:13defnBlkt: dont put your x y in ()
22:13Blkttrue, sorry again :D
22:13defnoh i think i see what you need
22:13Blkt> Blkt: dont put your x y in ()
22:13BlktERC> > Blkt: dont put your x y in ()
22:13BlktERC> wtf
22:14livingstonapparently that's not the only error ...
22:14Blkt,(map (fn [x y] (cons (list x) (list y))) [1 2 3] [4 5 6])
22:14clojurebot(((1) 4) ((2) 5) ((3) 6))
22:14Blktalmost right...
22:14livingstonas ugly as it sounds you probably want to map apply in this case
22:14BlktI think that a struct or something like that should be better
22:14defn,(map #(cons %1 %2) [1 2 3] [4 5 6])
22:14clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer
22:15_ato,(map #(list %1 %2) [1 2 3] [4 5 6])
22:15clojurebot((1 4) (2 5) (3 6))
22:15hiredman_ato: please
22:15hiredmanlist
22:15livingstonor something close to mapping apply
22:15Blktremleduff: do you like it that way?
22:16livingstonhiredman: lol, at least there wasn't a (if (= x y) true)
22:16defnthis seems like something that could be done with destructuring
22:16_atoI think I missed the question
22:18livingstonah I know why I can't apply hash-map, unfortunately... sometimes I need to get the keys and values flipped to be {v1 k1, v2 k2 ...}
22:18Blktwhy would u need that?
22:19defn,(let [[[x y] [[1 2 3] [4 5 6]]] [x y])
22:19clojurebotUnmatched delimiter: )
22:19slyphonheh
22:19slyphonkind of looks like clojurebot is laughing at you
22:19livingstonBlkt: need what?
22:19defn,(let [[[x y] & [xs ys]] [[1 2 3] [4 5 6]]] [x y])
22:19clojurebot[1 2]
22:19Blktto flip keys and values
22:19defnhmm, i wonder...
22:20livingstonBlkt: because if I want to run my substitutions the other way... the inverse operation
22:21defnslyphon: oh, im sure the bot can't laugh
22:21defnslyphon: hiredman, on the other hand. ;)
22:21slyphonhahahaha
22:21slyphon:)
22:21slyphonclojurebot: botsnack
22:21clojurebotthanks; that was delicious. (nom nom nom)
22:21slyphon:D
22:21Blktlivingston: can't you wrap it in something like (zipmap (values *yourmap*) (keys *yourmap*))
22:22defnhaha
22:22slyphonit's funny, sometimes my kid will actually make that sound when he's really enjoying something
22:22rhudsonremleduff: (defn vmap [f & seqs] (apply map f seqs))
22:22slyphon(he's 14 months)
22:22defnlivingston: could you restate your question?
22:22defnor is this for remleduff?
22:23remleduff,(doc vmap)
22:23clojurebotTitim gan éirí ort.
22:24rhudsonNo, that's the defn of a vmap function that does what you want
22:24rhudsonThen (vmap + [1 2 3]) => (1 2 3)
22:24remleduffOh, gotcha! Thanks :)
22:24rhudsonand (vmap + [1 2 3] [4 5 6] ) => (5 7 9)
22:24slyphonso, if i wanted to model a jms MessageConsumer as a sequence of messages, and have it so that when the consumer was closed (it returns nil) the seq only returned nil, uhm, what should i look at for an example of how to do that?
22:24defnslyphon: haha, it's cute until they're 14 years, then the nom nom nom thing is just annoying
22:24livingstondefn: I just have the sequection (k1 v1 k2 v2) and I was just looking for an effeceint way to get that into the hashes {k1 v1 k2 v2} and also {v1 k1 v2 k2}
22:25slyphondefn: hahaha
22:25defnslyphon: and then you realize you're doing it yourself
22:25slyphondefn: yeah, then it's probably intentional
22:25slyphondefn: HA!
22:25remleduff,(let [m [{:id 1}{:id 2}{:id 3}] ](map assoc m (repeat :newkey) [4 5 6]))
22:25clojurebot({:newkey 4, :id 1} {:newkey 5, :id 2} {:newkey 6, :id 3})
22:25defnlivingston: ah okay
22:25remleduffThat's what I've ended up with since "item" is a map and rank can conceivably be considered an aspect of items
22:25defni really think this is possible with some fancy destructuring
22:26defnbut im just not skilled enough to do it
22:26livingstondefn: yeah so I can just loop recur with conj, but I thought there was something nicer
22:28Blktlivingston: (zipmap (values *originalmap*) (keys *originalmap*))
22:29defn,(let [m {:foo 1 :bar 2}, k (keys m), v (vals m)] [(zipmap k v) (zipmap v k)])
22:29clojurebot[{:bar 2, :foo 1} {2 :bar, 1 :foo}]
22:29Blkt,(let [mappa {a 1 b 2 c 3}] (zipmap (values mappa) (keys mappa)))
22:29clojurebotjava.lang.Exception: Unable to resolve symbol: a in this context
22:29livingstonBlkt: that'll reverse it but starting with the inverse that's a 3 pass solution loop conj is still better (and I think there is a built-in to flip maps)
22:30BlktI see
22:30remleduffdefn: How about (apply assoc {} [1 1 2 2 3 3]) ?
22:30defni wonder if there is something in contrib
22:30defnremleduff: that's pretty nice i think
22:32livingstonremleduff: that's the same as apply hash-map, but that still can't be modified to flip the k/v pairs in reverse
22:33slyphonthere's clojure.set.map-invert
22:33Blktdoes anyone succesfully used clojure.contrib.sql ?
22:34defnlivingston: why not?booya
22:34slyphonBlkt: yep
22:34defnclojure.set is great
22:34Blktslyphon: could u link me a good example?
22:34slyphonit's win
22:34slyphonBlkt: hrm
22:34Blktmy version fails badly...
22:35slyphonBlkt: i think i used this to get started (more or less) http://ericlavigne.wordpress.com/2008/12/28/using-postgresql-with-compojure/
22:35sexpbot"Using PostgreSQL with Compojure « Eric Lavigne"
22:35Blktthanks
22:35slyphonsure
22:36livingstonslyphon: I could invert it, but since I'd have to build the map in the first place to do that, I'd rather just build it in the right order at that time
22:36lancepantzBlkt: http://github.com/stuarthalloway/programming-clojure/blob/master/examples/snippet.clj
22:37Blktthanks a lot
22:37lancepantznp
22:37defni need to include stuart's examples in walton
22:38defnmaybe cut out all of the inner expressions from def and defn
22:40Blktmay I ask which kind of ide/editor you guys use?
22:40defnemacs
22:40lancepantzvim
22:40defnno, emacs! ;)
22:41lancepantznot saying it's better :P
22:41defnBlkt: frankly i think emacs is a better IDE-type environment, but if you know vim I wouldn't go out of my way to learn it.
22:41defnthey're pretty much the same thing, just different
22:41defnemacs is sort of nice because as i've learned clojure i've picked up a lot of emacs lisp as a sort of bonus
22:41lancepantzi think most people go with emacs/vim/netbeans depending on what they use
22:42lancepantzif i had to pick one to learn it'd be emacs
22:42Blktdefn: I mostly use emacs (though I'm not uberskilled with it) but I'm having problems configuring clojure-slime on Windows
22:42rhudsonI'll put in a vote for La Clojure (IntelliJ)
22:42defnBlkt: using elpa?
22:42Blkty
22:42Blktspawning child process: invalid argument
22:43defnyou shouldn't have to do much work at all IIRC, once you have elpa you just grab clojure-mode, clojure-test-mode, slime, slime-repl, and swank-clojure i think
22:43defnthen M-x slime
22:43defnor M-x swank-clojure-project and navigate to the project root
22:43BlktI was wondering if that's avoidable
22:43defni believe the first time you run M-x slime it will install clojure and clojure-contrib for you
22:44defnBlkt: if what is avoidable?
22:44BlktI had SBCL messed up on my laptop thanks to that autoconfiguration
22:44Blktelpa
22:44defnah, you can use SBCL + clojure without much setup -- think you just need to set some var for additional inferior lisps
22:45Blktwish it was that easy
22:45BlktI should dinamically load one of two different slime versions at emacs' startup
22:46Blktinferior lisp only doesen't work
22:46Blktfor what I've been able to do at least...
22:46BlktI'll try out, anyway, no ide anyone?
22:47defnenclojure?
22:47lithper1_two separate .emacs files should work
22:47Blktand two different launchers too
22:48Blktdefn: did you try enclojure?
22:49defni think i did for like 20min, but ive gotten used to my emacs setup
22:50defni like having choices
22:50Blkt:)
22:50defnand really, if something is messed up like your config, it's just a matter of time before you figure out the problem or write some elisp to work around it
22:52livingston,(reduce (fn [m [v k]] (assoc m k v)) {} (partition 2 '(v1 k1 v2 k2 v3 k3)) )
22:52clojurebot{k3 v3, k2 v2, k1 v1}
22:53livingstonthat's the best I figured out for that given a sequence such as that for input
22:56rhudson,(apply hash-map (reverse [:v1 :k1 :v2 :k2]))
22:56clojurebot{:k1 :v1, :k2 :v2}
22:57livingstonrhudson: nice, very clever
22:57livingstonpresumably that's even slightly less consing because of the no nested lists
22:58Blkt,(reverse [:v1 :k1 :v2 :k2])
22:58clojurebot(:k2 :v2 :k1 :v1)
22:58Blktnice
23:01chouserit's not actually a vector, right? Otherwise you should consider 'rseq'
23:02livingstonit's a Java string array actually (the seq operations just handle it) are Java arrays intercahable with vectors?
23:12defn,(type [1 2 3])
23:12clojurebotclojure.lang.PersistentVector
23:14slyphonis there a recommended way to mock java objects in clojure unittests?
23:14slyphonis there a mocking lib for java that's not sucktastic?
23:20rhudsonlivingston, do you need both forward & reverse maps from the same string array?
23:21livingstonrhudson: yes, but not at the same time
23:21livingstonsometimes I'll need it one way sometimes the other, why?
23:22rhudsonWell, (vec array) gives you a vector, presumably a simple copy of the whole array.
23:23rhudsonThen you can use (rseq v) to get the reverse map, and v to get the forward map
23:23rhudson,(doc rseq)
23:23clojurebot"([rev]); Returns, in constant time, a seq of the items in rev (which can be a vector or sorted-map), in reverse order. If rev is empty returns nil"
23:23livingston(i'm asking a RDF server for what it's mappings are from short-hand namespaces to long-form --- sometimes I'm translating one way, sometimes the other so...)
23:23livingstonoh very cool
23:24livingstonso if I vec the array off the bat is that any more or less expensive than whatever behavior I get if I just let some sequence handling function do it's business?
23:25rhudsonLikely not worth it for the forward case
23:26livingstonfor the reverse calse I'm just calling reverse on the java array, I'm assuming that will do the fastest thing it can, right?
23:26livingstoncalse -> case
23:27rhudsonlooks like (class (reverse array)) is a PersistentList
23:28rhudsonBut I don't know the implementation to know whether that's a chain of cons or something more efficient
23:30livingstonfair enough
23:30livingstonthanks
23:47livingstonif I have a var *foo* it's not expense to call (bindings [*foo* *foo*] is it?
23:48livingstonit would make my macro a lot more clean