#clojure logs

2010-01-17

00:42alexykcan transients be passed into defn's outside of those they were created in?
00:46aldebrn,(for [n (range 3)] (do (println "hello")))
00:46clojurebot(nil nil nil)
00:46aldebrn^ how come it doesn't println my "hello"'s?
00:47aldebrn(In my real example I have more in the (do) but they don't print)
00:47kanak1,(for [n (range 3)] (doseq (println "hello")))
00:47clojurebotjava.lang.IllegalArgumentException: doseq requires a vector for its binding
00:48kanak1,(for [n (range 3)] (doall (println "hello")))
00:48clojurebot(nil nil nil)
00:49qbg,*out*
00:49clojurebot#<StringWriter >
00:50qbg,(println "Foo")
00:50clojurebotFoo
00:50aldebrn,(doseq [n (range 3)] (println "hello"))
00:50clojurebothello hello hello
00:50qbgI guess the printing needs to happen before the value is returned...
00:51aldebrn(doseq [n (range 3)] (println "thank") (println "you"))
00:51kanak1,(for [n (range 3)] (dorun (println "hello")))
00:51clojurebot(nil nil nil)
00:52kanak1weird. in my repl, either one of dorun or doall also displays hello
00:53qbg,(dorun (for [n (range 3)] (println "hello")))
00:53clojurebothello hello hello
00:53qbgfor returns a lazy seq
00:53aldebrnGotcha!
01:00alexykis there update-in! finally?
01:00alexykfor transients
01:00qbgNot in the latest master branch
01:01alexykrrr
01:04alexykI'm not fond of this:
01:04alexyk,(persistent! (binding [assoc assoc!] (update-in (transient {:a 1}) [:a] inc)))
01:04clojurebot{:a 2}
01:04qbgWhy not write update-in! then?
01:05alexykqbg: am not sure how :)
01:05qbgSince that horrible hack you just did seems to work
01:06alexykit's chouser's so it should have :)
01:06alexykor _ato's
01:06qbg(defn update-in! [m ks f & args] (binding [assoc assoc!] (apply update-in m ks f args)))
01:06qbg(something like that)
01:06alexykah ok, you mean just defn'ize the hack
01:07alexykI was wondering if there's something deeper
01:07qbgThis is Clojure; the obvious often works
01:08alexyk:)
01:10qbgThe only real black magic I have found so far in Clojure is setting the :arglists metadata in a macro.
01:10qbgAnd I was only convinced my solution was right once I saw defn did that.
01:11qbgWeird stuff, but other than that good :)
01:13alexykalas, the hack fails: (persistent! (update-in! (transient {:a {:b 1}}) [:a :b] inc)) doesn't work
01:14alexykand that's my use case
01:17hiredman~def update-in
01:20alexykhiredman: so for transients, is it only the first assoc which must become assoc!, and the rest stay assoc?
01:21alexykor nested map must become transient too?
01:21hiredmanah
01:21hiredmanyeah
01:22alexyk (persistent! (update-in! (transient {:a (transient {:b 1})}) [:a :b] inc)) => {:a #<TransientArrayMap clojure.lang.PersistentArrayMap$TransientArrayMap@1d840cd>}
01:22alexykso I guess I need to persistent! every nested map too
01:22hiredmanupdate-in recursively calls update-in
01:23qbgHmm... You can't seq a transient
01:23qbgI guess that makes sense...
01:25alexyk(let [half-there (persistent! (update-in! (transient {:a (transient {:b 1})}) [:a :b] inc)) keys (keys half-there) vals (vals half-there)] (zipmap keys (map persistent! vals)))
01:25alexyk=> {:a {:b 2}}
01:27alexykI guess a transient map of transient maps makes sense for a nested structure
01:27hiredmanhmmm
01:27hiredmanI don't think so
01:30gibranianwhy doesn't my entries reach to other users, freenode says i should register, did flood of lasy night cause this?
01:30qbgI assume that you really need the transients for performance...
01:30gibranianhmm, they are successfully sent here, weird :)
01:31alexykhiredman: indeed, hack fails: (update-in! (transient {}) [:a :b] #(inc (or % 0))) => null pointer exc.
01:33gibranianwhy is clojure case-sensitive? is it for better communication with java or is it an independent design decision?
01:33chousergibranian: in a unicode world, case-insensitive is a bit scary
01:34hiredmanwhy would anyone write a case insensitive language?
01:34greghcase insensitive is so 80s
01:34alexykto please Lord Fortran
01:34chouserbesides, it helps prevent CLers from shouting all the time
01:35alexykand Mac HPFS non-plus
01:35qbgHey, that was just the reader's default behavior!
01:35chouserCAR
01:35chouserwhat did you say?
01:35chouserCDAAADADR
01:35chousershhh...
01:35qbgYou set the reader to case-invert ;)
01:35alexykchouser: how would yolu write update-in! ? :)
01:35alexykyou
01:36alexykto it works for this case: (update-in! (transient {}) [:a :b] #(inc (or % 0)))
01:37chouserhm, I thought I pasted code that did nested transients
01:37chouserbut it was a pain, and ended up rather slow
01:37gibranianso your argument is that it is old-fashioned, i see
01:38chousergibranian: we're mostly goofing off, I think.
01:38hiredmangibranian: why would you want it case insensitive?
01:38alexykchouser: I missed the nested ones
01:38chouseralexyk: not today, and I'm having trouble finding it now...
01:38gibranianchouser: sorry :) not yours, you had a point
01:40qbgYou know what CL has that Clojure doesn't? third.
01:40chouserthis does not seem right. I'm looking at http://paste.lisp.org/list/clojure?0 and not believing that's all the pastes.
01:40hiredmanhttp://delicious.com/clojurebot/pastbin
01:41gibranianhiredman: i think naming conventions based on case sensitiviry like fooBar causes repetitive strain injury
01:41gibranian:D
01:41qbgThis is why we have Emacs
01:42chouserClojure avoids both excessive caps and underscores
01:42gibranianqbg: emacs also causes repetitive strain injury, search for emacs pinky :)
01:42hiredmangibranian: fooBar can just as easily be used in a case insensitive language
01:42chouseroh, I just annotated someone else's
01:42hiredmanit just doesn't force you to use the same case everywhere
01:42chouseralexyk: this is what I was thinking of: http://paste.lisp.org/display/92238#2
01:42hiredmanhttp://delicious.com/clojurebot/pastbin+chouser
01:43qbgEmacs pinky is for the weak!
01:43alexykright right, now I remember
01:43gibranianqbg: anyway, i'm just fooling, i love emacs.
01:43alexykit was damn slow, but I wonder is it because of the transients nested?
01:44qbgLazy way not to get Emacs pinky: spend more time in IRC than in Emacs
01:44chouseralexyk: oh, I wouldn't assume so. Just in that case it was a poor solution.
01:44fanatico`qbg: doctor's orders.
01:44chouserhiredman: handy, thanks!
01:45hiredman:)
01:45alexykok, sleepy time, dreaming of transient sheep
01:45fanatico`remapping capslock to ctrl is also pinky-friendly.
01:49qbgEmacs foot pedals could be cool
01:50chouserqbg: wow. just... wow.
01:50qbgI only have two feet though...
03:37quizmecan you compile your own clj files into jars ?
03:37tomojjars are just zip files
03:38lypanovquizme: http://clojure.org/compilation
03:38tomojleiningen helps with clojure
03:38tomoj(or steal someone's build.xml and use ant)
03:42quizmeok that's neat
03:42lypanovleiningen lets you basically just call "lein uberjar" and it builds you the jar you need, using the above aot compilation. super easy.
03:46quizmei c
03:48quizmecan i ask a dumb question?
03:50quizmelet's say you wanted to make a big graph (with cycles) and do a depth first search, and update a counter on each node everytime you stepped on it. what data structures should you use?
03:51quizmeand would the counter be refs ?
06:06esbenawhen porting a java program (which uses a lot of polymorphism and overloading) to Clojure: is the idiomatic Clojure way to pass structs around, use multimethods for overloading, and redefine methods for polymorphism?
07:37LauJensenI'm becoming more an more troubled by this lack of feedback from futures and agents when they fail - The fact that they can fail silently is adding a huge amount of insecurity to the program and should get some attention
07:43the-kennyLauJensen: There's a proposal or something like this for better error handling in agents
07:44LauJensenI don't need to it be happen particularily graceful, I just need to know when something breaks.
07:46the-kennyLauJensen: Maybe this patch is interesting:
07:46the-kennyhttp://www.assembla.com/spaces/clojure/tickets/30
08:06dabdwould it make sense to support same arity overloading of functions if the user supplied type hints? http://pastebin.com/m14bcb6ad Or this should only be possible via multimethods?
08:30opqdonutthat would make sense wrt. the java dispatch system
08:32LauJensendabd: that sounds like the case for multimethods
08:41dabdLauJensen: I know multimethods support that I was just wondering if this could be also an alternative for overloading
08:41LauJensenNot to my knowledge
08:53LauJensenCan anyone tell me why lein doesn't find javax.mail here http://download.java.net/maven/2/javax/mail/mail/ when targeted with [javax.mail/mail "1.4.2"] ?
09:00RaynesLauJensen: Did you add it as a repository?
09:00RaynesIf not, you're going to need to do so.
09:00LauJensenMaven2 is automatically included
09:01RaynesMaven central is included. I'm pretty sure you'd need to add a repo for that.
09:01LauJensenDownloading: javax/mail/mail/1.4.2/mail-1.4.2.jar from central
09:01LauJensenThats a line from lein, and that file exists in central
09:02RaynesWell if the fine exists in central, of course it will find it.
09:02LauJenseneh?
09:02RaynesBut it isn't going to find it at the repo you linked.
09:02Raynesfile*
09:03RaynesUnless I'm misunderstanding something very crucial.
09:04RaynesI just woke up, you know.
09:08LauJensenWhats the syntax for :repositories?
09:22LauJensen[["id" "url"]]
09:27RaynesLauJensen: It's a map of repository names to urls IIRC.
09:27RaynesI'm eating a large bowl of chili at 8:30AM for breakfast.
09:27RaynesLauJensen: Maybe I am a redneck after all.
09:27Raynes:o
09:35LauJensenhehe, sure sounds like it
11:13neotykHi *
11:13neotyklooking for some help with ns macro
11:14neotykHave no idea how to do following: (ns test-clean (:refer-clojure :exclude [compile]) (:use [leiningen.compile :only [compile]]))
11:15neotykI get: compile already refers to: #'clojure.core/compile in namespace: test-clean
11:32Raynesneotyk: (:refer-clojure :exclude (compile)) and (:use [leiningen.compile :only (compile)]) would work, I imagine.
11:33neotykRaynes: let me try
11:34neotykRaynes: this: (ns test-clean (:refer-clojure :exclude (compile)) and (:use [leiningen.compile :only (compile)])) fails with: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
11:35RaynesI didn't mean for you to literally copy and paste what I said. :p
11:35RaynesHold on.
11:35somniumneotyk: did you add the exclude after compiling once?
11:35sethsneotyk: rather than use :use, is it too painful to fully qualify the path to leiningen/compile?
11:35sethsas a temporary workaround?
11:36somniumneotyk: your first example looks okay, but the runtime may have already refered clojure.core/compile into the ns
11:36Raynesneotyk: http://gist.github.com/279440
11:36neotykseths: no it should be fine, but I'm trying to understand how to use ns
11:36RaynesI wasn't sure how the :refer-clojure stuff worked. Never used it before.
11:37neotyksomnium: it might be the case as I run it in slime
11:37r2q2What is the name of that clojure made package manager?
11:37r2q2it uses leinengen
11:37sethsr2q2: leiningen is a build tool that can build jar files and download dependencies
11:38sethso
11:38neotykr2q2: clojars yoy mean ?
11:38r2q2yea yea
11:39neotykr2q2: this is called repository not manager
11:39r2q2yea sorry about the confusion
11:39somniumneotyk: in that case unmapping c.c/compile or restarting slime should get it to compile (if thas indeed the problem)
11:41neotyksomnium: when disconnected slime and swank-p... again still getting same error
11:42r2q2How do i get a listing of the jars on clojars?
11:43sethshttp://clojars.org/repo/
11:44r2q2seths: Thanks.
11:44neotykworks with lein test
11:45neotykso swank is bringing c.c/compile into ns
11:49r2q2If I want to keep my code private do I never do a lein push?
11:49sethsr2q2: yes
11:49sethsyou can do a lein install
11:49sethsthat just moves your jar to the local m2 repo, $HOME/.m2 for me
11:53neotykwhy for lein test on http://gist.github.com/279445 reports contains 0 assertions
11:54sethswhat's the file name?
11:54sethsshould match the ns
11:54neotykseths: test_clean.clj
11:58the-kenny,(doc for)
11:58clojurebot"([seq-exprs body-expr]); List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero or more modifiers, and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightmost fastest, and nested coll-exprs can refer to bindings created in prior binding-forms. Supported modifiers are: :let [binding-form expr ...], :while test, :when test.
11:58the-kennyseths: for is lazy
11:58sethsneotyk: there may be an issue with having "-" in the namespace
11:59sethsI have test-foo.clj and test_bar.clj in my test dir
11:59neotykthe-kenny: so I should take from it,
11:59sethsfull of blatant syntax errors and they aren't being reported
11:59the-kennyneotyk: Wrap it in a (doall
11:59neotyk,(doc doall)
11:59clojurebot"([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. doall can be used to force any effects. Walks through the successive nexts of the seq, retains the head and returns it, thus causing the entire seq to reside in memory at one time."
12:00neotykawesome
12:00sethsneotyk: my guess is your test file is not being evaluated at all... try putting random characters in it
12:01sethser /s/evaluated/executed/
12:01neotykseths: it is getting executed, doall did the trick
12:01sethsd'oh
12:01neotykor not :/
12:01sethssame thing?
12:02neotyknow it reports that there are two assertions
12:02neotykbut they should fail
12:02neotykmust be something with my test
12:07neotyk,(doc doseq)
12:07clojurebot"([seq-exprs & body]); Repeatedly executes body (presumably for side-effects) with bindings and filtering as provided by \"for\". Does not retain the head of the sequence. Returns nil."
12:08neotykthe-kenny: doseq seems like better than (doall (for ... for my case
12:25dabdthe only way to add documentation to a defmethod is through metadata?
13:52LauJensenBack in the day I used some getClassLoader/findResource hack to access resources in my project - Is there some helpers for Clojure that does that these days?
14:05esbenaI'd like to create an anonymous class, and invoke the constructor of the super class: new AbstractAction("Quit") { ... }, but how do I invoke the constructor using the clojure (proxy [AbstractAction] ...)?
14:09LauJensenWhats the fn to print the stacktrace from *e ?
14:18qbgLauJensen: (.printStackTrace *e)
14:18LauJensensanx
14:30Drakesonhow do you add extra repositories in a project.clj file?
14:31defnDrakeson: :repositories [["repo-name" "url"]]
14:33Drakesonthanks
14:34Drakesonhow do you exclude certain jars from bein installed?
14:35robwolfeDrakeson: you can't unfortunately
14:37Raynesdefn: Really? Phil said it was a map of repo names to urls...
14:37Raynesrobwolfe: I'm pretty sure you can...
14:38defnRaynes: what i just showed you works fine
14:38Raynesdefn: Then technomancy lied to me.
14:38Raynes:p
14:38defndamn phil
14:38defnlol
14:39LauJensen[log4j "1.2.15" :exclusions [javax.mail/mail
14:39LauJensen javax.jms/jms
14:39LauJensen com.sun.jdmk/jmxtools
14:39LauJensen com.sun.jmx/jmxri]]
14:39Raynesrobwolfe: Yeah, you can exclude indirect dependencies like LauJensen just showed.
14:39DrakesonLauJensen: wow! that's _exactly_ what I wanted to exclude!
14:39LauJensenDrakeson: :repositories [["maven2-repository.dev.java.net"
14:39LauJensen "http://download.java.net/maven/2/&quot;]]
14:39RaynesDrakeson: He can read your mind.
14:40DrakesonLauJensen: yeah, I just called it java.net, though :)
14:40robwolfeRaynes: you can exlude dependencies, but not what will be installed
14:41LauJensenDrakeson: That just didn't work for me, thats why I posted the whole thing
14:42ordnungswidrigI have a macro that expands to a call to defn, say (defmacro foo [] `(defn bar [baz] baz))
14:43ordnungswidrigAt runtime I get "Can't use qualified name as parameter: compojure-rest.r2/request"
14:44qbgDo you need parameter to be readable?
14:45qbg,(defmacro foo [] `(defn bar [~'baz] ~'baz))
14:45clojurebotDENIED
14:45ordnungswidrigqbg: Yes, I want it — I know I can gensym some. But
14:45qbg,(macroexpand '(defmacro foo [] `(defn bar [~'baz] ~'baz)))
14:45clojurebotDENIED
14:45ordnungswidrigOh, I only tried '~
14:46qbgI can't macroexpand with clojurebot? :(
14:46ordnungswidrigqpb: nope
14:46ordnungswidrigqbg: AFAIR
14:46ordnungswidrigHmm, you can't defmacro actually
14:46ordnungswidrig,(macroexpand (defn foo [])
14:46clojurebotEOF while reading
14:47ordnungswidrig(,macroexpand (defn foo []))
14:47qbgRemember to quote
14:47ordnungswidriglast trial:
14:47qbg,(macroexpand '(defn foo [] bar))
14:47clojurebotDENIED
14:47qbgI think it uses a regex...
14:47ordnungswidrigdefn is forbidden as well
14:48ordnungswidrig,(defmacro cond)
14:48clojurebotDENIED
14:48qbg,(eval (read-string "(+ 2 2)"))
14:48ordnungswidrig,(macroexpand 'cond)
14:48clojurebotDENIED
14:48clojurebotcond
14:48ordnungswidrig,(macroepand 'cond :a :b :c :d)
14:48clojurebotjava.lang.Exception: Unable to resolve symbol: macroepand in this context
14:49ordnungswidrig,(macroexpand 'cond :a :b :c :d)
14:49clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$macroexpand
14:49ordnungswidrig,(macroexpand '(cond :a :b :c :d))
14:49clojurebot(if :a :b (clojure.core/cond :c :d))
14:49ordnungswidrighell, polluting the logfile :-)
14:49ordnungswidrigqbg: but macro expansion is acutally allowed
14:50qbgI hope you can't call a certain static java method...
14:50qbgKilling clojurebot would be sad...
15:01chouser,(System/exit 0)
15:01clojurebotjava.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM.0)
15:01chouserqbg: that one? :-)
15:02qbg,(.getUptime (java.lang.management.ManagementFactory/getRuntimeMXBean))
15:02clojurebot4466784
15:02qbgchouser: yes
15:03mabeswhat is wrong with my syntax here? (use 'clojure.walk :only [:macroexpand-all]) (I know how to do this from the ns macro but from outside it)
15:03qbgHmm... That is kind of low...
15:03mabeser.. I had (use 'clojure.walk :only [macroexpand-all]) but that doesn't work
15:03chousermabes: (use '[clojure.walk :only [macroexpand-all]])
15:04mabeschouser: ah ok. thanks for answering
15:07chousermabes: sure!
15:07chouserthe use/require stuff is unnecessarily confusing, and up for a redesign.
15:16neotykchouser: looking forward to that
15:17chouserme too!
15:17mabesI'm glad I'm not the only one that gets tripped up by it then :)
15:19robwolfemabes: welcome to the club ;)
15:25neotykchouser: is there a time line for this redesign?
15:27esbenaanonymous function in Swing: how do I call 'this.dispose()'?
15:53RaynesPattern match you say.
15:54RaynesWho wrote that? I have a bone to pick with them. It was my idea - I just hadn't actually done it yet. :<
16:50dabdis it true that if a Java class extends Iterator I can automatically seq over it?
16:51chouseryou need to call iterator-seq on it
16:53dabdok I see. seq only works directly on classes implementing Iterable
16:56chouserah right, because you want to be aware when a seq might be (lazily) pushing your mutable Iterator around.
16:58ordnungswidrighmm, macros again. How can I use an argument to a macro as keyword at runtime?
16:58the-kennyordnungswidrig: maybe '~foobar?
16:59ordnungswidrigSay (defmacro foo [bar] …) And I want :bar at runtime
17:00the-kennyThere's a function, wait
17:00the-kenny,(keyword 'foobar)
17:00clojurebot:foobar
17:02the-kenny,(let [foo 42] `(keyword ~foo))
17:02clojurebot(clojure.core/keyword 42)
17:02the-kenny,(let [foo 'bar] `(keyword ~foo))
17:02clojurebot(clojure.core/keyword bar)
17:05ordnungswidrig(defmacro foo [bar] `(keyword ~bar)) then (foo a) will expand to (keyword a). I want it to expand to (:a)
17:06ordnungswidrigyou see the conversion to keyword must happen at macro time, right=
17:06ordnungswidrigs/=/?
17:09Chousukeordnungswidrig: `(~(:keyword bar))
17:09Chousukeoops
17:09Chousukewithout the :
17:10ordnungswidrigChousuke: thanks. thats exactly what I see in my REPL, now :-)
17:20ynnivanyone use queries with SC.DateTime's?
17:30nuggienis it possible to use the "for" macro with a binding list that is determined at runtime?
17:31qbgnuggien: how evil do you want to get?
17:31nuggiennot sure, clojure newbie still...
17:32qbgSince for is a macro, it doesn't have access to runtime values
17:33qbgYou could use eval, but yuck.
17:33qbgWhat kind of stuff do you want in the binding list?
17:33nuggienqbg: right, I saw http://bit.ly/88RZxj
17:35nuggienqbg: "for" was just an easy way for me to turn [[\a \b \c] [\y \z]] into ay, az, by, bz, cy, cz so I was just wondering if I could do this when the original vector is something determined at runtime
17:36qbgIf you just want all combinations of two items, you don't need to create the binding list at runtime
17:37qbg(defn pairs [a b] (for [x a y b] (list x y)))
17:37nuggienqbg: exactly my problem though, the two items vec is just an example. I won't know how many items will be passed into my function until runtime
17:37qbgIf you want n combinations, you could do it recursively.
17:38nuggienright, just thought there was something built into clojure i could use :)
17:38qbgThere might be something in clojure-contrib
17:39qbg(that does what you want)
17:39nuggienthanks, i'll have a look
17:39qbgHmm, since for is just the list monad, in theory you could build the chain at runtime...
18:02dabdwhy the documentation for empty? discourages the idiom (not (empty? and encourages (seq if the first is more intuitive http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/empty?
18:12chouser(if (not (empty? ...))) is a double-negative and needlessly deeply nested
18:13ChousukeAnd (seq foo) is just as clear to anyone familiar with clojure. :)
18:45dabdchouser: but the primary intention of (seq is to create a sequence not to use as a predicate, so it would be more natural to use (not (empty? when testing for emptiness
18:45dabdbut of course (seq is a "clojurism"
18:46dabdand shouldn't we let the compiler bother with removing the double negative? after all it is a hidden implementation detail...
18:52chouseranother primary use of 'seq' is to return null when collections are empty
19:19RaynesThank Fontosius, the greek God of fonts, for Deja Vu Sans Mono 9pt.
19:27alecwould anyone know of a clojure mode for gedit?
20:12dabdfor a mixed Java/Clojure project what is the recommended build tool?
20:13datkaMaven is always nice
20:15dabdclojure itself is build using just ant right?
20:15datkaYes
20:16chouserclojure includes a build.xml file for ant that compiles both java and Clojure AOT
20:16dabdI'm not familiar with ant or maven but I guess it would be better to learn maven
20:17dabdeven if people say it is scary
20:18datkaMaven is scary, but once you get used to it, its very nice
20:19datkaEspecially if you find yourself using many dependencies
20:19dabddoes maven completely replace Ant or it is necessary to use both?
20:20chouserI don't suppose anyone remembers if deftype on a protocol is still faster when the protocol is on an interface?
20:20datkaNo, you'll use the clojure-maven-plugin to compile
20:21datkaYou can still call out to ant if you want
20:21somniumchouser: I thought :on was removed from defprotocol
20:23chouseroh, perhaps you're right.
20:23rhickeyaargh - with metadata on functions, AOT-compiled core__init runs into a code size limitation...
20:25rhickeyand I thought I was almost done
20:26rhickey:(
20:29chousercode size!? I thought Java classes got pretty big.
20:29chouserhow can defprotocol generate its own named interface and not require AOT?
20:29rhickeythe init code is one big load method and one big static initializer
20:29r2q2why is everyone saying stuff twice
20:31somniumr2q2: it may be your client
20:31somniumr2q2: it may be your client
20:31rhickeychouser: there is now a peer cache for Clojure's dynamic classloaders
20:32rhickeyI figured why should the OSGi, Netbeans et al classloaders have all the fun?
20:33rhickeynone-of them are strictly hierarchical
20:35rhickeythis cache accomplishes 2 things - it makes the (dynamic) classes available across loaders, and it makes the load of bytecode with the same hash a no op, instead reusing the already-created class. Using the interface by name still requires AOT for proper resolution in all cases
20:35chouserI do remember you mentioning that before...
20:35rhickeythe generated interface is a nimplementation detail of dynamic use of protocols
20:36chouserI was asking because of the performance benefits of the real interface
20:36chouserno types on protocol method args?
20:36chouserseriously, it's like I look away for a week and everything that was once in my head is gone.
20:37rhickeythe benefit is best ascribed to defining protocol methods inside the deftypes
20:37chouserok
20:43alexykis there a shorter way to achieve this:
20:43alexyk,(let [string nil] (if string (.toLowerCase string) nil))
20:43clojurebotnil
20:43alexyki.e. lowercase if non-nil, nil if nil
20:44chouser(when string (.toLowerCase string))
20:44alexykso when returns nil when the cond if false?
20:45chouseryes
20:45alexykis
20:45alexykok, thx!
20:45somniumalexyk: so does if, for the record
20:45alexykha! so else-less if is the same as when
20:46alexykis "when" just a prettier clearer else-less if then?
20:46somniumkind of, when inserts a do
20:46chouserright, both.
20:46alexykah ok, with a body helper
20:47chouserit helps indicate that there is no else, and also that there may be multiple steps in the then
20:48alexykrhickey: I was surprised to find no update-in! in the core... Is there a reason it's omitted?
20:49alexykmy large reduce-able data are nested maps which I grow e.g. when scannin 100M twits. I'd really like to quickly do it with transients
20:49alexyke.g. a graph is {:from {:to [list of messages]}
20:49alexyk}
20:50alexykit would be really useful to have an efficient (update-in! graph [:a :b] some-f)
20:50somniumalexyk: did bashing directly on the cursors help performance any?
20:51alexyksomnium: didn't implement that yet, will try
20:52alexykbut seeing no update-in! in the core still disturbs me, so I hope to shed the light to the top here :)
21:07chousertransients are relatively new. I wouldn't read too much into the current lack of any particular helper fn
21:07chouseralexyk: have you tried to write update-in! ?
21:09hiredmandoes update-in! recursively create transient maps? does it persist them afterwards? it is not as simple as pressing a button and making it happen
21:12chouserautomatically persisting doesn't make much sense, I think.
21:13chouserif it's assuming all the interior maps and vectors are transients, then the ones it makes should be transient as well.
21:13chousera recursive transient or persistent! fn is probably trickier
21:14hiredmanalexyk: if you are heavily using transients on nested structures I would suggest just biting the bullet and going back and forth from mutable maps
21:15hiredmanyou are going through all this to pretend to have mutable maps
21:19chouserah, that was the problem. converting a single transient to persistent is O(1), but converting vector of transients to persistent is O(n)
21:29alexykhiredman: probably it's one way, growing the map as mutable
22:25chouserjust converted fingertrees from older syntax (with extend for protocols) to modern deftypes.
22:27chousermostly just deleted boilerplate -- looks much better.
22:34technomancyRaynes, defn: the correct answer is a map of repo names to URLs, but because of the way destructuring works, a vector of two-element vectors will have the same effect
22:34technomancy(specifying your own lein repos)
22:40technomancywilig: oh dang! thanks a bunch.
22:40technomancyI've been looking forward to getting that fixed for quite some time.
22:41wiligtechnomancy: Well, it's probably got bugs ;-) But it does work for me.
22:41wiligHow would you like it delivered?
22:41technomancyhave you got a github fork of the project?
22:42wilighmm, you know I have a github account, I guess that will work.
22:42technomancypulling from a git remote (github or not) is the most convenient for me
22:42wiliggive me a few minutes to tie up a loose end and I'll throw it up there.
22:42technomancyexcellent
22:43technomancyfeel free to use github pull requests, messages on the swank-clojure mailing list, or just bugging me on IRC to notify me of patches in the future.
22:44wiligheh, cool.
22:44technomancygood heavens: http://www.piratejesus.com/nerdcore/nerdcore017.gif
22:46wiliglol
22:46wiligthat's alot of work, to make a point.
22:51Raynestechnomancy: <3
22:51Raynesdefn: I win.
22:53technomancyfrom a destructuring perspective, the only difference between a (hash-)map and a vector of two-element vectors is guaranteed ordering
22:56RaynesRegardless. I still win.
22:57RaynesI'd like to thank the academy...
22:58chouserdid I miss something? what are you guys talking about?
22:58Rayneschouser: Somebody asked how you add repositories in a Leiningen project file.
22:58RaynesI said a map, defn said a vector of vectors.
22:59chouserah, ok. thanks.
23:06seba_I'm using c.c.generic.arithmetic to implement + - multimethods for my types. What do I do to avoid the need of refer-clojure :exclude [+ -] in the clients of _my_ ns ?
23:06technomancywilig: gotta go offline for a while (train going underground), but I'll catch up later.
23:06wiligsounds good
23:06technomancythanks for the help; much obliged.
23:06wiligmy pleasure
23:07chouserseba_: I don't think there's anything you can do. If they don't want clojure.core/+, they have to say so.
23:08seba_chouser: how would you merge, in client code, + implementations from several namespaces and different types?
23:09chouser"merge"? you can pick which one you want to get when you use an unqualified +, and then have to use namespace names or aliases for the others.
23:13seba_chouser: Hum ... I see .... so, if I have (deftype foo) in foos ns and (deftype bar) in bars ns, and both namespaces implement + multimethod, client code should use (foos/+ foo1 foo2) (bars/+ bar1 bar2) (+ 1 2)
23:13chousersure
23:13hiredmanseba_: if you are using the + multimethod in c.c.generic.arithmetic they would both use c.c.generic.arithmetic/+
23:13chousernow, a defmulti lives in a single namespace ... well, yeah, what hiredman said
23:17seba_then clients of my ns need to _know_ how to call +. Wouldn't be nice to have encapsulation there? is not the fact that my ns uses c.c.g.a/+ an implementation detail?
23:18seba_is there any way to trick clients to use c.c.g.a/+ without them knowing it? given that generic already has an implementation for Number
23:22seba_I'm thinking, for instance, on a DSL. I would want clients to call + for numbers and for DSL types without needing to know the inners of c.c.generic