#clojure logs

2009-03-16

00:13Mecdoes emacs have code completion?
00:22RaynesMec: There is a hack in the wikipage to make it tab complete.
00:22Raynesiirc
00:37Mec,(replace {0 'b 1 'a} ['a 'b])
00:37clojurebot[a b]
00:38Mecis there a way to replace by index instead of by value
00:39dreishassoc
00:40Mecah nice, thanks
01:21Mecany chance of a library function that creates an infinite sequence by repeatedly calling a function on an initial value?
01:21Mecsmells like recur
01:21Mecerr iterate
01:36hiredmanclojurebot: do you understand emotion?
01:36clojurebotthis model does not support emotionml as spec'd in http://www.w3.org/2005/Incubator/emotion/XGR-emotionml-20081120/
01:40hiredmanclojurebot: does rest ever return a unicorn?
01:40clojurebotrest never returns a unicorn
01:40cmvkk_Mec: repeatedly ?
01:41Mecnaw iterate is what i wanted, repeatedly doesnt take an init value
01:41cmvkk_oh, aha.
01:59Mecok how do you find the index of a value in a vector, i must be getting too tired
02:14hiredman,(find [1 2 3] 3)
02:14clojurebotnil
02:14hiredmanhmm
02:15hiredmanah
02:17hiredman,(map-invert [1 2 3])
02:17clojurebotjava.lang.Exception: Unable to resolve symbol: map-invert in this context
02:18hiredman,(clojure.set/map-invert [1 2 3])
02:18clojurebotjava.lang.UnsupportedOperationException: nth not supported on this type: Integer
02:18Mecsurely there's a way to search thru a vector
02:21hiredman,(let [v [1 2 3]] (first (filter #(= 3 (v %)) (range (count v)))
02:21clojurebotEOF while reading
02:21hiredman,(let [v [1 2 3]] (first (filter #(= 3 (v %)) (range (count v))))
02:21clojurebotEOF while reading
02:21hiredmanbah
02:21hiredmandunno
02:21hiredmanit's never come up
02:21hiredman,(let [v [1 2 3]] (first (filter #(= 3 (v %)) (range (count v)))))
02:21clojurebot2
02:22hiredmanwait
02:23hiredman,(map #(.getName %) (.getMethods (class [])))
02:23clojurebot("withMeta" "withMeta" "withMeta" "nth" "assocN" "assocN" "count" "pop" "pop" "cons" "cons" "cons" "empty" "create" "create" "create" "seq" "equiv" "valAt" "valAt" "assoc" "assoc" "entryAt" "rseq" "invoke" "add" "add" "get" "hashCode" "compareTo" "indexOf" "clear" "equals" "toString" "length" "isEmpty" "lastIndexOf" "contains" "addAll" "addAll" "size" "toArray" "toArray" "iterator" "remove" "remove" "containsKey" "set" "c
02:23hiredman,(.indexOf [1 2 3] 3)
02:23clojurebot2
02:23hiredman:P
02:26slashus2,(.length [1 2 3 4])
02:26clojurebot4
02:27hiredman,(.clear [])
02:27clojurebotjava.lang.UnsupportedOperationException
02:28Mecwell now
02:28Mecthat's refreshing
02:28hiredmansomewhat embarressing I did not remember that right away
02:30Meclooking in javaland completely slipped past me
02:31hiredmanit's a big place
02:31hiredmanthe kingdom of nouns
02:33slashus2Is something like indexof going to be in the core for vectors?
02:33slashus2and or sequences in general
02:34hiredmanwhy would it need to be?
02:34hiredmanit is already there
02:35hiredmanI imagine we just need a big honking like to the javadoc for Collections
02:36hiredman~jdoc java.util.Collection
02:36hiredmanlink
02:40heanol~clojurebot
02:40clojurebotclojurebot is amazing
02:40heanolhehe
02:40heanolare there any sources for the bot?
02:40hiredmanclojurebot: where are you?
02:40clojurebothttp://github.com/hiredman/clojurebot/tree/master
02:41heanolthanks
02:41slashus2hiredman: Aren't things like "count" alternatives for the .length in a collection?
02:42hiredman~def count
02:42slashus2I am looking at the source code. It doesn't use .length I see.
02:43hiredmanmy internet is so slow
02:43hiredmanstill waiting for that to load
02:44slashus2I am looking at the count method in RT
02:44hiredmanI am headed there
02:44slashus2It kind of unifies the different length sizeOf getLength things.
02:45hiredmanhah
02:45hiredmangoogle code thinks this file is under the bsd license
02:48hiredmanI guess that is the reason for count
02:48slashus2Things were the api is not consistent on the java side may give incentive to cook something up in RT. That may not be the case with indexOf.
03:04RaynesMec: I just got a bit of your can't-spell-for-shit blues. There is no matching method .setVisable in swing ;)
04:59Lau_of_DKHey everybody
07:05Lau_of_DKIm running a websolution out of compojure/jetty as a servlet - Anyway to force the content-type in the header to be text/html instead of text-plain ?
07:15Lau_of_DKI got it, nvm
07:47MecRaynes: what's the actual method?
08:16Chouserrhickey: welcome back
08:17rhickeyChouser: thanks - did you hold down the fort?
08:17Chousernope, no need. The bench keeps getting deeper.
08:17rhickeythat's great
08:18rhickeyQCon was awesome
08:18ChouserI didn't realize you had several talks until the play-by-play on twitter.
08:19rhickeyyeah, the second talk was a new one - it went pretty well:
08:19rhickeyhttp://olabini.com/blog/2009/03/qcon-london-thursday/
08:19Mechmm not and nil? seem identical, do they have an oppisite
08:20Chousernot and nil? return different values for an arg of false
08:22Lau_of_DK"rich spent alot of time talking about state" Hmm, sounds familiar :)
08:22Mectrue enough chouser
08:23rhickeyThe state talk was the best formulation of some of the key ideas of Clojure I've come up with so far - I'll be including it in my ILC tutorial Sunday
08:23Lau_of_DKILC?
08:24rhickeyhttp://www.international-lisp-conference.org/2009/index
08:24Lau_of_DKOh that one - This talk you gave has some interesting slides, but is the talk itself available somewhere?
08:25Lau_of_DKRE ILC, cool man, you'll be speaking with Gerald Jay Sussman :D
08:25Holcxjorhickey: Thanks for the talk on Thu evening -- I tried to talk to you in the pub afterwards but you were gone all of a sudden
08:25rhickeyQCon records everything, but they dribble them out over time - I had two talks and an interview recorded
08:25Lau_of_DKk
08:26Mecany chance of screencasts on your recent talks?
08:26rhickeyHolcxjo: yeah, I followed some people upstairs, but the group split
08:26rhickeyMec: they'll come to the InfoQ site over time
08:27rhickeyLau_of_DK: Sussman is a great speaker, I'm psyched to see his talk
08:27Mecexcellent
08:28Lau_of_DKrhickey, I can very well image *jealous*
08:28Lau_of_DK:)
08:28rhickeyI spent a couple of hours in a pub in a fascinating conversation with Joe Armstrong (Erlang)
08:28Lau_of_DKs/image/imagine
08:28Lau_of_DKcool- Anything interesting come out of it ?
08:29rhickeyMet also a couple of other Erlangers - Steve Vinoski and Ulf Wiger - very nice guys and receptive to Clojure
08:30rhickeyLots of other really interesting people at the conference as well
08:31rhickeyThis is probably the best exposure a Lisp has had at an industry conference in a long time
08:35Lau_of_DKSounds very cool
08:35Lau_of_DKGuess you've hit the bigtime now :)
08:36Lau_of_DKA little disappointing maybe, that you were in London and didnt stop by DK, but we can forgive
08:36rhickeyLau_of_DK: not quite :)
08:36Lau_of_DKno?
08:40rhickeyLau_of_DK: there was a passing mention by the organizers of http://jaoo.dk/aarhus-2009/
08:50Lau_of_DKI haven't heard of that before, but if you decide to show up, please keep me posted
09:35Meccan you (apply recur list)?
09:36Chouserno, recur is a special form
09:36Meci suppose i can just destructure the binding
09:42ChouserCompiler$FooExpr classes are very ... mutable.
09:55keithbIs there a difference between the meanings of ; and ;; as comment indicators? I've seen both used.
09:55gnuvincekeithb: it's more of a convention: ; is used inline, ;; is usuall on its own line
09:55gnuvince;; example function
09:56fogusI think ;; just makes things stand out a little better
09:56gnuvince(defn foo []
09:56gnuvince (+ 3 4)) ; greatest operation ever
09:56keithbgnuvince: fogus: Thanks.
09:58arbscht;; typically gets indented as well
09:58arbscht(defn foo []
09:59arbscht ;; greatest operation follows
09:59arbscht (+ 3 4))
09:59ChouserIs this a convention borrowed from an earlier lisp?
09:59arbschtfrom emacs :)
10:23rhickeyChouser: don't emulate that mutability. Mostly it's just for the intimately-related Parser class
10:24Chouserrhickey: some of it will be difficult to avoid, like parent pointers going from fnmethods on up.
10:24AWizzArdclojurebot: max people
10:24clojurebotmax people is 149
10:25AWizzArduh, it was 162 before
10:25Chouserclojurebot forgot some things
10:25AWizzArdI see
10:26rhickeyChouser: I'd like to see where it's not possible - one thing for sure is that I avoided passing some things up/down that now I would readily do rather than use the dynamic vars
10:32Mecis there a way to do default values for function args, without arity?
10:33AWizzArdWhat means "without arity"?
10:33Mecoverloading
10:33AWizzArdShould not every function have an arity? Even if it is 0? (in that case it is a constant or has side effects)
10:34Mecarity is the number of args
10:34AWizzArdso each function must have an arity
10:34Mec(defn f ([x] x) ([x y] (+ x y))
10:34AWizzArdanyway, you could make the function take hashmaps
10:35Mechmm
10:35AWizzArdhashmaps are the idiomatic way to do this in Clojure
10:36AWizzArdyou can call (f {:x 10 :y 20}) or just (f {:x 10})
10:37AWizzArdand it will (merge {:y (:x arg)} x) inside the function f
10:38AWizzArdif x does not contain an {:y value} it will use the {:x val} in x
10:38Mecah that could work
10:40AWizzArdoh, this should have been (merge {:y (:x arg)} arg) of course
10:41AWizzArdBut really, if this is just for such a small thing such as your f, then I suggest to overload f.
10:50Mecisnt there some function like append that lets you put 2 lists together
10:51dliebke,(conj {:a 1} {:b 2})
10:51clojurebot{:b 2, :a 1}
10:51Mecah concat
11:09hiredmanclojurebot: destructuring
11:09clojurebotdestructuring is http://clojure.org/special_forms#let
11:12hiredman,((fn [{:keys [a b c] :or {c 10}}] [a b c]) {:a 1 :b 2 :c 3})
11:12clojurebot[1 2 3]
11:12hiredman,((fn [{:keys [a b c] :or {c 10}}] [a b c]) {:a 1 :b 2})
11:12clojurebot[1 2 10]
11:19AWizzArdclojurebot: max people is 162
11:19clojurebotOk.
11:26danlarkinAWizzArd: *gasp*!
11:26AWizzArdhmm?
11:41danlarkinAWizzArd: you interfered with the max people count
11:41AWizzArdI resetted it to the last known entry.
11:41AWizzArdIt forgot some information.
11:44hiredmanthe machine crashed, and somehow the file was emptied, and I did not notice till the empty file copied over the backup
11:45Mecis there some way to (apply f list val)
11:46AWizzArdyes: (apply f list val)
11:46hiredmanwhat do you want that to do?
11:46Mec(apply f '(1 2 3) 4) -> (f 1 2 3 4)
11:46hiredmanah
11:46AWizzArdis val a list/vector?
11:46AWizzArddo (list val)
11:46AWizzArdor [val]
11:46AWizzArd(apply + [1 2 3] [4])
11:46AWizzArd,(apply + [1 2 3] [4])
11:46clojurebotjava.lang.ClassCastException: clojure.lang.LazilyPersistentVector cannot be cast to java.lang.Number
11:47AWizzArdgreat
11:47Mec,(apply list '(1 2 3) [5])
11:47clojurebot((1 2 3) 5)
11:47AWizzArd,(apply + 1 2 3 [4])
11:47clojurebot10
11:48hiredman,(apply (comp (partial apply conj) reverse list) [1 2 3] 4)
11:48clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
11:48hiredmanhmmm
11:48hiredman,(apply (comp (partial apply conj) list) [1 2 3] 4)
11:48clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
11:48hiredmanah
11:48hiredman,((comp (partial apply conj) list) [1 2 3] 4)
11:48clojurebot[1 2 3 4]
11:49Mec,(apply + (concat '(1 2 3) [4])))
11:49clojurebot10
11:49hiredmanhmmm
11:50Mecall ugly :x
11:50hiredman,(conj [1 2 3] 4)
11:50clojurebot[1 2 3 4]
11:50hiredman,(apply + (conj [1 2 3] 4))
11:50clojurebot10
11:51Mecthat only works if it's a vector, a list gets prepended
11:51AWizzArdof course
11:51dnolenis the Clojure equivalent of the atom predicate in Common Lisp (not (seq? x)) ?
11:52Chousukehmm
11:52replacaChouser: The ;,;;,;;; convention is not tied to emacs but is traditional predating even common lisp. Emacs "encourages" it, though, by auto-indenting comments based on the number of semicolons
11:52Chousuke,(not (seq? [1 2 3]))
11:52clojurebottrue
11:52Chousukeso not quite :/
11:53Chousuke,(not (coll? [1 2 3]))
11:53clojurebotfalse
11:53Chouser(not (coll? x)) is closer
11:53Chouseryeah
11:53Chouserreplaca: ah, thanks.
11:55dnolenChouser: thx
11:56dnolenwhat would be a good name for such a function since Clojure has it's own idea of atom?
11:58hiredmannot-a-seq?
11:58hiredmannot-a-coll?
11:58hiredman(def not-a-coll? (comp not coll?))
11:59dnolenthat's short and sweet like (atom x) :), I've been converting snippets of Common Lisp in my exploration of Clojure.
12:01AWizzArdin CL: (atom (vector 1 2 3)) ==> T
12:02dnoleninteresting so (not (seq? x)) is better AWizzArd?
12:02AWizzArdthe HyperSpec defines: (defparameter x (make-instance 'interface-1))
12:02AWizzArd(defparameter dp (slot-value x 'dis-pai))
12:02AWizzArdoops
12:03AWizzArdatom n. any object that is not a cons.
12:03AWizzArdthis is the right thing :)
12:04AWizzArdSo, the closest thing would indeed be (not (seq? x))
12:04hiredman~hyperspec is not applicable
12:04clojurebotIn Ordnung
12:04Chousukehmm
12:05AWizzArdhiredman: that makes not too much sense. Of course Clojure is different, but it was designed with (Common Lisp) in mind and took huge amounts of the experience of it.
12:05hiredman~what does the hyperspec say about clojure's vectors?
12:05clojurebothyperspec is not applicable
12:05AWizzArdI think it makes sense to keep some of the vocabulary that is used since a few decades.
12:05hiredman~what does the hyperspec say about java objects?
12:05clojurebothyperspec is not applicable
12:06hiredmananyway
12:06ChousukeAWizzArd: the CL meaning of atom is not very useful in a Clojure context :)
12:07hiredmanclojure has no cons cells, so it's all atoms
12:07dnolenChousuke: it is if your porting CL, I think it does, macros produce seqs for example
12:07dnolenchecking for not-seq? is useful
12:08ChouserI rarely use coll? and even more rarely (not (coll? x)), but both a *far* more common than seq? or (not (seq? x))
12:08Chousukednolen: I was talking about the "not a cons" definition of atom
12:08hiredmandnolen: there is nothing stopping a macro from return something that is not a seq
12:08AWizzArdChousuke: right, I agree. One could still argue that the verb "consing" still makes sense.
12:09ChousukeChouser: the more common form of (seq?) is probably (if (seq foo))
12:09ChousukeAWizzArd: well, yeah. but cons is not that common in clojure :)
12:09dnolenhiredman: syntax backquote returns seqs, that's probably the most common form for macroexpansion.
12:09AWizzArdChousuke: if the goal is to get the close to the original behaviour then (atom? some-vector) should return true.
12:09hiredmandnolen: sure, but:there is nothing stopping a macro from return something that is not a seq
12:09ChousukeAWizzArd: though perhaps full laziness will make it more common.
12:10AWizzArdwhat do you mean?
12:10dnolenhiredman: and then that's OK ;)
12:10hiredman~def future-call
12:10ChousukeAWizzArd: conj is more common that cons :)
12:10Chousukethan*
12:10ChouserChousuke: right, but of course 'seq' is not 'seq?'
12:10hiredmanthere are plenty of macros that actually return a java object
12:10AWizzArdyes, I mean with this full lazyness thing
12:10ChousukeAWizzArd: clojure.org/lazy
12:10Chousuke~laziness
12:10clojurebotIt's greek to me.
12:11Chousukehmm
12:11Chousuke~lazy
12:11clojurebotlazy is hard
12:11Chousuke:(
12:11ChousukeAs I understand it, with the fully lazy stuff, lazy-cons will get replaced by cons and lazy-seq
12:12Chousukeor has been replaced.
12:12Chousuke:P
12:12Chousukedepending on your view.
12:12hiredmanwill?
12:12hiredmanit's already happened
12:12Chousukeyeah, but not in a release :/
12:12Chousukeunless there was a new one I missed.
12:13cgrandrhickey: just found a bug in my patch to proxy, line 170 should read "(if (or (considered sig)" and not "(if (or (considered mk)"
12:16AWizzArdI think lazy-cons is not in svn anymore?
12:19hiredman,'lazy-cons
12:19clojurebotlazy-cons
12:19hiredman,`lazy-cons
12:19clojurebotsandbox/lazy-cons
12:19hiredmansure ain't
12:24AWizzArd,(/ 1M 3)
12:24clojurebotjava.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.
12:35AWizzArd,(.divide 1M 3M 10 BigDecimal/ROUND_CEILING)
12:35clojurebot0.3333333334M
12:48slashus2,(doc with-precision)
12:48clojurebot"([precision & exprs]); Sets the precision and rounding mode to be used for BigDecimal operations. Usage: (with-precision 10 (/ 1M 3)) or: (with-precision 10 :rounding HALF_DOWN (/ 1M 3)) The rounding mode is one of CEILING, FLOOR, HALF_UP, HALF_DOWN, HALF_EVEN, UP, DOWN and UNNECESSARY; it defaults to HALF_UP."
12:48slashus2,(with-precision 10 (/ 1M 3))
12:48clojurebot0.3333333333M
12:51slashus2I am getting this strange error in my repl (with-precision 10 (/ 1M 3)) java.lang.NoClassDefFoundError: clojure/core$binding__3596$var_ize__3598 (NO_SOURCE_FILE:32)
12:53gnuvinceif I find Clojure being significantly slower than Java (factor of b
12:53gnuvince(factor of 8), and that I know I don't have reflexion calls, where else would be a good place to look for?
12:57whiddengnuvince: are you doing a lot of mathematical operations?
13:00gnuvincewhidden: not a lot, no.
13:01gnuvincewhidden: my code: http://bitbucket.org/gnuvince/clj-starcraft/src/
13:03keithbgnuvince: VisualVM might be helpful.
13:03whiddengnuvince: have you profiled the code with a profiler?
13:03gnuvinceculprit(s) will probably be un src/starcraft/replay/unpack.clj and parser.clj
13:04keithbgnuvince: It's a free profiler for Java.
13:04gnuvincewhidden: I ran with -Xprof
13:04gnuvinceTells me about the functions I expected to see
13:04gnuvinceI started -Xrunhprof:cpu=times
13:04gnuvinceBut that takes forever to run, so I won't be able to give you any numbers for at least 15 minutes
13:08keithbgnuvince: In this code: (apply str (take-while #(not= % \u0000) bytes)))), is it a very large number of bytes? If so, does str do string concatenation or does it use a StringBuffer or such? The former could result in a huge number of objects, and possibly take much longer.
13:08whiddengnuvinced: i'd second the suggestion to use VisualVM - I think that would help to sort through the numbers
13:09gnuvinceNo GUI here though
13:09gnuvinceI'll need to try it at home.
13:09hiredman~def str
13:10gnuvincekeithb: never more than 32 bytes. However, (apply str) is the "normal way" to concatenate strings and it's pretty efficient (uses a StringBuilder internally and by using apply, uses only one instead of n if reduce was used)
13:12whiddengnuvince: I've found that doing speculation refactoring without had profile data is mostly useless. It's been my experience that the places you spend a lot of time are places you think safe/cold.
13:12keithbgnuvince: Thanks.
13:13gnuvincewhidden: my experience too: I dramatically improved performance after I found that reflexion was taking a huge amount of time
13:14gnuvinceBut now, I am not sure where to look except maybe try and make the code "lower level"
13:14whiddengnuvince: My quick cursorary glance, with my somewhat novice Clojure eyes, didn't see any egregious erors.
13:14gnuvince-Xrunhprof still running...
13:16Chouserafter reflection the next most common slow spots are boxing and unboxing in tight loops
13:16ChouserI haven't looked at your code, though, so I can't say it applies in this case.
13:17gnuvinceHow expensive is destructuring versus extracting elements manually? I'd say exactly the same?
13:19Chouseryou can look at the macroexpanded code -- generally has calls to nth for each arg
13:19hiredmanI recall someone mentioning it has a slow down
13:19hiredmanbut that was many months ago
13:20danlarkinit was a little slower in my experience
13:20danlarkinbut that was over thousands of function calls
13:21RaynesMec: .setVisible
13:21danlarkinso maybe don't use it in a tight loop, but otherwise it's unnoticeable
13:21RaynesI know, delayed response. Just woke up.
13:24RaynesOn a brighter note, I know how to spell 'visible' now.
13:26pjstadigso i have agents working with TC
13:27pjstadigthe next thing is clojure.lang.Atom
13:27hiredmanNice
13:27Chouserpjstadig: each 'send' may go off to a different host?
13:29hiredmanthat would be interesting
13:29pjstadighehe
13:29pjstadiggood question
13:29pjstadigthe agent has a queue
13:30pjstadigso i would guess that the first VM to pop the queue would do the work
13:30pjstadigthere would obviously be one thread pool per VM, since threads are a non portable object
13:31pjstadigi've only gotten them to work preliminarily
13:31Chouserok
13:31pjstadigi can (send *a* + 1) in one vm
13:31pjstadigand see @*a* => 2 in the other
13:32danlarkinpjstadig: I'm really excited about this
13:32pjstadigi had to basically replace the AtomicReference uses to get them to work
13:34pjstadigi had to add some synchronized blocks, so i'm not sure that I haven't changed some semantics
13:34pjstadigi'm just trying to get it working first, then to test and fix
13:34pjstadigdanlarkin: me too
13:35pjstadigdoes anyone have some Java concurrency foo?
13:35pjstadigi need to rewrite Atom to not use a java.util.concurrent.AtomicReference
13:36hiredmansounds scary
13:36pjstadigI'm guessing I can use a wait with a very small timeout?
13:36hiredman~jdoc java.util.concurrent.AtomicReference
13:36pjstadigthen kick back if the thread didn't get it's job done
13:36hiredman:(
13:36hiredman404
13:36pjstadig404 FAIL
13:36pjstadiger
13:37pjstadigmaybe i had the class name wronge
13:37hiredmannah
13:37pjstadig~jdoc java.util.concurrent.atomic.AtomicReference
13:37hiredmanit ah
13:38hiredman~I forgive you
13:38clojurebotI don't understand.
13:38danlarkin~clojurebot couldn't find the right javadoc URL so hiredman got mad and then suddenly...
13:38clojurebothiredman is slightly retarded
13:39danlarkinNooooo
13:39pjstadighehe
13:39hiredman:(
13:41pjstadigactually i guess i could just use a synchronized block to simulate compareAndSet
13:51gnuvinceand -Xrunhprof is still running
13:57rhickeypjstadig: you could just use synchronized - the reason atoms don't is that you can deadlock on nested swap!s
13:59blbrown_ltgnuvince, what version of the jdk are you running. I had issues getting runhprof to work with jdk5. Just a fyi
14:01gnuvinceblbrown_lt: sun-jvm-6 from Ubuntu Hardy IIRC
14:01gnuvincejava version "1.6.0_07"
14:02blbrown_ltOK, that should work fine. With 'hat' for example
14:02gnuvincehat?
14:02blbrown_ltif you run Xrunhprof, you may also want to use the heap analysis tool. to see the results of hprof
14:03gnuvinceIs that a command line argument?
14:04blbrown_lttry jhat
14:06blbrown_ltgnuvince, a small blog entry on how I use hprof. search for the term if you dont want to read. http://berlinbrowndev.blogspot.com/2008/12/basic-tools-for-monitoring-garbage.html
14:08pjstadigrhickey: so there's no deadlock problem for clojure.lang.Atom?
14:08rhickeypjstadig: nope
14:08rhickeynor for any other Clojure reference type
14:09rhickeyI'm working on a mutex reference type, which will avoid deadlock by constraining nesting
14:10gnuvincerhickey: hi, how did the UK trip go?
14:10rhickeygnuvince: it was awesome
14:10gnuvincerhickey: cool! :)
14:12gnuvinceblbrown_lt: thanks, bookmarked.
14:12gnuvincerhickey: I think ILC is next week, isn't it?
14:12danlarkinblbrown_lt: same, this is a useful writeup, thanks
14:12blbrown_ltsorry I keep bringing this up. does it make any sense to create a clojure based framework that uses springmvc and hibernate. I like the libraries and have used them for several years. And think for the business layer, clojure could help. integrating spring and hibernate. But then again, maybe it is time to completely start from scratch hmm. For example, I also wouldnt mind coming up with a new server pages framework (e.g. not jsp)
14:12blbrown_lt. I hate hjsp
14:12rhickeygnuvince: yes
14:13blbrown_ltdanlarkin, no prob. if you have websphere it even makes more sense
14:13gnuvincerhickey: good luck there, hope they're not like on cll in real life :)
14:13danlarkinblbrown_lt: you can help me develop madison...
14:14rhickeygnuvince: I spoke to Boston Lisp in the fall and they were a great audience, I expect the same, plus some more Clojure folks too
14:14blbrown_ltdanlarkin, what is madison
14:14pjstadig~clabango
14:14clojurebothttp://www.clabango.com/
14:14blbrown_ltplus, I am kind of too headstrong to work with others
14:15danlarkinblbrown_lt: http://github.com/danlarkin/madison/tree/master
14:16pjstadigsweet!
14:16blbrown_ltdanlarkin, I am assuming it is a web framework
14:16danlarkinblbrown_lt: eahup it is
14:17danlarkinyet another unnecessary web framework
14:18pjstadigYauwf
14:20hiredmanclojurebot: Yawfie?
14:20clojurebotYawfie is danlarkin's port of django to clojure
14:21hiredman:(
14:21hiredmanclojurebot: forget Yawfie
14:21clojurebotI forgot Yawfie
14:22hiredmanclojurebot: madison?
14:22clojurebotExcuse me?
14:22hiredmanclojurebot: madison is http://github.com/danlarkin/madison/tree/master
14:22clojurebotRoger.
14:24Chouserrhickey: an odd thing about this is that I have much more of Clojure available in the compiler now than exists at the top of core.clj
14:25Chouserit's be easier to make fn a 'special form' that expands to an instance form internally and analyzes that, than to try to write a fn macro at the top of core.clj
14:25Chousers/it's/it would/
14:28kefka`In Clojure, can purely functional calculations be assumed to be properly parallelized?
14:29blbrown_ltdanlarkin, I wouldn't say it is unncessary. There are still things broken with most j2ee web frameworks. And there aren't that many popular ones or that are different.
14:29danlarkinkefka: no...
14:29blbrown_ltdanlarkin, do you use any third party library. For example, in my approach, I want to use a couple of common existing frameworks
14:30danlarkinblbrown_lt: well it's definitely nowhere near complete yet, but no I'm not using like Hibernate or anything
14:30danlarkinI am using a few clojure libraries though
14:31kefkadanlarkin: Ok, so in order to ensure parallelism, should I be spwaning threads or using agents?
14:32danlarkinkefka: there're a few ways... agents, futures, pmap...
14:32Chouserclojure.parallel
14:33danlarkinpvalues
14:34netytanGood day ladies and gentlemen - could someone comment on the implementation of multimethods in Clojure. My contention is that they're implemented in the same way as CLs or Dylans generic functions. Is this factual?
14:35netytanMore importantly, do they have the same semantics.
14:35hiredmanwho are you contending with?
14:36cmvkk_for example, in clojure's multimethods you can define your own dispatch function, where in CL it just dispatches on type.
14:37kefkaWhere are futures discussed? Also, if I'm making a function call (f X Y Z) and want the evaluations of X, Y, Z to be done in parallel, what's the idiomatic/correct way of doing so?
14:38netytanhiredman: I'm engaged in a discussion with a friend and I don't like to lie.
14:38hiredman,(doc pvalues)
14:38clojurebot"([& exprs]); Returns a lazy sequence of the values of the exprs, which are evaluated in parallel"
14:38danlarkin(apply f (pvalues X Y Z))
14:38netytancmvkk_: I'm sure that you can waggle it. In any case don't let the CL guys year you say that CL can't do something :).
14:39cmvkk_heh
14:40keithbI know that proxy creates an instance of a subclass of a Java class, but can I create a subclass in Clojure, for the purpose of creating multiple instances of that subclass?
14:40Mecanyone know of a fast trick to add the digits of a number together?
14:40cmvkk_keithb, maybe using gen-class
14:40keithb(doc gen-class)
14:40clojurebotWhen compiling, generates compiled bytecode for a class with the given package-qualified :name (which, as all names in these parameters, can be a string or symbol), and writes the .class file to the *compile-path* directory. When not compiling, does nothing. The gen-class construct contains no implementation, as the implementation will be dynamically sought by the generated class in functions in an implementing Clojure na
14:40p_lcmvkk_: AFAIK you can change the way multimethods are dispatched with MOP :D
14:41keithbcmvkk_: Thanks.
14:41kefkaembarrassed on pvalues; should have looked that up before asking. Sorry.
14:42hiredmankeithb: I believe proxy makes one subclass per class (possibly class/interface combination?) and then after that just makes instances of that one subclass
14:42kefka,(doc future)
14:42Chouserkeithb: a class created by proxy is created at compile time and reused each time proxy is called for the same set of parent classes.
14:42clojurebot"([& body]); Takes a body of expressions and yields a future object that will invoke the body in another thread, and will cache the result and return it on all subsequent calls to deref/@. If the computation has not yet finished, calls to deref/@ will block."
14:42danlarkinkefka: don't worry about it, that's what we're here for :)
14:43Chousermaybe pvalues could be implemented on a seq of futures now, instead of via pmap.
14:44hiredmanpmap is a seq of futures
14:44kefkaI'm about to update to current version and pull clojure-contrib for something almost in production... anything I should be worried about?
14:45Chouserhiredman: oh. indeed it is. thanks. :-)
14:45hiredmanuh, have you crossed the lazy barrier already?
14:45kefkaI'm about to cross it.
14:45kefka,(doc rest)
14:45clojurebot"([coll]); Returns a possibly empty seq of the items after the first. Calls seq on its argument."
14:45hiredmanit looks like pvalues uses map, not pmap
14:45keithbChouser: Sorry, I may have asked you this before, but in the code at http://gist.github.com/80000, if I call it multiple times with different behavior arguments, the values returned will all be instances of the same class?
14:45kefka,(doc next)
14:45clojurebot"([coll]); Returns a seq of the items after the first. Calls seq on its argument. If there are no more items, returns nil."
14:45kefka,(seq nil)
14:45clojurebotnil
14:46kefka,(next [1])
14:46clojurebotnil
14:46kefka,(rest [1])
14:46clojurebot()
14:46kefkaI see that change. It used to be that (rest [1]) was nil and thus logically false.
14:46Chouserkeithb: yes
14:47Chouserkeithb: try a couple and compare their class names.
14:47Mecis that just to kind of force people to use next?
14:47kefkaSo the behavior of 'rest has changed? Any other differences?
14:47triddellFor you current (or future ;) Ubuntu/Emacs uses out there I've updated my tutorial: http://riddell.us/tutorial/slime_swank/slime_swank.html
14:47hiredmankeithb: have you read the lazy page on clojure.org?
14:48triddellI broke it into three pieces now. One for basic clojure, one for emacs and one for slime/swank.
14:48hiredmankeithb: http://clojure.org/lazy
14:49pjstadigcool
14:49marklartriddell: thanks, I used that to get setup the first time :)
14:49triddellI plan to add some tutorials on git/egg and maybe muse and android in the future
14:49Mecany thoughts on combining :while and :when in a for?
14:49keithbhiredman: No, but I will. ;)
14:49ChouserMec: go for it
14:49pjstadigtriddell: any thoughts about using M-x clojure-install to set everything up?
14:50hiredmanit has a section on "porting"
14:50triddellmarklar: your welcome... hope it helped... got a bit out of date
14:50MecChouser: lol, i mean is it possible, i dont think im up to tackling that yet
14:50ChouserMec: there has been a subtle change to the sematics when you have both on the same loop-part
14:50marklartriddell: it definitely helped, thanks
14:51ChouserMec: so make sure you know if you're using a pre-1320 version or not
14:52Mechmm is there a function that returns the version
14:52hiredmannope
14:52hiredman:(
14:52danlarkinMec: frequently requested, but no
14:52Meclet me see if i can find it
14:52keithbhiredman: What is the connection between proxy and lazy? I read the page (skimmed really, a lot was over my head for now), but didn't understand how it applies to my problem.
14:52triddellpjstadig: saw that once... have to look a bit more... since the process isn't to bad I think a developer using something like clojure in emacs can benefit from how the pieces work together... I would like to reference a script which would keep this particular setup updated... and maybe I could reference M-x clojure install in the future
14:53keithbpjstadig: Paul, is that you? :)
14:53hiredmankeithb: oh, uh, I meant kefka
14:53hiredmansorry
14:53keithbOh, ok.
14:53Mecdoes it say anywhere in the source code what the version is?
14:53ChouserMec: depends on how you got clojure. downloaded a .jar? git? svn?
14:53hiredmanclojurebot: appologize for me!
14:53clojurebotfor is not used often enough
14:53Mecclojurebox
14:53bitbcktlol
14:54hiredmanclojurebot: apologize for me!
14:54clojurebotmea culpa!
14:54pjstadigtriddell: it seems like an easy way to get things going, plus M-x clojure-update can help keep you up to date, but you're probably right. it's good to get to know how the tools work together.
14:54pjstadigkeithb: yeah :)
14:56triddellpjstadig: I will look into that... is that available on a fork of clojure-mode?
14:56triddellpjstadig: or swank-clojure
14:56Meclookjs like i have 1235
14:58hiredmanr1230
14:58ChouserMec: ok. you can still use :when and :while on the same loop part, but the order in which you give them won't matter
14:58Chouserr1320
14:59hiredmanwhoops
14:59Chouser:-)
14:59Mecok
14:59ChouserI'm trying to remember ... I thnk the :while is checked first. If that's true, then it checks the :when
14:59Mecthat's how i'd expect
15:00Chouserif the :when and :while are on different loop parts, then they're checked in the order you give them.
15:00Mecwhile is for the whole loop, when is for individual values
15:00Chouserin r1320 and on, they're always checked in the order you give them.
15:01gnuvinceHoly schmoly, -Xrunhprof has been running for nearly 2 hours now
15:01Mecfrom looking at the code it seemed they where in a cond and only one would work
15:02ChouserMec: oh!
15:02ChouserMec: no, you're right. :-(
15:02Mecwell poo
15:02Chousersorry, I'm forgetting. I think they both worked on doseq
15:03Mechmm, best way to filter out nil then?
15:04Chouserhm
15:04Mec(filter (compliment nil?) list) i guess
15:04hiredman(filter identity ...) or (remove nil ...)
15:04Chouser,(for [i [1 3 5 7 8 9 10] :while (odd? i) :when (> i 3)] i)
15:04clojurebot(5 7)
15:04Chouserdoes that not work for you?
15:05Mecremove says it returns when pred is false, does that mean it will drop it will drop all but nil?
15:05Mecoh nvm
15:05Mecdidnt parse that correctly
15:06hiredmanuh, that remove call maybe wrong
15:06hiredmanI use (filter identity ...)
15:06ChouserMec: did you try the (for ...) example I just posted?
15:06hiredmanso I dunno how remove works
15:06pjstadigtriddell: its in clojure-mode
15:06gnuvince-Xrunhprof has been running for 2 hours now; is there a problem?
15:06pjstadigand i think it's in the master branch
15:06Mecit gives me the same result as clojurebot
15:07ChouserMec: great -- looks like you can combine them then.
15:07Mecweird but yay
15:08Chouserbut as I said, they'll always go in that order.
15:08Chouser,(for [i [1 nil 3 5 nil 7 8 9 10] :when i :while (odd? i)] i)
15:08clojurebot(1 3 5 7)
15:08Chouserin your version, that probably throws a NPE
15:09Mecshouldnt it stop on 8?
15:09Mecya nill pointer
15:09Mecerr it does
15:09Mecwow im just out of it right now
15:11kefka,(doc clojure/contrib/fcase)
15:11clojurebotjava.lang.Exception: Unable to resolve var: clojure/contrib/fcase in this context
15:11kefka,(doc clojure.contrib/fcase)
15:11clojurebotjava.lang.Exception: Unable to resolve var: clojure.contrib/fcase in this context
15:11kefka,(doc clojure.contrib.fcase)
15:11clojurebotjava.lang.Exception: Unable to resolve var: clojure.contrib.fcase in this context
15:12danlarkinkefka: you know, you can call doc from your local command line too :)
15:12Meclol
15:12hiredmanclojurebot also responds to privmsgs
15:12pjstadigclojurebot can also be PM'ed
15:13kefkadanlarkin: I know, but I wanted to know if I had clojure-contrib properly installed.
15:13kefkaIt wasn't working at my local command line. I wanted to see if it works here.
15:13hiredmanyou need to (require 'clojure.contrib.fcase) first
15:14eevar_best way to read all contents from a java.io.Reader into a string?
15:14kefkahiredman: Ah. Cool. I assume the same's true of clojure.parallel?
15:15hiredmanand most namespaces don't have docstrings
15:15hiredmanand clojurebot's doc lookup may not work with namespaces that do
15:17hiredmanhttps://twitter.com/clojurebot/status/1337623633
15:17hiredmanI love how the eyes kind of look up towards the tweet
15:19kefkaWhen I require 'clojure.parallel, I get a weird error message
15:19kefkajava.lang.ClassNotFoundException: jsr166y.forkjoin.ParallelArray (parallel.clj:0)
15:19hiredmancorrect
15:20hiredmanthe location of some classes has changed in jsr166y have changed
15:20kefkaDo I need to require something else before clojure.parallel?
15:20hiredmanand clojure.parallel has not been updated
15:20kefkaWhat is jsr166y?
15:20hiredmanhttp://paste.lisp.org/display/77047
15:20hiredmanoh
15:21hiredmanWell
15:21hiredmanyou need the jsr166y.jar
15:21pjstadigrhickey: i figured out the random NPEs i was getting from PersistentHashMap$BitmapIndexedNode
15:21pjstadignot a bug in PHM, but TC had a problem with calling clone() on an array
15:22pjstadigthat's done several places in the persistent structures
15:22hiredmankefka: see http://clojure.org/other_libraries
15:22pjstadigi changed them to new Object[_]; System.arraycopy()
15:23pjstadigis there an advantage to using clone() instead of creating and copying?
15:26Chouseranyone here using cl-format?
15:27Lau_of_DKNot since I left cl...
15:27Chouserno, I mean cl-format for Clojure.
15:27Lau_of_DKoh :) no
15:27Chouserhttp://github.com/tomfaulhaber/cl-format/tree/master
15:27pjstadigwise guy
15:28Lau_of_DKIs that based on the pprint you did Chris ?
15:28Chouserno
15:28gnuvince~seen blbrown_lt
15:28clojurebotblbrown_lt was last seen in #clojure, 58 minutes ago saying: danlarkin, do you use any third party library. For example, in my approach, I want to use a couple of common existing frameworks
15:28ChouserI'm trying to use it, but so far it's too smart for me.
15:28blbrown_ltgnuvince, yea
15:29Lau_of_DKHmm, that sounds alarming :)
15:29gnuvinceblbrown_lt: is the output of -Xrunhprof:cpu=times reliable?
15:29Chouserthe compiled .jar fails, the git clone requires that it be compiled, and I can't figure out how to compile the git clone.
15:30gnuvinceCause the numbers are... weird
15:30blbrown_ltgnuvince, I would hope so, but I normally haven't used that statistic. Are you running on a decent machine
15:31gnuvinceblbrown_lt: yeah
15:31lisppaste8gnuvince pasted "Profile output (top 20 only)" at http://paste.lisp.org/display/77121
15:32kefkahiredman: so the change I need to make to use clojure.parallel is in the paste you sent me, and that's a change to parallel.clj?
15:32pjstadigstarcraft.replay.parse/parse-buffer and starcraft.replay.parse/read-field-aux look like the winners
15:33gnuvinceYeah
15:33gnuvinceI'm a bit confused
15:33gnuvincewhy are the first two methods taking so long?
15:33gnuvinceEspecially when they're called only 9 times
15:34blbrown_ltgnuvince, http://stackoverflow.com/questions/375439/java-hprof-question I havent used that aspect of the profiling so I would be pretending if I knew. But, I would think it makes sense
15:34blbrown_ltask rhickey maybe he could run hprof also
15:34hiredmankefka: I believe so, I have not used it
15:35kefkaNow I get "java.lang.ClassNotFoundException: extra166y.ParallelArray (parallel.clj:0)"
15:36kefkaNever mind. Embarrassing classpath mistake.
15:36pjstadiggnuvince: well i don't know, but maybe it was a fluke
15:37pjstadigmaybe that's why it took so long, something went screwy?
15:39blbrown_ltgnuvince, this may help also. http://java.sun.com/developer/technicalArticles/Programming/HPROF.html
15:39gnuvincepjstadig: I don't think it was a fluke, the performance of the site has been pretty much the same for a while now.
15:39Lau_of_DKCompojure guys! If I want to attach an onchange event to a drop-down, how do I do that ?
15:39gnuvince(I just happened to test a Java version this morning, and it ran about 8x faster)
15:40kefkaOk. Still I'm getting the same error.
15:43kefkaThe error being "java.lang.ClassNotFoundException: extra166y.ParallelArray (parallel.clj:0)
15:43kefkawhen I try to require clojure.parallel
15:44hiredmando you have all the right jars?
15:45hiredmanhttp://gee.cs.oswego.edu/dl/concurrency-interest/
15:45kefkaI have jsr166y.jar, clojure.jar, and clojure-contrib.jar in my classpath
15:46hiredmanthere is also a extra166y.jar
15:46kefkaOk. It looks like I need extra166y.jar and possibly others. Thanks.
15:48kefkahiredman: it's working now. Thanks.
15:51hoeckChouser: just got cl-format working here, it's nice
15:52Chouserhoeck: you're using this jar, or something else? http://github.com/tomfaulhaber/cl-format/raw/master/release/cl-format.jar
15:52hoeckChouser: I had to set the clojure-jar property in the build.xml manually and then just used ant to build the jar
15:53hoeckChouser: I cloned the repository and built my own jar
15:54Chouserok, that's what I've done too.
15:54ChouserI had a typo in my clojure-jar property that stumped me for a while.
15:54Chouserbut now it builds, and I get a cl-format.jar
15:55Chouserbut when I put that in my classpath, I get:
15:55Chouseruser=> (use 'com.infolace.format)
15:55Chouserjava.lang.NoClassDefFoundError: clojure/lang/RT (format.clj:0)
15:57Chouserok, I just got it to work, by putting cl-format.jar directly in my -cp option, instead of copying it to one of my java.ext.dirs
15:57Chouserthis I do not like.
15:58slashus2Why does pvalues use a syntax quote on fn instead of ' ?
15:58hoeckwhat is a java.ext.dir?
15:59hiredmanif you figure out why some things don't work well with java.ext.dir it would be interesting to know
15:59hiredmanhoeck: don't
15:59hiredman~add-classpath
15:59clojurebotadd-classpath is bad, avoid it. I mean it!
15:59hiredman~jar directory
15:59clojurebotwith java6(jdk1.6) CLASSPATH can contain a "*" so /jar/dir/* will suck in all the jars in the /jar/dir directory, this also works with swank-clojure-extra-classpaths in emacs, alternatively you can use this shell snippet: find .jars/ -type f -name \*.jar -print0|xargs -0|sed "s/ /:/g"
16:00hiredmanof course that will all confuse people
16:00hiredmanwho will try and use * like shell expansion
16:00hoeckbut adding a jar after starting the jvm to a * classpath doesn't seem to work
16:00hiredman*sigh*
16:00hiredmanhoeck: the solution is "do not use add-classpath"
16:01Chouserok, pprint working. I'll have to look at java.ext.dirs later. Thanks all.
16:01hoeckI know
16:01hiredmanadd-classpath is unreliable
16:01cemerickrhickey: I'm sure you get notifications and such, but I wanted to raise this regression directly: http://code.google.com/p/clojure/issues/detail?id=98
16:01hiredmanso don't rely on it
16:02cemerickI would go spelunking in the gen-class stuff, but I'm completely tied up.
16:02kotarakisn't java.ext.dirs also the voodoo thing, one shouldn't use?
16:02hiredmankotarak: that has been my experience
16:02hiredmansometimes it doesn't work
16:03pjstadighow can you patch a long running JVM with code changes that may necessitate classpath changes?
16:04walterspjstadig: one thing you need to understand is the Permgen
16:04Chouserwhat code changes necessitate classpath changes?
16:04pjstadigtakes away from the dynamic nature of Clojure, me thinks, if you can't dynamically change the classpath
16:04kotarakI don't get, what problems people have with their classpath. I have I directory, where I put all jars I want in there. Together with symlinks to local stuff. A starter script adds all that to the CLASSPATH env var and fires up clojure. I never ever had a single problem with this setup.....
16:04pjstadigkotarak: we're talking about changing the classpath after the JVM has booted
16:05Chouserkotarak: I'm trying to remember why i moved off of that.
16:05cemerickpjstadig: as long as you bootstrap your app with a classloader you control (i.e. *not* the bootclassloader), then you can do just about anything with the effective classpath.
16:05kotarakpjstadig: maybe this is a thing, the jvm doesn't want?
16:05pjstadigChouser: hypothetical, adding a feature to an application that requires a new external jar
16:05Chouserpjstadig: unpack the jar into an existing classpath root. It may not be pretty, but it would work
16:06p_lwasn't it possible to modify the classpath at runtime?
16:06cemerickapp servers have been doing stuff like this for years and years
16:12pjstadigis that what *use-context-classloader* is about?
16:15rhickeycemerick: try 1330
16:16Lau_of_DKCompojure guys! If I want to attach an onchange event to a drop-down, how do I do that ?
16:20slashus2Why does pvalues in core.clj use a syntax quote on fn instead of ' ?
16:21dnolenLau_of_DK: not sure how good JS integration is in Compojure, but all you need to do is add an onchange attribute to the element, the string will be a JS fn call.
16:21pjstadig~def pvalues
16:22Lau_of_DKdnolen, yea I get that - its the compojure syntax/approach for doing so Im missing
16:22pjstadig`fn will explicitly resolve to clojure.core/fn unless i'm mistaken
16:23dnolenLua_of_DK: from compojure wiki, [:a {:href "/"} "Home"]]]
16:23pjstadigi think it's just to prevent picking up an fn frome somewhere else
16:23dnolenso it looks like attributes are just maps.
16:23slashus2pjstadig: I understand.
16:23dnolen[:select {:onchange "myJSFn()"}]
16:23pjstadig,`fn
16:23clojurebotclojure.core/fn
16:24dnolenuntested guess.
16:24pjstadig,'fn
16:24clojurebotfn
16:24slashus2pjstadig: Using macro expand I see it now.
16:26Lau_of_DKdnolen, I get attributes - Im asking specifically about drop-down
16:26dnolenLau_of_DK: that's how you add an onchange event on a drop-down, am I missing something?
16:27Lau_of_DKYea, you are :)
16:27Lau_of_DKIf you work it out specifically for drop-down let me know, otherwise I'm going forward with my filthy JS solution
16:28dnolenLau_of_DK: haha, I'm assuming you're looking for tighter JS integration?
16:42cemerickhrm, can we leave messages with clojurebot?
16:45hiredmanno
16:46hiredmanit's in the TODO, if you want to do it
16:46hiredman:P
16:46cemerickhiredman: :-P ;-)
16:46danlarkinnext thing you know rich'll sign on and get 200 messages from random dudes
16:46cemerickdanlarkin: really? I've really enjoyed it in the past.
16:46hiredmanit would, of course, only give you your messages if you ask for them
16:46cemerickAh, I suppose. Maybe only sane people could be added to the messaging perm list or something. *shrug*
16:47pjstadigthere's always e-mail :-p
16:47danlarkinyeah who knows, I'm frequently wrong about this type of thing, so..
16:47cemerickemail is SO last century, man!
16:48pjstadigmaybe someone should write a spam filter for the clojurebot message queue
16:48pjstadigusing a naive bayes filter
16:48Chouserbut and a tagging system
16:48Chouserand a folders
16:48Chouserauto-filters
16:48pjstadigand an RSS feed
16:48Chouserweb-based reader
16:49Chouserprotocol for fetching and sending messages
16:49pjstadigand automatic twittering when someone reads a message that you left for them
16:49pjstadigcharacter sets
16:49pjstadigmime types
16:49pjstadigattachments!
16:49Chouseroh, yes, attachments
16:50pjstadigmaybe you could even leave a clojure message
16:50hiredmanright now I am writing a data persister using an agent and a watcher, instead of having to write a new method for writing stuff to disk for every module/extension/behavior
16:50pjstadigsome code that gets executed when someone joins channel
16:50hiredmanclojurebot does tweet
16:51pjstadighiredman: you writing these down?
16:51hiredmanpjstadig: I log everything
16:51pjstadigthis is good stuff :)
16:51hiredmanafter the machine crash and clojurebot lost some memory, I fed a month or so of irclogs through it
16:51pjstadigclojurebot: prepare for dictation
16:51clojurebotfor is not a loop
16:53pjstadigclojurebot: for is a loop...in Java
16:53clojurebotc'est bon!
16:58danlarkinI fear the day that clojurebot becomes sentient
17:00pjstadigi, for one, welcome our new IRCbot overlords
17:01hiredmanpjstadig: you just overwrite two factoids
17:01hiredmanoverwrote
17:05kotarakclojurebot: for
17:05clojurebotfor is a loop...in Java
17:05kotarakclojurebot: for is also not a loop
17:05clojurebotRoger.
17:06kotarakclojurebot: for is also not used often enough.
17:06clojurebotRoger.
17:08Chouser~clojurebot
17:08clojurebotclojurebot is like life: you make trade-offs
17:11hiredman^- failed tab completion
17:17hiredmanhmmm
17:23hiredmanadding this feature (the agent & watcher based persistence store) will also move clojurebot's dictionary out of the global space
17:23hiredmanwhich means it will be possible to run multiple clojurebot's at once with different dictionaries
17:29Mecdoes the api somewhere describe how to handle exceptions?
17:29hiredmantry/catch/finally
17:30Mecah hah, it was hiding on the special forms page
17:33Mecany chance of an example? i dont understand the doc
17:34danlarkinuse it like try/catch in java
17:36Mecit looks like it would work just like if/then/else but it takes 2 variable number of args back to back... which doesnt seem right
17:37Chouser(try foo bar baz (catch Exception e qux))
17:38slashus2,(try (/ 9 0) (catch ArithmeticException e e))
17:38clojurebotslashus2: Excuse me?
17:39slashus2:-(
17:39Mecah ok
17:43Meci keep getting a clojure.lang.PersistentVector cannot be cast to java.lang.Number but i sware im not :*(
17:46hiredman(try do some stuff (catch Exception e (println e)))
17:47Meci think i found the problem
17:47Mectho once you catch an exception how do you gtfo
17:53stuhoodgtfo? like get the funk out?
17:53Mecyou betcha
17:53stuhoodif you catch the function, the return of the (catch) statement is the result of the whole (try)
17:53stuhooder, catch the exception
17:54Mec(defn gtfo [] (System/exit 0))
17:54stuhoodheh.
17:55hiredman(it isn't a statement, it is an expression)
17:55blackdog_what's the latest word on 1.0 ?
17:56hiredman~seen rhickey
17:56clojurebotrhickey was last seen joining #clojure, 11 minutes ago
17:56hiredmanI've started ignoring joins and parts in this channel
17:57tashafaim lazy... is there a contrib that turn a clojure structer to json?
17:57tashafathat turns*
17:57tashafa?
17:58danlarkintashafa: that really is _quite_ lazy
17:59tashafahey, its clojure's fault :)
18:00spacema__maybe we can get clojurebot integrated with letmegooglethatforyou.com
18:00tashafafine i'll C-x C-f into clojure-contrib
18:01hiredmanthere is a json deal in contrib
18:01hiredmanand there is another one that is not in contrib
18:01stuhoodhiredman: re statement/expression: indeed... thanks
18:01danlarkin+1 for the latter!
18:02tashafaah json write
18:02tashafajust lie json read
18:02tashafalike*
18:03tashafahmmm.. .i see what they did there
18:04tashafahiredman: whats up with the other one thats not in contrib?
18:11hiredmanuh, it's there? it's not in contrib
18:11hiredmanclojurebot: clojure-json?
18:11clojurebotclojure > scheme
18:11hiredmanhmmm
18:12hiredman~google clojure-json
18:12clojurebotFirst, out of 9460 results is:
18:12clojurebotdanlarkin's clojure-json at master - GitHub
18:12clojurebothttp://github.com/danlarkin/clojure-json/tree/master
18:12hiredman^-
18:12hiredmanstuhood: wait, didn't you write the one in contrib?
18:15stuhoodhiredman: no... there are a lot of stuarts in the community, heh
18:16tashafa:(
18:16hiredmanmy mistake then
18:16tashafajson write doesnt do timestamps correctly
18:16hiredmanyeah, a lot of stuarts
18:17hiredmantashafa: I am sure it just doesn't know how you want it done
18:17tashafa... "posted":#<Timestamp 2009-03-08 20:17:49.0>,"type":.....
18:18stuhoodtashafa: i don't think there is a standard way to do timestamps, so you'll probably have to explicitly convert it to a Long if that is what you wanted
18:18tashafahmmm
18:18tashafathanks
18:19tashafagood thing im using clj record i could implement a call back
18:22hiredmanI seem to recall that one of the json libs used multimethods, so you might be able to hook up your own method for turning a Timestamp object into json
18:24fandahello!
18:25fandafunction 'empty' is missing on the page http://clojure.org/sequences
18:25stuhoodehlo!
18:25stuhoodfanda: i see empty?
18:25stuhood,(empty? '(1 2 3))
18:25fandayes, but there is also 'empty'
18:25clojurebotfalse
18:25tashafathanks hiredman
18:25fanda(doc empty)
18:25clojurebotReturns an empty collection of the same category as coll, or nil; arglists ([coll])
18:26fandathere is 'not-empty' correctly mentioned
18:27stuhoodbut not-empty is the opposite of empty? so that makes sense, right?
18:27tashafahow would you pass a java method as a function argument?
18:28Chousuketashafa: wrap it in an anonymous function
18:29stuhoodtashafa: you can use a lambda: #(.toString "blah")
18:29Chousukeor use (memfn javaMethod)
18:29tashafa,(map #(.getTime %) [java.util.Date. java.util.Date.])
18:29clojurebotjava.lang.ClassNotFoundException: java.util.Date.
18:29tashafa,(map #(.getTime %) [java.utils.Date. java.utils.Date.])
18:29clojurebotjava.lang.ClassNotFoundException: java.utils.Date.
18:30Chousuke,(map #(.getTime %) [(Date.) (Date.)]
18:30clojurebotEOF while reading
18:30Chousuke,(map #(.getTime %) [(Date.) (Date.)])
18:30clojurebot(1237242527447 1237242527447)
18:30tashafathanks
18:30tashafabrain fart
18:31fandastuhood: I just couldn't find function 'empty' mentioned on the clojure.org... It should be somewhere
18:31tashafacool thanks...
18:32fandastuhood: either sequences or data_structures - then these functions link to API page
18:32stuhoodfanda: yea... it's on the API page, but the Sequences page only claims "This is a sampling of the primary sequence functions, grouped broadly by their capabilities."
18:32tashafaone of my records happend on 1234567890... day, i thought it was some kind of mistake
18:33fandastuhood: my bad then, I always assumed that there should be all of them :-)
18:35fandaanother thing: what do think about (empty nil) throwing NullPointerException?
18:35fandais this desired behavior?
18:36stuhoodthat makes sense... how can you create a new collection of the same type as nil?
18:36fandadoc says that it accepts collection
18:36fanda(doc empty)
18:36clojurebotReturns an empty collection of the same category as coll, or nil; arglists ([coll])
18:37danlarkintashafa: clojure-json uses multimethods, you can write your own java.util.Date handler
18:37fandathat clause "or nil" is questionable :-)
18:37fandai wonder if (empty nil) => nil would be a better alternative
18:38stuhoodmm, yea... you're right
18:38fanda,(empty [1 2])
18:38clojurebot[]
18:38fanda,(empty (seq [1 2])
18:38clojurebotEOF while reading
18:38fanda,(empty (seq [1 2]))
18:38clojurebotnil
18:38stuhoodahh
18:39Chousuke,(empty (map inc [1 2]))
18:39clojurebotnil
18:39fandayes, there are some nils, but I am not satisfied :-)
18:42stuhoodi agree that it probably shouldn't throw an exception, and should return nil instead
18:43fandai will post it to the group
18:43fandanot sure if rhickey is listening :-)
18:44Chousukehmm
18:44Chousuke,(into nil [1 2])
18:44clojurebot(2 1)
18:45hiredmanuh
18:45Chousukefunky :)
18:45hiredmanhwa?
18:45slashus2hmm
18:45Chousuke,(conj (conj nil 1) 2)
18:45clojurebot(2 1)
18:45Chousukethat's what into does :)
18:47fandathanks all for the help!!!
18:48slashus2Maybe if "to" is nil it should throw an illegal argument exception?
18:49hiredman,(doc conj)
18:49clojurebot"([coll x] [coll x & xs]); conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type."
18:49slashus2For into that is.
18:50ChousukeI think into is just a (reduce conj to coll)
18:51hiredmanif only there was some quick and easy way to read the source for into
18:51Chousukeand I guess there will be situations in which you wish into did not throw an exception, if it did :)
18:51Chousukeheh
18:51Chousukeright.
18:51Chousuke~source into
18:52slashus2,(into '(1 2) [1 2 3 4 5])
18:52clojurebot(5 4 3 2 1 1 2)
18:53Chousuke(reduce conj '(1 2) [1 2 3 4 5])
18:53Chousukegah
18:53Chousuke,(reduce conj '(1 2) [1 2 3 4 5])
18:53clojurebot(5 4 3 2 1 1 2)
18:54slashus2Kind of wonder why it isn't implemented with reduce.
18:54Chousukemaybe it predates reduce.
18:54slashus2reduce is 539
18:54slashus21889 is into
18:54hiredmanI think the taking nil as () (which is what the into behavior is) is a remnent of when nil == ()
18:54slashus2so it doesn't predate it.
18:54Chousukewas nil ever equal to ()? :/
18:55ChouserI don't think nil was ever () in Clojure.
18:55slashus2,(reduce conj nil [1 2 3])
18:55Chousukeslashus2: then whoever implemented it just didn't think of using reduce I guess :)
18:55clojurebot(3 2 1)
18:55hiredmanpre-lazy, seqs could not be lazy
18:55hiredmaner
18:55hiredmanpre-lazy, seqs could not be empty
18:55hiredmaninstead of getting () you would get nil
18:56hiredmanso in that sense
18:56Chousukeyou still can't get a () from a seq I think
18:56Chouserbut () was never a seq
18:56Chouserhm
18:56Chouser,(seq? ())
18:56clojurebottrue
18:56hiredmanhah!
18:56hiredman,(drop 3 '(1 2 3))
18:56clojurebot()
18:57Chousuke(seq ())
18:57hiredman,(class (drop 3 '(1 2 3)))
18:57Chousuke,(seq ())
18:57clojurebotnil
18:57clojurebotclojure.lang.LazySeq
18:57Chousukehmm
18:57Chousukeso what does seq return now? :/
18:57hiredman,(doc seq)
18:57clojurebot"([coll]); Returns a seq on the collection. If the collection is empty, returns nil. (seq nil) returns nil. seq also works on Strings, native Java arrays (of reference types) and any objects that implement Iterable."
18:58Chousukeall this laziness has managed to confuse my idea of the terminology
18:59hiredmanyeah
18:59slashus2surprisingly using reduce to implement into is more efficient
19:00kotarak_Hmm... I think, the only thing changed, is that rest now returns a collection instead of a seq, no?
19:00slashus2than its current implementation.
19:00hiredmanwell
19:00hiredmanSequences can now be empty
19:00hiredmanpreviously they could not
19:01slashus2Do you all get the same performance results?
19:01kotarak_Maybe a Sequence is not a seq?
19:02hiredmanthere is no Sequence type
19:02hiredmanI am just trying to distringuish between nouns and verbs using capital letters
19:02kotarak_Maybe a Sequence is the collection of items in a seq.
19:03hiredman...
19:03kotarak_rest returns a Sequence not a seq.
19:03hiredmanno
19:03kotarak_Maybe Sequence is non-existent.
19:03kotarak_and I should go to bed.
19:03hiredmanclojurebot: rest?
19:03clojurebotrest never returns a unicorn
19:03stuhoodhaha
19:03hiredmanI think that was an rhickey quote
19:04hiredmanprevious to lazy, rest could never return an empty sequence, because empty sequences did not exist
19:05hiredmanso a lot of functions still treat an empty seq and nil as the same thing
19:05hiredman,(into '() [1 2 3])
19:05clojurebot(3 2 1)
19:05hiredman,(into nil [1 2 3])
19:05clojurebot(3 2 1)
19:06slashus2,(time (reduce nil (range 10)))
19:06clojurebotjava.lang.NullPointerException
19:06slashus2,(time (reduce conj nil (range 10)))
19:06clojurebot(9 8 7 6 5 4 3 2 1 0)
19:06clojurebot"Elapsed time: 0.127 msecs"
19:06slashus2,(time (into nil (range 10)))
19:06clojurebot(9 8 7 6 5 4 3 2 1 0)
19:06clojurebot"Elapsed time: 0.125 msecs"
19:08slashus2About the same
19:09fanda,(time (reduce + (reduce conj nil (range 1000000))))
19:09clojurebot499999500000
19:09clojurebot"Elapsed time: 2121.037 msecs"
19:09Hunthat is /not/ a valid benchmark. not to the slightest
19:09fanda,(time (reduce + (into nil (range 1000000))))
19:09clojurebot499999500000
19:09clojurebot"Elapsed time: 1083.92 msecs"
19:10fandavery funny - I get different results on clojurebot and on my computer :-)
19:10slashus2probably need to run it a few times each.
19:12slashus2For reduce I get "Elapsed time: 703.340936 msecs" "Elapsed time: 640.98617 msecs" "Elapsed time: 640.678316 msecs" "Elapsed time: 687.656826 msecs" "Elapsed time: 644.186306 msecs"
19:12slashus2For into I get "Elapsed time: 843.761718 msecs" "Elapsed time: 754.135803 msecs" "Elapsed time: 762.740057 msecs" "Elapsed time: 769.567923 msecs" "Elapsed time: 711.6967 msecs"
19:14fandaafter few runs - reduce conj is faster than into
19:14fandapercentage looks similar to yours
19:15slashus2I don't see any reason why reduce shouldn't be reused in into.
19:17fandaslashus2: post it to the group if you want
19:17fandaRich usually welcomes speed improvements
19:18Hunsbcl still beats it by factor 3 on my machine :) (time (reduce #'+ (loop for i below 1000000 collect i)))
19:22fandaHun: I am not sure if that version is equivalent
19:22fandaClojure's version creates list of 0 to 1000000-1 numbers, then uses this list to create a list with the same numbers (only in the opposite order)
19:22fandareduce + is just for printing
19:23fandaour test was actually to time list creation
19:23fandareduce conj vs. into
19:24fanda,(time (reduce + (range 1000000)))
19:24clojurebot499999500000
19:24clojurebot"Elapsed time: 180.617 msecs"
19:26Hun(time (reduce #'+ (reduce #'cons (loop for i below 1000000 collect i) :from-end t :initial-value nil)))
19:26Hunfanda: better by factor 2
19:27Hunhmm
19:27Hunon my machine, reduce #'cons is actually faster than using reverse. something's fishy
19:33fandaHun: ... and we have a winner: it is sbcl :-)
19:34lpetitHello
19:34Hunfanda: hmm. the flames in the olden days were more fun :)
19:35fandaHun: flames are boring these days... cooperation is more fun... since when is LISP using Java? since Clojure :-)
19:35Hunfanda: very weird. on abcl, both lines (with and without reverse) take the exact same time (about factor 5 worse than clojure)
19:35Hunand abcl is also java :)
19:36fanda:-)
19:37fandagotta go to bed, take care all!
19:37Hungotta sleep. it's getting late here
19:37blbrownabcl is still kind of slow, maybe mostly uses reflection?
19:38Hunblbrown: don't know. i can't test it on my production app, because it breaks on one of the libs i use. gotta fix that some time in the future
19:38Hunshouldn't need too much reflection there. lots of type hints
19:58gnuvince_Hmmm :(
19:58gnuvince_Seems I can't get an answer to that profiling question
20:00slashus2gnuvince_ I would like to know the answer too.
20:04gnuvince_I sure wouldn't mind if I was about 50% slower than the Java version
20:04slashus28 times slower is a little much.
20:05gnuvince_Yeah
20:05slashus2What is java.lang.Object.wait and java.lang.ref.ReferenceQueue.remove ?
20:05gnuvince_That's what I'd love to know
20:06slashus2I looked at java.lang.ref in the java api.
20:06gnuvince_Especially how a total of 9 calls can take 66% of runtime, but 4 million calls to the AtomicInteger.get takes 1%
20:06slashus2a lot of waiting going on?
20:06Chouserwait is for waiting on a lock, isn't it?
20:09gnuvince_ void wait()
20:09gnuvince_ Causes current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object.
20:12ChouserHow much time for how many calls to wait?
20:13Chouser302283 is in milliseconds I suppose.
20:16ChouserI see one direct call to .wait() in the clojure code base
20:16Chouserhttp://code.google.com/p/clojure/source/browse/trunk/src/jvm/clojure/lang/LockingTransaction.java?r=1308#133
20:16Chouserbut that looks like 100 msecs per wait, so I don't think that adds up to 302283
20:17gnuvince_I wonder if it could be a packaging bug
20:18gnuvince_I ran the same code, with the same clojure version with the same replay file here and Object.wait() and ReferenceQueue.remove() don't even appear in the output
20:18Chouserhuh
20:19rhickeygnuvince: what's the problem code?
20:19gnuvince_rhickey: http://groups.google.com/group/clojure/browse_frm/thread/c416294e5cca477b#
20:20gnuvince_I ran a -Xrunhprof profile run at work with Sun's VM as shipped with Ubuntu Hardy Heron and it gave me those numbers.
20:20gnuvince_Here at home, with Ibex and a different version of Sun's VM, Object.wait and ReferenceQueue.remove don't even appear in the output.
20:28slashus2gnuvince_ Is the performance the same with Ibex?
20:28slashus2Ibex's version rather?
20:29gnuvince_I'm going to try that now
20:29gnuvince_I just finished checking out the other project.
20:34gnuvince_Both programs are faster on my home machine
20:34gnuvince_However, there's still a speed difference: Java takes 12.68s, Clojure takes ~160s
20:35slashus2even worse
20:36gnuvince_yah
20:36slashus2tried openjdk?
20:36slashus2I am sure that will be the same... never mind.
20:37gnuvince_I'd rather look at my code and figure out where I went wrong
20:44danlarkingnuvince: if you're really stumped then it's time to start picking apart your code and find the bottleneck
20:45danlarkinor refactor your algorithm to be more (or less!) idiomatic
20:46gnuvince_danlarkin: well with these new numbers, I see that AtomicInteger.get is called a lot of times for a single file (2M+ times)
20:46danlarkinso is that a boxing/unboxing thing?
20:47gnuvince_Could be, I've never seen this before, I'll need to play around with the code.
20:47RaynesIs there a function or method to parse an int to a double.
20:48hiredman(double 1)
20:48gnuvince_I could also look into whether using vectors is a wise idea to describe byte fields
20:48hiredman,(double 1)
20:48clojurebot1.0
20:48danlarkinints are a subset of doubles
20:48danlarkinthere is no parsing necessary
20:48Raynes,(/ 3 5)
20:48clojurebot3/5
20:48RaynesI need a double. :\
20:48danlarkinthat's not an int
20:48hiredman,(double (/ 3 5))
20:48clojurebot0.6
20:49hiredman,(class (/ 3 5))
20:49clojurebotclojure.lang.Ratio
20:49RaynesEr, did I say parse?
20:49hiredmanYes
20:49hiredmanand you said int
20:49RaynesI got 10 minutes to finish what I'm doing, I'm just typing random shit.
20:49danlarkinAND you said "there"!
20:50danlarkinRaynes: please no fowl (ha!) language :(
20:50Raynesdanlarkin: What is it with you and foul language?
20:51danlarkinit's channel semi-policy
20:51RaynesPut it in the topic then.
20:51RaynesWe need a list of rules.
20:52RaynesNo talking, no fowl language, no using clojurebot ect.
20:52Raynes:S
20:52Raynes:D*
21:32durka42Raynes: you seem to have single-handledly enacted that first rule :p
21:49Raynesdurka42: Oh shi-
21:58gnuvince_hmm?
23:06Mecwhats the proper format for (System getProperties line.separator)
23:06Chouser,(System/getProperty "line.separator")
23:06clojurebotjava.security.AccessControlException: access denied (java.util.PropertyPermission line.separator read)
23:07MecChouser: thanks
23:33arohnerdoes dosync have a defined return value?
23:35Chouserit returns the value of the final form
23:36ChouserI'm not sure if that's promised, but I suspect it is. Like 'do'
23:44gavin___has anyone had success using repl-utils/add-break-thread! with slime?
23:49Chousergavin___: http://groups.google.com/group/clojure/browse_thread/thread/e05cc5a9c1dc8b1
23:50Chouserlooks a bit mixed
23:51gavin___Chouser: I read that and got it sort of going after several mis-starts, but in the end my Swank REPL Thread dies with an InterruptedException
23:52Chouserhm.
23:53gavin___in swank.core/eval-for-emacs the SIGINT exception thrown by add-break-thread! gets caught and displayed in an *sldb* buffer, but then the send-to-emacs call that comes a bit after that gets another InterruptedException for some reason
23:53Chouserinteresting -- I can get some perhaps similar unexplained behavior at a plain repl
23:54ChouserIf I type Ctrl-C when there's nothing running, the next expression I eval catches a SIGINT
23:54Chouserok, thanks
23:54Chouserbleh
23:54ChouserI mean, that's not all of it though
23:55gavin___hmm, I haven't seen that. Actually in a plain REPL I can't get Ctrl-C to do anything for some reason; I've been sending SIGINT from a separate process for testing
23:55arohneris there a java fn for xor, or just the operator?
23:56ChouserIf I Ctrl-C at a prompt, then eval "55", I get a SIGINT printed
23:56ChouserI can then eval several more expressions with no problem.
23:57ChouserBut the next time I do (Thread/sleep 10) it fails immediately with a java.lang.InterruptedException: sleep interrupted (NO_SOURCE_FILE:0)
23:57Chouserwhich sounds more like what you're seeing.
23:57gavin___I'll check that out. Maybe its just doomed due to all of the scary warnings in the Thread.stop docs