#clojure logs

2010-04-28

00:32MadWombatHello
00:33RaynesHello.
00:35MadWombatI have a number of functions generating data and a single function for storing this data. At this point I have something like (def fns ['f1 'f2 'f3]) (doseq [f fns] (store-data ((eval f))))
00:35MadWombatthis somehow seems ugly and non-idiomatic
00:35MadWombatespecially ((eval f)) part
00:36MadWombatis this "The Clojure Way" or am I not sufficiently enlightened?
00:37technomancyMadWombat: what about (def fns [f1 f2 f3]) (doseq [f fns] (store-data (f))) ?
00:38technomancyassuming the f1, f2, f3, etc have been def'd when the function calling store-data is compiled
00:46MadWombattechnomancy: interesting :) wonder why I started quoting them right away anyway
01:10vIkSiTmmarczyk, you mean "back" into a separate duck-streams ns?
01:10cemerickvIkSiT: right, (:require [clojure.contrib.io :as io]), and then use io/slurp* and io/spit, etc
01:10mmarczykyes
01:10mmarczykbut you can just use stuff from io, yes
01:10cemerickIt's been suggested that it be restored, but deprecated
01:10mmarczykbe wary of changes in behaviour though
01:10vIkSiTah I see
01:10vIkSiThmm.
01:11mmarczyksome of the functions act somewhat differently in addition to having been moved to a different ns
01:11vIkSiTi c
01:12vIkSiTwell, it looks like Clojure is to languages what Linux has been to OSs :) Its changing so fast!
01:12cemerickthe perils of following the bleeding edge :-)
01:12vIkSiT(Not to mention that half the books haven't been written yet :P)
01:12cemerickvIkSiT: you can see the current state of the API here: http://richhickey.github.com/clojure-contrib/index.html
01:13cemerickThat shows where the master branch is, and there's a link at the left to get to the 1.1.x release docs.
01:13vIkSiTcemerick, ah, I've been using 1.2.0 Master for a while.. don't think I could go back to 1.1.x
01:14mmarczykspoiled with the new toys :-)
01:16vIkSiThehe totally
01:18vIkSiTcemerick, wow, that list is comprehensive! How does one explore all that :)
01:19cemerickslowly, and only as needed :-)
01:25vIkSiTthe graph library looks interesting
01:43vIkSiThmm is line-seq recommended to open files?
01:44cemerickvIkSiT: it takes a reader, but sure
01:44vIkSiT(line-seq (reader "filepath")) for instance.
01:44vIkSiTah, I was just guessing that since line-seq is lazy - it probably doesn't put everything in memory..
01:44vIkSiTvs say, slurp
01:45cemerickvIkSiT: io/read-lines is probably better
01:45vIkSiTah
01:45cemericknote the docs though
01:46vIkSiTcemerick, anything specific there btw?
01:46mmarczykso if you might need to consume just a handful of lines, then close your reader, (with-open [r (reader path)] (let [ls (line-seq r)] ...)) might be better
01:46defnstu h's new screencast is awesome
01:46cemerickvIkSiT: regarding?
01:48vIkSiTcemerick, oh, nothing - I thought you were talking about soemething specific in the docs.
01:48mmarczyk(doc clojure.contrib.duck-streams/read-lines)
01:48clojurebot"([f]); Like clojure.core/line-seq but opens f with reader. Automatically closes the reader AFTER YOU CONSUME THE ENTIRE SEQUENCE."
01:48cemerickvIkSiT: only the fact that read-lines doesn't close the reader it opens until you consume the entire sequence, which is likely what mmarczyk was referring to
01:48mmarczyksee the bit in capital letters
01:48mmarczykyup
01:49mmarczykdefn: it is, isn't it? :-)
01:49vIkSiTaah, I get mmarczyk's statement now as well, thanks!
02:04vIkSiToh I always forget to ask - on an emacs slime REPL - whats the best way to break the currently executing program/statement?
02:06_atovIkSiT: C-c C-b
02:06vIkSiTah thanks _ato
02:07vIkSiTalso, is there a way to "log" a particular REPL session into a file somewhere?
02:07_atomaybe C-x C-w (write-file) and enter a filename
02:08_atothat's a one off saving though, dunno about logging continuously
02:08_atoyou can keep hitting save after you've named it I guess :p
02:08vIkSiThehe
02:09vIkSiTah that works just fine..
02:09vIkSiTI just need a log of some stuff
02:37vIkSiTis there a way to create an index for an in memory clojure data structure?
02:37vIkSiT(assuming you have a huge map for instance..)
03:54carkhvIkSiT: a map is already indexed by it's key isn't it ?
03:54carkhits*
04:07LauJensenMorning all
04:07esjand a good morning to you, sir.
04:07ordnungswidrigmoin
04:09sparievmorning
04:11mmarczykgood morning
04:12sparievisn't memfn deprecated ?
04:13Raynesmmarczyk: I was trying to modify a ref inside a macro inside a macro.
04:14sparievjust received a ClojureInAction MEAP update, and found example with memfn in chapter on Java interop
04:15Raynesspariev: memfn existed before #().
04:15RaynesI don't know why he would use it.
04:17mmarczykhi Raynes
04:17RaynesYo.
04:17mmarczykare you by any chance trying to write a pair of a wrapper macro establishing state + a macro to be used inside that to update that state?
04:18mmarczykjust occurred to me you might be
04:19RaynesI think that about nails it. It establishes some state and then does some stuff with it at the end. However, I just realized that isn't going to work like I want it to.
04:19RaynesMy macrofoo is quite weak.
04:19mmarczykincidentally, it took me until now to put the pieces together and realise that I know you from all of SO, clj101 and here :-)
04:19mmarczykmakes me feel a bit silly now
04:19Raynes~@body tries to evaluate everything in an argument list passed to a multimethod in the other macro, and I don't see a way around that. :\
04:19clojurebotmultimethods is what separates the boys from the men.
04:20RaynesIndeed.
04:20mmarczykoh, well, I was thinking of posting an answer to your Q with some thoughts re: this kind of scenario
04:21mmarczyk:-)
04:21Raynesmmarczyk: http://gist.github.com/381865 Is the actual example.
04:21mmarczykincidentally, I find this surprising:
04:22mmarczyk,(let [g (gensym)] (= g (symbol (name g))))
04:22clojurebottrue
04:22RaynesThat fails. Hard. Since you wanted a more realistic example. :>
04:22mmarczyknot in hindsight, that is
04:22mmarczykbut haven't expected it
04:22mmarczykRaynes: looking now
04:23RaynesAye, that (do in defplugin is unnecessary, by the way.
04:23RaynesJust haven't removed it.
04:24mmarczykyou might want to add a comment to your Q to point to that, it makes the idea come across
04:24mmarczykquite clearly
04:24RaynesI will once I get it less ugly and more of what I expected.
04:25RaynesI also forgot to remove the quote from ~@body in defplugin.
04:25RaynesThat was a typo.
04:25Raynes:p
04:25RaynesThis would totally work if not for ~@body forcing evaluating of the damned argument list.
04:26mmarczykhm
04:26mmarczyk~@ has nothing to do with whether sth is evaluated or not
04:26clojurebotIk begrijp
04:26Rayneshttp://gist.github.com/381870
04:26mmarczykouch, sorry, clojurebot
04:27Raynesmmarczyk: I guess that isn't quite what I meant.
04:27RaynesAnyway, the arg list that is being passed to the multimethod from defcommand is being evaluated by something.
04:27RaynesBecause it gives me "whatever is not defined"
04:28RaynesI've never really done anything significant with macros before.
04:29mmarczykI'm trying to fix that atm
04:29RaynesMacros are fun until you realize that you're too dumb to write them. :>
04:30Licenser_Raynes: my experience: often a function works too
04:30RaynesFor context, if anybody is wondering what I'm doing, I'm writing a DSL for plugins in sexpbot.
04:31cgrandRaynes: defplugin's body can only contain defcommand forms?
04:32Raynescgrand: I've not decided on that yet.
04:32RaynesIt depends on whether or not it can contain other things without causing problems. :p
04:32RaynesAll that is really necessary in there is defcommand forms.
04:32RaynesTechnically, anyway.
04:33RaynesYou could put functions and such outside and just drop the defcommands in defplugin.
04:33cgrandthen why bother with two separate macros?
04:33RaynesIt doesn't really matter either way.
04:33RaynesBecause I was trying to go for the put-everything-in-defplugin scheme.
04:34RaynesBecause it would look better.
04:34RaynesIf that's too much trouble, I'll have to go that route.
04:38mmarczykhave you considered using clojure.contrib.macro-utils/macrolet ?
04:39cgrandput-everything-including-defs-and-defns?
04:39mmarczykI've almost reimplemented a chunk of that just now, then realised I'd seen it in contrib :-)
04:39mmarczyk(please disregard the nonsensical `almost' in the above)
04:40Raynescgrand: Indeed.
04:41RaynesWas that moved in contrib master?
04:42RaynesAh
04:42Raynesmacros
04:42mmarczykhttp://gist.github.com/381879
04:42mmarczykI'm using latest contrib now
04:42mmarczykso yeah, maybe it was called something different before
04:42mmarczykthe ns, that is
04:43Rayneshttp://github.com/richhickey/clojure-contrib/blob/master/src/main/clojure/clojure/contrib/macro-utils.clj is giving me a File Not Found
04:43mmarczykthe gist is just a rough sketch, btw
04:44mmarczykhttp://github.com/richhickey/clojure-contrib/blob/master/src/main/clojure/clojure/contrib/macro_utils.clj
04:44RaynesD'oh.
04:44mmarczyk:-)
04:45Raynesmmarczyk: Oh, that's cool.
04:45cgrandRaynes: alternative DSL designs which don't need two separate macros, https://gist.github.com/19367943286f495c96df
04:45Raynesmmarczyk: I can work with this.
04:46RaynesThanks, both of you. I like the macrolet option.
04:47mmarczykcgrand's ideas look good, though -- especially the first one, looks a lot like defprotocol
04:48RaynesI don't think I really understand macros enough to implement either of those idea.s
04:48Raynesideas*
04:49mmarczykthat could be construed as a reason to try :-)
04:49RaynesOr a construed reason to kill myself.
04:49RaynesI was pretty fond of my original idea. :\
04:50RaynesI've already been frustrated for about 2 hours. Not sure I can handle another 10.
04:50mmarczyknothing like a 10-hour-long bug hunting session, I find
04:51mmarczykI mean, I never quite get into that sort of kill-murder-destroy mood in any other way -- and it has this purifying effect, you know? ;-)
04:52Chousukehmhm
04:52ChousukeI think you should try implementing both of cgrand's ideas
04:53RaynesIs the other idea really that bad?
04:54mmarczykwell actually the first defplugin with (cmdkey [args] body...) sections should be the most straightforward too
04:54Chousukewell the worst of it is that it captures the name cmd-list
04:54mmarczykyou could make that (defplugin plugin-name (cmdkey [args] body...)*)
04:54RaynesCapturing cmd-list should never cause any problems.
04:55Chousukethat would be pretty easy. you'd just get the name and a seq of cmdkey specs as parameters
04:55mmarczykChousuke: not with the macrolet approach
04:55RaynesAnd the macrolet approach uses a gynsym.
04:55Raynesgensym*
04:55mmarczyknot to say I don't agree with the general sentiment, which I do
04:56RaynesI need an extra keyboard.
04:56RaynesOne I can beat my head against. :>
04:57mmarczykhm, I seem to have forgotten to include the (let [g (ref [])] ...) bit in the gist, will fix in a sec
04:57Chousukemaybe you're trying too hard :P
04:57Chousukecreate a simpler macro first, then expand
04:57RaynesI kind of just wanted this done. Immediately.
04:57RaynesWhich is more the problem than anything.
04:58mmarczyk...fixed (hopefully)
04:58ChousukeRaynes: make a function that takes one of those (cmdkey [args] ...) things and then returns some clojure code
04:59Chousukethen do your macro like `(do whateverstuff ~@(map helper-fn cmdspecs))
05:00cgrandhttps://gist.github.com/19367943286f495c96df#L11
05:00Chousukethat would be a simple way to implement cgrand's first idea.
05:01Chousuke... or that :)
05:01RaynesClose.
05:02RaynesEach of these commands does more than just exist. Each of them take help string for the command and a list of words that will trigger the command.
05:02RaynesI'm not sure how that would be possible like this.
05:04RaynesOr wait.
05:04RaynesSorry, had a brainfart there.
05:04RaynesIt's all coming back to me.
05:04Raynes:p
05:04Chousukekeep in mind that in principle you're just working with data structures
05:05RaynesChousuke: I was thinking about it too much.
05:05RaynesIt makes sense now.
05:05Chousukeif you design your DSL so that the data structures are easy to modify it'll be easy to implement
05:06Raynescgrand: I appreciate the head start there.
05:06Raynescgrand: You might have just taught me macros. :p
05:07cgrandRaynes: great!
05:08mmarczyk:-)
05:12cgrandRaynes: don't look at this solution now then http://gist.github.com/381898 :-)
05:13mmarczykand a working example of macrolet usage... though for a different purpose (which is ridiculous): http://gist.github.com/381904
05:26Raynescgrand: Out outcomes ended up being quite similar. I just stole your clever trick to get rid of the ref.
05:26Raynescgrand: It's still tossing me that "whatever is not defined" stuff though.
05:27cgrandRaynes: can you paste your test?
05:27Raynescgrand: Also, why is that `(do ..) before the ~@(for ..) important?
05:28Raynescgrand: http://gist.github.com/381923
05:28Raynes"irc is not defined"
05:28RaynesI assume it's trying to evaluate the stuff in the argument vector.
05:28cgrandbecause a macro returns only one form, so you have to group the defmethods and the dosync into a do
05:29Raynescgrand: Oh, alright.
05:29stilkov_Is there a page somewhere that lists the performance guarantees for the various different collections?
05:29stilkov_http://clojure.org/data_structures only mentions them for some functions
05:31Chousukehmm
05:31Chousukea table would be easy to make
05:31Chousuketoo bad I don't have a blog or anything to publish one :P
05:35cgrandRaynes: I can't reproduce your bug
05:35Rayneshttp://gist.github.com/381936 Is there anything wrong with my version?
05:35stilkov_Chousuke: I can offer a a blog that would be happy to host this :-)
05:40Raynescgrand: I think I had some screwed up parens.
05:41cgrandRaynes: I guess beacuse your own version works as well as mine
05:41jwr7deftrace does not support functions with docstrings (as I've just discovered)
05:43Raynescgrand: Works like a charm now. Thanks a lot, and congratulations on being part of the effort to run Clojurebot out of town. ;)
05:43Raynesmmarczyk, Chousuke: Thanks to you guys as well. <3
05:48RaynesNow the fun part.
05:48RaynesConverting some 30 plugins to use the new DSL.
05:49lancepantzcan i use read-properties to read a properties file from the classpath instead of a specific file?
05:50ChousukeI wonder if conj to a vector is log32 or constant time
05:57ChousukeAnyone spot mistakes in this? It's all from memory and docstrings. www.gensoukyou.net/datas.html
05:57sexpbot"datas"
06:03wooby'morning all
06:07ChousukeI wonder about the queue performance guarantees though :/
06:08Chousuketoo bad rhickey isn't here :P
06:10Chousuke(don't tweet that url or anything, I make no guarantees of persisting stuff on my home server)
06:11LauJensenChousuke: So accept stilkov's offer?
06:12Chousukeonly after I get someone to agree with me on the veracity of that data
06:16cgrandChousuke: conj on Queue is O(log32 n) (the tail of a queue is a vector)
06:16cgrandpop is O(1) for vectors
06:17cgranderr no
06:17sparievaccording to Chapter 5 of JoC, count on vectors is "essentially constant time", which means O(log32 n)
06:18Chousukehmm, so they don't store a count value?
06:18cgrandpop is O(log32 n)
06:19sparievoh, sorry, my bad, it's o(1)
06:19sparievmisreading on my part
06:19Chousukeyeah, I just checked the source
06:31ChousukeI guess the table is okay now.
06:41Raynesrhickey: Morning.
06:41rhickeyhey
06:58Chousukerhickey: I wrote a table summarising the performance guarantees of various data structures for certain operations: www.gensoukyou.net/datas.html any comments/corrections?
06:58sexpbot"datas"
07:02rhickeyChousuke: from an algorithmic (big-O) complexity standpoint, O(logN) and O(log32N) are the same, so big-O is not the way to distinguish those. Instead, you can say that access to an element will require max log32N hops, i.e. a concrete limit
07:03rhickeyconj and pop on vectors are O(1)
07:04ChousukeI suppose assoc doesn't work for sets either. I should probably note that somehow
07:06rhickeyconj on queue is also O(1)
07:08AWizzArdrhickey: subvec also O(1) yes?
07:10ChousukeI suppose I'll just change the time guarantees constant, near-constant and logarithmic with explanations
07:11Chousukeand linear
07:13rhickeyAWizzArd: yes
07:14AWizzArdgooood
07:20patrkriswould protocols make it possible to transparently make partition fast on vectors by using subvec?
07:21Chousukepartition is fast
07:21Chousukeit returns a lazy sequence
07:21Chousukeso it's in effect constant tim
07:21Chousuketime*
07:22LauJensenChousuke: I dont follow your logic
07:22patrkristhe call to partition itself is fast, yes
07:23LauJensenpatrkris: But yes, protocols would let you use specific functions for chopping up specific datatypes
07:23patrkrisLauJensen: yes - but I guess multimethods could be used also
07:25LauJensenI guess.
07:27ChousukeI need to learn to use org-mode better :P
07:27Chousukeoh well, I guess the table is okay now.
08:16wlangstrothtechnomancy: were there really that many *jure projects? I only know of scriptjure.
08:17Rayneswlangstroth: Compojure, conjure, enclojure, etc.
08:18LauJensentechnomancy: that last commit was a joke right?
08:18wlangstrothRaynes: I completely forgot about those - LauJensen: Pretty sure that was a joke - doesn't Compojure use lein?
08:19RaynesSurely it's a joke.
08:20LauJensenRaynes: If it was anybody other than phil who made it, I wouldnt even have asked :)
08:20Raynes:p
08:20wlangstrothHe *has* kept it up there for a while, though
08:21RaynesNow my bot has a newly designed plugin system with an implicit help system, and all the plugins have been updated to the reflect the changes. That took a while.
08:21RaynesHuge commit, that was.
08:21Raynes26 files changed, 575 insertions(+), 455 deletions(-)
08:21LauJensenwlangstroth: Yes, and deep down in every American there's a communist screaming to get out, so I wouldnt put it past to him to feel like he should control how we name our projects :)
08:22RaynesHey! :<
08:22wlangstrothLauJensen: It's so true. We Canadians admitted to our socialism long ago.
08:22mmarczykin fact, at this very moment, he is following this conversation and laughing in an evil manner at those who are trying to believe this is all a joke
08:24mmarczyk"Leiningen!" he shouted. "You're insane! They're not creatures you can fight--they're an elemental--an 'act of God!' Ten miles long, two miles wide--*jure projects, nothing but *jure projects! And every single line of code of each one of them a fiend from hell..."
08:24Raynes$help (
08:24sexpbotRaynes: Evalutate Clojure code. Sandboxed, so you're welcome to try to break it.
08:24RaynesIt's beautiful.
08:24Raynesmmarczyk, cgrand: I love you guys. <3
08:25mmarczyk:-)
08:25LauJensenmmarczyk: You must restrain yourself! We dont know for sure yet!
08:26mmarczykpleased to make your acquaintance, Mr. Sexpbot
08:26LauJensen$(dorun (pmap count (partition 2 (range 10e9))))
08:26RaynesThe core code is a mess right now because of a lack of sophisticated hooking.
08:26sexpbotExecution Timed Out!
08:27LauJensenNice work Raynes
08:27RaynesLauJensen: Thank you. <3
08:27RaynesIt uses clj-sandbox for that. Courtesy of Licenser_.
08:28mmarczykLauJensen: there's this strange feeling deep down in my gut, of truly the most dire portent, I fear
08:28wlangstrothThat's the most sophisticated "Execution Timed Out!" I've ever seen.
08:29mmarczyk$(.hash "asdf")
08:29sexpbotNo matching method found: hash for class java.lang.String
08:29mmarczyk(ouch)
08:29mmarczyk$(.hashCode "asdf")
08:29sexpbot3003444
08:29fogus$(#(% %) #(% %))
08:30mmarczyk$(.getDeclaredMethod Integer "parseInt" (into-array Class [String]))
08:30sexpbotDENIED!
08:30rfg$(def x 5)
08:30sexpbotDENIED!
08:30RaynesOh yeah, that reminds me of a big.
08:30Raynesbug*
08:30LauJensen$(future (+ 2 2))
08:30sexpbotDENIED!
08:30RaynesIf it returns nil, it doesn't print anything.
08:30RaynesThat's something I forgot to fix from ages ago, because it isn't on my TODO list. :>
08:30mmarczyk$(eval :foo)
08:30sexpbotDENIED!
08:30mmarczyk$:foo
08:30sexpbotCommand not found. No entiendo lo que estás diciendo.
08:31rfg$*clojure-version*
08:31sexpbotCommand not found. No entiendo lo que estás diciendo.
08:31mmarczyk$(do *clojure-version*)
08:31sexpbotDENIED!
08:31mmarczyk$(identity *clojure-version*)
08:31sexpbotDENIED!
08:31RaynesIt's 1.2.
08:31RaynesBut that var isn't whitelisted.
08:31mmarczykthe secretive Mr. Sexpbot :-)
08:31mmarczyk$(clojure.contrib.find-namespaces/find-namespaces-on-classpath)
08:31sexpbotclojure.contrib.find-namespaces
08:32rfg$(System/getProperty "java.class.path")
08:32sexpbotDENIED!
08:32RaynesRight now, you can do less with him than you can with clojurebot, because of manual whitelisting. Lot's of useful stuff is whitelisted (everything in the core API docs, nearly).
08:33mmarczykwhy'd he return 'clojure.contrib.find-namespaces for $(clojure.contrib.find-namespaces/find-namespaces-on-classpath) ?
08:33mmarczyk#clojure-casual ? is there such a channel? :-)
08:33RaynesI don't know.
08:33fogus$(let [$ identity] (#(% $) #(% $)))
08:33sexpbotclojure.core$identity__3929@e62a39
08:33Raynesmmarczyk: Indeed.
08:35mmarczyk$(ns-resolve *ns* '*clojure-version*)
08:35sexpbotDENIED!
08:35Licenser_mmarczyk: if you break the sandbox you get a cookie :P
08:36mmarczykoh! oh!
08:36mmarczyklemme get the code then
08:37Licenser_mmarczyk: changing the code to break it does not cound :P
08:37mmarczykthat much is understood :-)
08:37Licenser_elsewhre http://github.com/Licenser/clj-sandbox
08:37sexpbotPage has no title.
08:37RaynesUh oh.
08:37RaynesThat isn't good.
08:37Licenser_I broke sexpbot
08:38Licenser_heh
08:38RaynesHe's supposed to ignore github titles.
08:38mmarczykstill, I shall learn the anatomy of the target, so that I may most swiftly concoct the lethal poison with which to corrupt it
08:38Licenser_mmarczyk: appriciated
08:39Licenser_I claim it to be more secure then clojurebot :P
08:39RaynesOh, I see.
08:42Raynes<Licenser_> elsewhre http://github.com/Licenser/clj-sandbox
08:42RaynesThere we go.
08:42RaynesGood bot.
08:43mmarczyk$(meta #'+)
08:43sexpbot{:macro false, :ns #<Namespace clojure.core>, :name +, :file "clojure/core.clj", :line 716, :arglists ([] [x] [x y] [x y & more]), :inline-arities #{2}, :inline #<core$_PLUS___3797 clojure.core$_PLUS___3797@15ed7e7>, :doc "Returns the sum of nums. (+) returns 0."}
08:44mmarczyk$(.alterMeta #'+ assoc :name '-)
08:44sexpbotTried to call: alterMeta on #'clojure.core/+ which is not allowed.
08:44mmarczyk:-)
08:44Licenser_:)
08:44Licenser_good aproach but no cookie yet
08:45mmarczykthis only serves to strengthen our resolve (and hopefully the awaiting cookie grows larger in time)
08:45Licenser_just more
08:46Licenser_you know there is a limit of cookie size to create but the ammount of cookies - while certenly limited - is way more extenedable
08:46mmarczyk"You silly wabbit..." :-D
08:46RaynesWell, _ato` just broke sexpbot.
08:47RaynesYou guys are on a roll today. :p
08:47Licenser__ato`: is good at breaking things
08:47mmarczykLicenser: oh, I should have realised you'd have a lazy sequence of cookies
08:47Licenser_of cause
08:48Licenser_if my stove could laziely evaluate it I even could make a unlimited sized cookie but sadly it's a java stove and I don't have a clojure wrapper yet
08:49mmarczyk$(symbol "asdf")
08:50mmarczykoh the bothersome legacy stoves
08:51Licenser_$(symbol "asdf")
08:51sexpbotresult: asdf
08:51RaynesNot as fixed as I thought.
08:52mmarczykhm
08:53mmarczyk$(throw (RuntimeException. "asdf"))
08:54Raynesmmarczyk: You might want to wait until the bot is online. :p
08:54RaynesWorks better that way.
08:55mmarczykthe very same idea has occurred to me ;-)
08:58mmarczykright, um, so I was going to retry that; here goes:
08:58mmarczyk$(throw (RuntimeException. "asdf"))
08:58sexpbotasdf
08:59spariev$(str "b" (reduce (fn [x y] (str x "i")) "i" (take 30 (repeat :cookie))) "g cookie")
08:59sexpbotresult: biiiiiiiiiiiiiiiiiiiiiiiiiiiiiiig cookie
08:59sparievjust experimenting with lazy seq of cookies
08:59Licenser_good work spariev
08:59RaynesCookies taste good.
09:00mmarczyk$(str #=(println "Regrettably, one must work harder than this for one's cookie."))
09:00sexpbotEvalReader not allowed when *read-eval* is false.
09:08fogusClojure API needed. http://www.flyobjectspace.com/
09:08sexpbot"Fly Object Space"
09:09mmarczyk$(() ())
09:09sexpbotclojure.lang.PersistentList$EmptyList cannot be cast to clojure.lang.IFn
09:10mmarczyk$(the-ns 'user)
09:10sexpbotresult: user
09:11mmarczyk$(.getMapping (the-ns 'user) 'resolve)
09:11sexpbotDENIED!
09:11mmarczyk:-(
09:12mmarczykobviously not gonna work, but hey... I've just thought of at least a dozen convoluted ways of calling Clojure functions by name :-)
09:17Chousuke,(resolve 'foo)
09:17clojurebotnil
09:18Chousuke,((resolve (symbol (apply str '[e v a l]))) '(+ 1 1))
09:18clojurebot2
09:18Chousuke:P
09:18mmarczykoh my :-)
09:19ChousukeI don't think there's any way to prevent arbitrary evaluation without actually explicitly somehow removing eval from the sandbox ns and all ways of getting to it.
09:19mmarczykyou're talking to the wrong bot, though :-)
09:19mmarczyk$(resolve 'foo)
09:19sexpbotDENIED!
09:19mmarczyk,(resolve 'foo)
09:19clojurebotnil
09:20anars,(doc resolve)
09:20clojurebot"([sym]); same as (ns-resolve *ns* symbol)"
09:20Chousuke$(var resolve)
09:20sexpbotDENIED!
09:20Chousuke$(ns-resolve *ns* 'foo)
09:20sexpbotDENIED!
09:20Chousukehmm, they've been more thorough :P
09:20Chousuke$'resolve
09:20sexpbotCommand not found. No entiendo lo que estás diciendo.
09:21Chousuke$(do 'resolve)
09:21sexpbotDENIED!
09:21Chousuke... very thorough :P
09:21Chousuke$(ns-mappings *ns*)
09:21sexpbotDENIED!
09:21Chousukehmmh
09:24LauJensenChousuke: I wonder if you ask Raynes nicely, if he won't give you your own special channel wherein you can practice :)
09:24RaynesI already did. :\
09:24RaynesThey just haven't listened. :p
09:24kzar#clojure-casual I think
09:25RaynesLauJensen: Every time people play with the bot, I note that it's in #clojure-casual as well for extended playtime.
09:30RaynesAt least chouser didn't have to see me make a fool of myself.
09:31Chousukeheh
09:31LauJensenmmarczyk: you're switching to mouse ?
09:31LauJensencemerick: You got me there :)
09:32Chousukehttp://github.com/technomancy/leiningen/commit/39732d5b649dedb70b14e88fe561dfc9ddb31611 \o/
09:33wlangstrothLauJensen: I'm guessing the concern for American roots had more to do with being sued than incurring a tax.
09:34LauJensenwlangstroth: as cemerick pointed out yes - though I hold a small grudge against your main man Al Gore, who wants to tax all of my precious CO2
09:35cemerickah, the blunt cludgel of tax policy :-)
09:36wlangstrothLauJensen: I didn't realize you were the one responsible for so much CO2.
09:36LauJensenYea thats my bad Im afraid
09:38wlangstrothI mean, I knew you were responsible for a lot of hot CO2, but ...
09:39LauJensenwow, cheap shot
09:40wlangstrothit was *right there* - how could I not take it? Besides, there's no technical discussion that I would interrupt.
09:40LauJensenyea I completely understand, now get going, I believe there are trees that need hugging - right ABOOT now :)
09:42RaynesOh. I accidentally did :reload-all instead of :reload.
09:42RaynesGood stuff.
09:43wlangstrothI believe you mean "A-BOAT", which is how we really say it. Hold on - there's an unhugged tree outside.
09:45wlangstrothLauJensen: where *are* you, anyway - I want to at least know what part of Scandahoovia I'm insulting
09:46RaynesNow the bot has reload functionality. No more shutting him down just to fix a bug.
09:49powr-tocIs there a variant of catch that allows you to catch nested
09:49powr-tocexceptions? I'm using c.c.sql and it throws RuntimeExceptions, yet
09:49powr-tocthe errors we need to catch are causally 2 deep
09:50LauJensenwlangstroth: Im in the middle of everything, aka Denmark
09:50clojurebotwhat time is it?
09:50underdevTime to get ill!
09:50Raynespowr-toc: clojure.stacktrace.
09:50rfgDenmark FTW
09:50Raynespowr-toc: (catch Exception e (.getMessage (clojure.stacktrace/root-cause e)))
09:51AWizzArdSQL-Gurus: I want to insert the contents of a vector 'v' into a table 't'. Only at runtime it is clear what the table is and how many elements the vector contains. Is there a better solution than (format "INSERT INTO %s (%s)" t (str/join \, (repeat (count v) \?)))
09:52AWizzArd,(format "INSERT INTO %s (%s)" "table" (str/join \, (repeat 5 \?)))
09:52clojurebotjava.lang.Exception: No such var: str/join
09:52AWizzArdwhere str/join ==> clojure.contrib.string/join
09:52AWizzArd,clojure.contrib.string/join
09:52clojurebotjava.lang.ClassNotFoundException: clojure.contrib.string
09:53zmilaAWizzArd - preferably you create sqls with different known tablenames, and then on run-time dispatch and select one of it
09:57AWizzArdzmila: clean and bureaucratic (:
09:57AWizzArdHallo bendlas
09:57bendlashi AWizzArd
09:58zmilaAWizzArd - RDBS performs better with prepared statements, it's not good to parse query on each insert.
10:00mattcodesyikes never expect this many people in a clojure chat room, tried join expecting id be setting up the room :)
10:01bendlasyeah, clojure has taken off
10:01chousermattcodes: only a couple years late :-)
10:02mattcodesprobably working through rubylearning clojure 101 course and programming clojure book (using intellij as IDE). still struggling to see benefits although i guy i follow on twitter has said it runs their forex system
10:02mattcodesi guy --> 1 guy
10:03chousermattcodes: benefits compared to what?
10:04slyphonchouser: a poke in the eye with a sharp stick
10:04slyphonchouser: oh, sorry, i meant VBScript
10:04chouserClojure benefit #1: doesn't poke you in the eye
10:04mattcodescoming from working with c# since 1.0 and getting alright in it (not ayende or udi dahan level) when would you use it in production? i watch a presentation the other day that social aspect make programming language successful - wealth of resources, pool of applicants for jobs, getting comfortable with clojure now but still cant see much benefit over java/c#
10:05mattcodesso someone is using in forex, just for algorithms like moving average or to host whole app, you write an app with you and your other collegaue, try going monster.com and getting a replacement
10:05slyphonthat's a very CTO way of looking at it
10:06mattcodesplaying devils avocadate because as much as Im improving and groking the concept I need a real excuse other than kool aid to follow it. e.g. peers of mind go scala meet ups (and have for 12 months) but come back and architecture and write everything in c#
10:06Raynesmattcodes: Clojure isn't as buried as you might think.
10:06chouserjust watching this now: http://vimeo.com/11236603 ...an excelent presentation of one of the kinds of problems Clojure helps you solve better than a lot of other languages.
10:06slyphonor, you and your buddy *write* monster.com in whatever language makes you most productive, sell it to a bunch of guys who will *hire* some team of monkeys to code it into PHP while you enjoy flying around the world on a plane-that-never-lands
10:06Raynesmattcodes: It's experienced extremely aggressive growth in the past year or so.
10:07mattcodesi want to like it - dont get me wrong - to be a polygot programmer surely is a good thing but i dunno perhaps im asking questions too early
10:07mattcodeswill check out the vimeo vids
10:07slyphonmattcodes: i'm writing a scheduler for a render farm with it
10:08stilkov_Chousuke: Thanks for the O() table, excellent
10:08mattcodesslyphon, and what benefits do you get over Java? presumably your utilising the stm?, for normal (most) apps thread per request im still not swaded
10:09Chousukestilkov_: feel free to reformat it if you want to publish it in a blog or something
10:09mattcodesis it just because we have got into a habit of abusing mutable objects in java/c# etc?
10:09Chousukestilkov_: org-mode exports contain a lot of extraneous stuff but it should be pretty easy to find the table in there.
10:10mattcodes(sorry I am playing devils avodcate here)
10:10stilkov_Chousuke: thanks, will do and link here
10:11Chousukestilkov_: don't link to my domain though. it's just a temporary storage for stuff.
10:12Chousukemattcodes: immutability makes things easier even if your application isn't multithreaded
10:12stilkov_Chousuke: have you considered gh-pages?
10:13Chousukestilkov_: I guess I could take a look.
10:13mattcodesis anyone writing CRUD style apps in clojure? blogs, forum software, crm, sales, etc..
10:15foguschouser: As always, a great video by Stu.
10:17chouserI'm trying to take his intro slide as a lesson. I already know about protocols and yet by the time he was done with that slide I *really* wanted to watch the rest to see all the things he teased.
10:17chouserI want to write chapter intros like that. :-)
10:17chouserwait, is this a public forum?
10:18Raynes_ato is evil.
10:19chouserRaynes: heh, did he hack it?
10:20Rayneschouser: He executed brainfuck to set the bot's nick.
10:21_ato$bf +++++++++++++.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.-----.------.++++++++.-------------------------------------------.++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.---.++.------.+++++++++++++++.------------.+.++++++++++.
10:21bfwin{:ptr 0, :cells {0 115}}
10:21bfwin[13 78 73 67 75 32 108 105 107 101 116 104 105 115]
10:22Chousuke:P
10:23fogusThat is a cool hack
10:25fogusI would have never thought of that in a million years
10:25RaynesIt's fixed now.
10:25Raynesfogus: _ato is a beast.
10:25fogusRaynes: Good thing he's on our side... or is he? :O
10:25Chousukehow is the bf interpreter capable of changing the bot's nickname? :/
10:26Raynesfogus: :p
10:26RaynesChousuke: \rNICK
10:26Chousukeaha
10:26RaynesNone of my commands filter newlines and carriage returns. He's finding those flaws.
10:26Chousukehmm
10:27Chousukewonder if that works with clojurebot too
10:28RaynesDoubt it.
10:28Chousukeit filters newlines but I'm not sure about CRs
10:28Chousuke,(print "\rNICK testbot") ; something like this?
10:28clojurebot NICK testbot
10:28RaynesIt filters them.
10:29technomancyLauJensen: it doesn't stop you from using lein with compojure, it just stops you from generating new *jure projects
10:29technomancy-
10:29Raynestechnomancy: You're actually serious, aren't you. o.o
10:30Chousuketechnomancy: I approve
10:30wlangstrothtechnomancy: cenjureship!
10:30Chousukethere was this new library called "matchure" and my first thought before "cool!" was "oh no, another bad pun :("
10:30RaynesI approve, but wow.
10:30RaynesBalls, man. You have them.
10:31wlangstrothoh, at least it wasn't "matjure"
10:31Chousukewell it's just as bad
10:31fogusThankfully my super-secret project "jurey-rig" still works
10:32wlangstroththere's no filter for *all* bad puns
10:32wlangstrothfogus: that's terrible
10:32wlangstrothfogus: I died just a little inside
10:34_ato$ lein new injure-technomancy -- Exception in thread "main" java.lang.IllegalArgumentException: *jure names are no longer allowed.
10:34likethisCommand not found. No entiendo lo que estás diciendo.
10:34LauJensentechnomancy: Ok, so if this is not a joke, please explain why you should decide what my projects should be called and not me/my clients?
10:37wlangstrothLauJensen: because Phil rules (which should go in the error message, if you ask me)
10:37ChousukeLauJensen: because nothing will actually prevent you from naming your project whatever you want.
10:37ChousukeLauJensen: leiningen will just refuse to help you
10:37technomancyLauJensen: if you really want to you can create a project skeleton then rename it
10:37technomancyit's just ... encouragement =)
10:38fogustechnomancy: I think you didn't go far enough... you should refuse any name that has a 'j' somewhere in the middle. :p
10:38Chousuke:P
10:38technomancyas to whether it's a joke or not, well it's an open question.
10:39arkahnhow does sexpbot understand bf?
10:41_atoarkahn: http://github.com/Raynes/sexpbot/blob/master/src/sexpbot/plugins/brainfuck.clj
10:41LauJensentechnomancy: I think its in poor taste. I agree that we've all had enough of these J-themed names, in fact I would probably vote for a renaming of Clojure itself, but I think its way over the line that you try to police it via restrictions on the use of lein
10:41Raynesarkahn: I didn't write that, by the way.
10:41arkahn_ato: excellent : ) Thank you
10:42arkahnRaynes: I'd still be proud ; )
10:44technomancyif there weren't a workaround I'd consider reverting it, but it's just an easter egg.
10:57Licenser_h
11:03LauJensentechnomancy: thats it, I'm forking leiningen: Attention everybody, may I present: Leinjure
11:05wlangstrothLauJensen: will we all be forced to pronounce it "line-yoor"?
11:06LauJensenabsojutely
11:06technomancyoh man, I should have seen that coming. =)
11:07technomancyactually you could just implement that as a plugin
11:07sparievLauJensen: you can do what you want in your leijure time :)
11:07LauJensenleinjure will projibit plugins
11:07technomancy"lein newjure" => it automatically adds "jure" to the name of the project you're trying to generate
11:07LauJensenperfect!
11:07wlangstrothtechnomancy: you're a genius!
11:08LauJensengejinus!
11:08wlangstrothLauJensen: I wasn't going to do it
11:09wlangstrothI think we're only serving to illustrate the wisdom of technomancy's decision
11:20stilkov_Chousuke: http://www.innoq.com/blog/st/2010/04/clojure_performance_guarantees.html
11:20sexpbot" Clojure Performance Guarantees - Stefan Tilkov's Random Stuff"
11:23chouserthat's a nice table
11:23Chousukestilkov_: looks good. and hopefully is free of errors :P
11:23chouseris vector and queue conj really constant?
11:24Chousukechouser: Rich said so
11:24wlangstrothstilkov_: nice chart - it's also true that this channel is great
11:24AWizzArdchouser: I understood Rich in that way: the performance has an upper limit. Thus, it is not constant, but typically below this limit.
11:24sparievchouser: and it's written in your book :)
11:25sparievabout queue, at least
11:25LauJensenchojer: read the logs from 2 hours ago approx
11:25Chousuke:P
11:25chouserall the near-constant things have upper limits too
11:25zmilastilkov_, please add some colors to the table cells - according to performance
11:26chouserour book isn't yet perfect... ;-)
11:26stilkov_zmila: good idea
11:26Chousukechouser: I think they might be something like initially linear but constant after n > something.
11:28chouserI see calls in PersistentVector.cons() to newPath and pushTail, which are both recursive.
11:28chouserSo I'm surprised those are O(1). But far be it from me to contradict rhickey.
11:28wlangstrothChousuke: would that n have to do with the 32-bit hash implementation?
11:28Chousukewlangstroth: no?
11:29AWizzArdchouser: http://clojure-log.n01se.net/date/2010-04-28.html#06:41
11:29sexpbot"#clojure log - Apr 28 2010"
11:32rhickeychouser: pushTail will only be called 1x in 32
11:32wlangstrothChousuke: I mean what's the limit on bagwell hash tries?
11:32Chousukewlangstroth: I'm the wrong person to ask about such things
11:33chouserstilkov_: rather than saying "increases linearly" in the definition of "linear", you might consider saying "when the collection is twice as large the operation takes twice as long"
11:33jowagso, it seems that if I specify :library-path "/" in a project.clj, "lein clean" will delete my filesystem :)
11:33chouserrhickey: so (log32 n)/32 ?
11:34Chousukeyou might want to clarify the "(e.g. 3.9 as long for a million elements than for 10 instead of 6)" too since it took me a long time to understand what that meant :P
11:34Chousukestilkov_: that was for you ^
11:34stilkov_chouser: agreed on both parts - it doesn't help there's a "times" missing ;-)
11:36rhickeychouser: but log32N is always less than 32 for all data sizes we might consider
11:38rhickeystilkov: that 3.9 times as long is a bit disconcerting. It is important to look at the absolutes rather than ratios. to get to 1 milltion: 1 hop from 32 to 1k, one hop from 1k to 32k, 1 hop from 32k to 1million = 3 hops
11:39rhickey1 billion = 5 hops
11:39chouserok, I see.
11:40rhickeybinary tree is 20 hops to 1million
11:40AWizzArdand 1 msec ==> 3k hops?
11:40rhickeyAWizzArd: ?
11:43AWizzArd,(time (let [hm (hash-map :a 1 :b 2 :c 3)] (dotimes [i 1000000] (get :b hm))))
11:43clojurebot"Elapsed time: 209.814 msecs"
11:43AWizzArd,(double (/ 1000000 209.814))
11:44clojurebot4766.126187956953
11:44rhickeyoh please
11:44AWizzArd4766 gets per msec
11:44rhickeylet's not waste time with microbenchmarks again
11:45AWizzArdWhy is it then important how many hops we need to one million/billion?
11:48chouserAWizzArd: that has to do with relative amount of work and is useful for choosing the correct collection/algorithm combination
11:49AWizzArdYes, though "hops" is an abstract thing for my poor human brain. "Time" says me more.
11:49chouseractual timing of large numbers of trivial operations depends on a lot of variables, most of which are both hard to control for and hard to control, and very few of which impact algorithm decisions
11:50sattvikAWizzArd: When deciding on a data structure for a given purpose, it is important to know the algorithmic performance guarantees of the structure. With that information and knowledge about how the structure will be used, the correct structure can be chosen. Ops/sec don't really tell you anything; they are highly dependent on the conditions of the test. Not least of all, they are unrealistic for most scenarios.
11:50AWizzArdWhen I hear: you can do 5k gets on Maps up to 100k elements, 3k gets on maps to 1 mio elements and 2k gets on maps to 1 bil elements, all per msec, then this gives me some information that I understand (:
11:50AWizzArdsattvik: yes
11:50rhickeyAWizzArd: and when the optimizer figures out that code doesn't do anything and optimizes it to instant, will it be very fast then?
11:50wlangstrothAWizzArd: but then you'd have to follow that up with your system configuration stats
11:51rhickeyI've been auditing some of the seq fns for inclusion in core, not sure I want to include indexed
11:51rhickeyI think it leads to bad perf code
11:51rhickeyI instead have map-indexed, where the mapping fn will get passed the index and the item
11:52rhickeyindexed == (comp map-index vector)
11:52rhickeyer, map-indexed
11:53chouserI wish I had all the clojure code I'd ever written indexed somewhere by idiom.
11:53clojurebotYes, Clojure can do that!
11:54AWizzArd^^
11:54chouserThen I could find the 5 places I've used indexed and see how well map-indexed would fit.
11:54rhickeythinking about the filter analogue, I've come up with keep, like filter, but yields the result of the function if truthy, rather than the item
11:54rhickeythen we could have keep-indexed as well
11:54chouserooh, for (filter identity (map ...))
11:55hiredmangrep --include "*.clj" -R indexed src/*
11:55wlangstrothrhickey: I've reached for something like that twice now, so I'd be all for that
11:55chouserany chance of getting multi-seq walking on any of these? keep in particular.
11:55wlangstroth(keep, that is)
11:56stilkov_rhickey: not sure whether my understanding of hop is correct
11:57stilkov_the amount of time for some operation increases with the number of elements, either not at all, or logarithmically, or linearly, or something we don't hope for
11:58rhickeystilkov_: being trees, the cost of trees increases with their depth, one hop is nav from node to node
11:59stilkov_and the depth increases with log32(n) - right?
11:59rhickeystilkov_: you can compare the rations between log32 and log2, but it doesn't tell the absolute value story well
11:59zakwilsonkeywords are substantially faster as map keys than strings, right?
11:59stilkov_rhickey: ah, so you're not saying my explanation is wrong, just misleading
12:00rhickeye.g. in a binary tree, going from 33 items in the tree to 1 million mean going from 5 hops to twenty, in a clojure data structure it means going from 3 hops to 3 hops - same cost
12:01ordnungswidrigrhickey: so why is 32 the sweet spot?
12:03rhickeyand 1-32 all take the same cost, no ratios at all, so it is not a continuum. Also in absolute terms, at max a Clojure tree (of a billion items) will take as many node navs as a binary tree with 32 items
12:05rhickeyoops sorry, s.b. 3 hops to 4 hops above
12:05stilkov_3.9 something
12:05stilkov_rhickey: OK, will update accordingly. Thanks for the explanation.
12:06dnolenrhickey: ++ for map-indexed. I don't need indexed collections often, but when I do, that would be nicer than using indexed which is always a bit of a pain.
12:09technomancyI guess the only problem with map-indexed vs indexed + map is that then you have to have -indexed versions of all your seq-consuming functions, right?
12:10rhickeytechnomancy: you can always (map-indexed vector...), it is simply a better primitive than indexed
12:11technomancyoh sure, that makes sense
12:12rhickeystilkov_: in practice people will not see lookup perf change significantly with data structure size:
12:12rhickey(let [v1k (into [] (range 10))
12:12rhickey v1m (into [] (range 1000000))]
12:12rhickey (time (dotimes [_ 1000000] (rand-nth v1k)))
12:12rhickey (time (dotimes [_ 1000000] (rand-nth v1m))))
12:12rhickey"Elapsed time: 257.341 msecs"
12:12rhickey"Elapsed time: 461.878 msecs"
12:12technomancystill a little awkward more if you want to use it in a doseq, but maybe it'll grow on me. I like the concept.
12:13stilkov_rhickey: so the "near-constant" moniker seems very much justified
12:14eyerisThe docs give the declaration (struct-map s & inits). Could someone translate this to english?
12:14rhickeystilkov_: right, even though some aspect is growing with a logarithmic relationship to the size, it becomes dominated by the constant factors
12:14eyerisI'm clearly not understaning what is expected for inits.
12:15eyerisAs a lisp-noob I thought & inits meant "and the rest of the arguments are converted to a list"
12:15eyerisSo I tried (struct-map my-declared-struct :key1 val1 :key2 val2)
12:15hiredmanthe docs for what?
12:16eyerisThe api docs on the web site.
12:16eyerishttp://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/struct
12:16hiredmanright, but the api docs cover EVERYTHING
12:16hiredmanso specificly that is the docstring on struct
12:16eyerisOr, for (struct-map)
12:16Chousukeeyeris: the list of inits is a list of init values, not a list of key/val pairs
12:17hiredman,struct-map
12:17clojurebot#<core$struct_map__5559 clojure.core$struct_map__5559@323ee8>
12:17hiredman,(doc struct-map)
12:17clojurebot"([s & inits]); Returns a new structmap instance with the keys of the structure-basis. keyvals may contain all, some or none of the basis keys - where values are not supplied they will default to nil. keyvals can also contain keys not in the basis."
12:17hiredmaneyeris: looks like you are confusing struct-map and struct
12:17eyerisSo I just have to supply values for the keys in the order that their appear in defstruct?
12:17Chousukehuh. that docstring is confused
12:18Chousukeeyeris: yes
12:18stilkov_,(do (defstruct my-declared-struct :key1 :key2) (struct-map my-declared-struct :key1 1 :key2 2))
12:18clojurebotDENIED
12:18Chousuke(doc struct)
12:18clojurebot"([s & vals]); Returns a new structmap instance with the keys of the structure-basis. vals must be supplied for basis keys in order - where values are not supplied they will default to nil."
12:18stilkov_eyeris: yields {:key1 1, :key2 2} in my REPL
12:19Chousukeright, so struct-map takes k/v pairs (though the docstring is confusing) and struct takes init vals
12:20rhickeychouser: you can extend them to N colls as a patch if you like :)
12:20stilkov_eyeris: so what problem do you run into with your code?
12:20eyerisstilkov_: I was initially confusing struct and struct-map as hiredman pointed out.
12:21AWizzArdrhickey: do you plan to add a Foo/create to records before 1.2?
12:22rhickeyAWizzArd: dunno
12:22eyerisI initially used your invocation with struct instead of struct-map. Assuming that I misunderstood the & notation, reading the word keyvals in the struct-map documentation, I put my :key val sequence into a map. I realized that I needed struct-map, but then I forgot to remove the map braces :)
12:25AWizzArdrhickey: in principle it could be advantageous to ship 1.2 without that and just wait a while and see what the users are doing. New features can be added later. But then print-dup could be adpoted maybe, to not print as #=(user.Foo/create {:x 1000})
13:26slyphonchouser: around?
13:26chouserw'sup?
13:26clojurebothttp://github.com/hiredman/clojurebot/tree/master
13:26slyphonchouser: could you look at something for me and tell me if i'm "doing it wrong"?
13:27slyphonhttps://gist.github.com/9ddaa20d37a4a4be4d07
13:27KirinDave_Oh shit
13:28slyphonchouser: i'm just not sure if i'm missing something, like line 100
13:28slyphonstylistically speaking
13:28slyphondoes this look like what clojure test code should look like?
13:29chouseryeah, I'm not the best person to ask about this.
13:29slyphonoh :)
13:30slyphoni guess it's just that i don't work with a bunch of other clojure developers, and i know i'm learning, so i always have that voice in the back of my head saying "you're doing it wrong"
13:30digash(defn ^bytes [] (byte-array 10)) (String. (bytes10))
13:30chouserslyphon: oh, it's good to ask, but I haven't done enough with clojure.test to really know the idioms
13:30digashthrows an exception Unable to resolve classname: clojure.core$bytes__4916@27443628
13:30digash
13:30slyphonchouser: who do you think i should ask?
13:31chessguyso someone at my work is looking for implementations of this function, but i don't know the clojure libraries well enough to do it without a painstaking search
13:31digashdoes anybody know why? I am on the latest 1.2
13:31chessguyhere's the ruby implementation
13:31chessguystr.split('/').reject(&:blank?).reverse.join(', ')
13:31chessguypretty darn expressive
13:31slyphonthat's "rails"
13:32slyphonso some of the expressiveness has been handed to you
13:32chessguywell, sure you can use libraries
13:33chessguydoesn't make it a different language
13:33chouserdoes &:blank? just match empty strings or also whitespace?
13:33chessguyempty strings
13:33slyphonblank means "is nil or empty string"
13:33slyphondoesn't barf on nil
13:34chouser(->> "abc/def/ghi" (.split #"/") (remove empty?) reverse (str/join ", "))
13:34slyphonwuuuuu!
13:35slyphon(.split #"/") really?
13:35slyphonnice
13:35chessguy,((->> "abc/def/ghi" (.split #"/") (remove empty?) reverse (str/join ", ")) "/C=US/O=U.S. Government/OU=DoD/OU=CENTCOM/OU=People/CN=Smith Bob A xyz123")
13:35clojurebotjava.lang.Exception: No such var: str/join
13:36slyphonHAH
13:36slyphonchessguy: you're leaking classified information there
13:36chessguyabout Bob Smith?
13:36slyphon*joke*
13:36zakwilson,(reverse (filter #(not (= "" %)) (.split "foo/bar/baz//qux" "/")))
13:36clojurebot("qux" "baz" "bar" "foo")
13:37licoresseemacs clojure-test-mode, is that working well with 1.2?
13:37zakwilson,(reverse (remove empty? (.split "foo/bar/baz//qux" "/")))
13:37clojurebot("qux" "baz" "bar" "foo")
13:37licoresseI'm new to tests and clojure
13:38chouserzakwilson: I recommend (.split #"regex" "string") over (.split "string" "regex-in-a-string")
13:39zakwilsonchouser is more of an authority than I am. Listen to him.
13:39dnolen(->> "abc/def/ghi" (split #"/") (remove blank?) reverse (join ", "))
13:39dnolenif you're using clojure-contrib 1.2.0
13:40chessguythat's nice
13:40chessguythough i'd rather have a function i could pass the string into
13:40slyphonuh
13:40slyphonyou just wrap the above in (fn blah [s] ...)
13:40chessguyyeah, i know
13:41chessguybut it's not that way now
13:41zakwilson,(#(->> % (split #"/") (remove blank?) reverse (join ", ")) "foo/bar/baz//qux")
13:41clojurebotjava.lang.Exception: Unable to resolve symbol: join in this context
13:41zakwilson,(#(reverse (filter #(not (= "" %)) (.split #"/" %))) "foo/bar/baz//qux")
13:41clojurebotNested #()s are not allowed
13:42zakwilson,(fn [x] (reverse (filter #(not (= "" %)) (.split #"/" x))) "foo/bar/baz//qux")
13:42clojurebot#<sandbox$eval__12354$fn__12356 sandbox$eval__12354$fn__12356@174c643>
13:42zakwilson,((fn [x] (reverse (filter #(not (= "" %)) (.split #"/" x)))) "foo/bar/baz//qux")
13:42clojurebot("qux" "baz" "bar" "foo")
13:42zakwilsonThere... NOW it has enough parens to be proper Lisp!
13:43slyphonzakwilson: hah!
13:43chessguylol
13:46licoressehow do I organize the test-files under test/ ? SHould I follow the same directory-structure as my clj files? Should there be a 1-to-1 mapping of source and test-source?
13:46licoresseTrying to figure out the C-c t command in clojure-test-mode
13:47licoresse(the one that switches from source to test-source)
13:48technomancylicoresse: the test toggle is kinda half-baked; there aren't any good conventions yet for mapping between test and impl.
13:48licoressetechnomancy: ok
13:49licoresseThat means, I should'nt worry too much about where to put the tests...
13:49licoresseas long as they are under test/
13:49licoressetechnomancy: correct?
13:49technomancyI like to have src/foo/bar.clj map to test/foo/test-bar.clj personally, but yeah, anything under test/ works
13:50stuartsierratechnomancy: I liked Halloway's suggestion of test/foo/bar_test.clj, results in better sorting
13:50technomancystuartsierra: sure, good point.
13:51licoressestuartsierra: yes
13:51technomancywe currently have test/foo/test/bar.clj, which is lousy because stack traces often just give the last segment, so you can't distinguish between impl and test. =\
13:52wlangstrothchouser: for the above matching, is there any reason not to use re-seq?
13:53BorkdudeWhat's the deal with str-utils and str-utils2, which should I use?
13:53chouserwlangstroth: not really -- just which is more natural for the regex you want. they're sort of complements of each other.
13:55stuartsierraBorkdude: neither :)
13:55stuartsierraBorkdude: In 1.2, both are deprecated in favor of c.c.string.
13:55Borkdudestuartsierra: just use the things you need from either or both?
13:55Borkdudeoh
13:56stuartsierraBorkdude: str-utils2 will be faster than str-utils(1), should support all the same functionality.
13:56Borkdudehow do I disuse a namespace?
13:56stuartsierraYou mean unmap the symbols you referred with "use"?
13:56Borkdudeyes
13:57stuartsierraCan't. Just create a new namespace to work in or restart the REPL.
13:57Borkdudeah
13:57chouser(re-seq #"[^/]+" txt) seems clumsier than (.split #"/" txt) ...besides not meaning *exactly* the same thing
13:57kotarak(doc ns-unmap)
13:57clojurebot"([ns sym]); Removes the mappings for the symbol from the namespace."
13:57kotarakBorkdude: could be tedious
13:58kotarak(doc ns-interns)
13:58clojurebot"([ns]); Returns a map of the intern mappings for the namespace."
13:58Borkdudestuartsierra: I made a new ns and used c.c.string, I get this:
13:58Borkduderepeat already refers to: #'clojure.core/repeat in namespace: user2
13:58stuartsierraoh yeah
13:59stuartsierrac.c.string contains names that clash with core
13:59stuartsierraYou can't "use" it without ":only".
13:59stuartsierraOr, alternately, "(require '[c.c.string :as s])"
14:00wlangstrothchouser: right, thanks
14:00mabesdoes anyone know of a congomongo clojure 1.2 compat fork? There doesn't appear to be any on github or clojars...
14:02BorkdudeI was just wondering if split also was a function in c.c.string or if it still should be called using direct java interop
14:03Borkdudebut apparently it's not in there
14:03kotarakmabes: I seem to remember I used it with 1.2. What problem do you see?
14:03mabeskotarak: I haven't dug into it yet, but when I try to 'use' it I get: java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V (coerce.clj:1)
14:04stuartsierraBorkdude: "split" is in c.c.string
14:04kotarakmabes: then you have to recompile it with 1.2 (or use the source files directly). I'm not sure whether it uses gen-class. I think, that part is in Java and hence independent of the clojure version
14:05mabeskotarak: ah, that makes sense. I'll try recompiling it with 1.2 update any require/use statements if needed.
14:07wlangstrothdoes anyone know if the precise difference between using a list and a vector with use/require is documented anywhere?
14:07stuartsierrathere is no difference
14:08stuartsierrathe implementation doesn't care
14:08somniummabes: my branch on clojars isnt aot-compiled, not sure of the forks. planning to overhaul it 1.2rc is available, but Ive heard reports of it working with 1.2 as is
14:08Borkdudestuartsierra: can you use :only within a normal (use ...)?
14:09chouserBorkdude: yes, please always use :only anytime you use 'use'
14:09wlangstrothstuartsierra: okay, thanks - I think I was getting confused with the examples
14:12lambdatronichi folks. I've got a really confusing map problem.
14:12Borkdudechouser: can you give an example of (use ...) with :only then? I never can remember the syntax
14:13lambdatronic@borkdude: (:use [foo.bar.baz :only (fun1 fun2 fun3)])
14:13chouserexactly
14:13somniumanyone know of any examples of using datalog? and does it support backtracking?
14:14chouser:as works too. I basically never use 'require' anymore, just (:use [foo.bar :as bar :only []])
14:15wlangstrothlambdatronic: confusing map problem?
14:15Borkdudelambdatronic: that is not what I meant
14:15lambdatronicSo...for some deeply mysterious (to me anyway) reason, I've got a map of vectors to structs: {[0 0] s1, [0 1] s2, ... [n m] sN}; however, I can't look up the structs by key in this map. I create a vector [0 1] (or whatever) and attempt (mymap [0 1]) and I'm just getting nils.
14:15BorkdudeI mean (use ...), not (:use ...)
14:16lambdatronicnow, I've even attempted = tests between the vector I create and the keys in the map, and they're coming up =.
14:16lambdatronicBut still...just nils.
14:16lambdatronicI'm using Clojure 1.1.0
14:16lambdatronicmaster
14:17lambdatronicAm I missing something totally obvious here?
14:18somnium,(let [m {[0 1] :a} k [0 1]] (m k))
14:18clojurebot:a
14:18stuartsierraBorkdude: (use...) is the same as (ns ... (:use ...)) except you have to quote all the symbols.
14:19lambdatronic@somnium right, I tried that, and it works from the REPL.
14:19lambdatronicso there's something going wrong inside my function that I can't suss out.
14:19somniumlambdatronic: maybe pastie the problematic section?
14:19lambdatronicwill do. just a sec.
14:21Borkdudestuartsierra: ah tnx
14:21Borkdudegtg
14:22chouseris there a better way to write #(compare (first %1) (first %2)) ?
14:23chouserI wrote a 'compare-by' to do that, but I wonder if I missed something like that in core somewhere.
14:23opqdonut(defn comparing [f] #(compare (f %1) (f %2))), and then use (comparing first)
14:23opqdonut:)
14:23chouseryeah
14:23chouser's what I did. :-)
14:23slyphonso, if i wanted to encapsulate a jms Consumer and present it as a seq of messages, how would i go about doing that?
14:23chouseractually, I used defn :-P
14:24chouser#(apply compare (map f %&)) meh
14:25slyphonooh
14:25slyphontake-while...kinda...
14:26wlangstrothchouser: by "better" do you mean faster? The first one reads fine, is what I mean
14:26slyphonchouser: any insights into how to go about using lazy-seq
14:26slyphon?
14:26chouserno, not faster. more succinct, abstracted
14:27slyphonlittle. yellow. different. clojure.
14:27chouserslyphon: One rarely needs to use lazy-seq directly.
14:27slyphonhrm
14:28mabessomnium: I just tried bumping the clojure deps to 1.2 in the congomongo project itself, and it is blowing up when I try to use it with the same error (java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V (coerce.clj:1)) This is with the latest 1.2 so something may have changed since the last time someone tried using it with 1.2
14:28slyphoni basically want to yield (.receive consumer) until it returns nil (marking the end of the sequence)
14:28mabessomnium: this is all I did: http://github.com/bmabey/congomongo/commit/67647703384239b7e13a71a026c77c307f55e64c
14:30slyphonanyone?
14:31chouser(take-while identity (repeatedly #(.receive consumer)))
14:32chouserthat'll stop on a false too
14:32slyphonhah
14:32zakwilson,(identity 4)
14:32clojurebot4
14:32slyphonexcellent, i was about to use "for"
14:32zakwilson,(identity 'foo)
14:32clojurebotfoo
14:32zakwilsonthis relies on the property that nil is treated as false, and everything that isn't nil or false is treated as true
14:33slyphonthat much i get
14:33slyphonchouser: thanks
14:34chouseryou could use (complement nil?) if you need to allow false's to get through
14:34slyphonhmm
14:34slyphonnah, anything that gets through should be a Message
14:34slyphonbut yeah
14:40somniummabes: ah, you dont need user in the project.clj. I should take that out. may need to rename some things with c.c.1.2-master though.
14:48lambdatronicalright.
14:48lambdatronicso I created a minimal test case and pasted it here: http://paste.lisp.org/display/98512
14:48lambdatronicJust load it into a repl and run (clj-span.test/test-me)
14:49lambdatronicYou should be able to see that the problem is in whatever is coming out of find-viewpath.
14:49lambdatronicThose vectors won't work as keys in the evil-map, although literal vectors do.
14:49lambdatronicAny help I can get here would be deeply appreciated. This bug has been biting me for a few days now.
14:51lambdatronicDon't suppose anyone is up for taking this case?
14:59slyphonyou know what would be cool in clojure-mode, highlighting #_ comments
14:59lambdatronic@slyphon agreed
14:59tcrayfordexplain #_ comments
15:00lambdatronicit's a reader macro that blocks the reader from reading the next form
15:00LauJensenIf you haven't heard about protocols, here's the 101: http://www.bestinclass.dk/index.php/2010/04/prototurtle-the-tale-of-the-bleeding-turtle/
15:00sexpbot"ProtoTurtle — The tale of the bleeding turtle | BEST IN CLASS"
15:00lambdatronicso #_(foo bar baz) is just entirely skipped
15:00slyphon,(#_(list :a :b) (list :c :d))
15:00clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn
15:00slyphonhrm
15:00tcrayfordI might have a look
15:00slyphon,([#_(list :a :b) (list :c :d)])
15:00clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: PersistentVector
15:01slyphonword?
15:01clojurebothttp://gist.github.com/54847
15:02slyphon,(concat (str "foo") (str "bar"))
15:02clojurebot(\f \o \o \b \a \r)
15:02slyphon,(concat #_(str "foo") (str "bar"))
15:02clojurebot(\b \a \r)
15:02tcrayfordgotcha
15:02chouser,(concat (comment (str "foo")) (str "bar"))
15:02clojurebot(\b \a \r)
15:03slyphonyeah, it doesn't highlight (comment) either
15:03slyphon:)
15:03chouser,(+ 1 2 #_(whoa horsey!) 3)
15:03clojurebot6
15:03slyphon(it does in vim-clojure)
15:03tcrayfordI have some trouble with clojure mode highlighting mutliline strings with sexps in them
15:03stuartsierraFirst cut at 1.1 backwards compatibility from 1.2 contrib to 1.1 contrib is in master now.
15:03chouser,(+ 1 2 (comment (whoa horsey!)) 3)
15:03clojurebotjava.lang.NullPointerException
15:03slyphonriiigh
15:03slyphont
15:03chouserstuartsierra: thanks for doing that. I'm sure it'll ease some pain.
15:04tcrayfordstuartsierra: is the api for lazytest final?
15:04stuartsierraI haven't added any deprecation warnings yet, interested to see if anything happens with the metadata idea on the list.
15:04stuartsierratcrayford: no
15:04tcrayfordI'm mostly concerned about how results look
15:05tcrayfordwas thinking of writing a runner for emacs (something like clojure-test-mode)
15:05stuartsierrayou mean the output of spec-report?
15:05mabesstuartsierra: so no deprecation warnings, but all c.c.1.1 will work on 1.2?
15:05stuartsierramabes: as of this moment, yes. Deprecation warnings may get added.
15:05tcrayfordyeah, I think
15:06stuartsierratcrayford: the report format is the least developed part; thus most likely to change.
15:06stuartsierratcrayford: if you were going to write a runner, I'd prefer it operate directly on the output record types, e.g. TestResultContainer
15:07stuartsierraBut even those are not API-stable right now.
15:07tcrayfordaye
15:07tcrayfordonce those are, I'll have a crack
15:07tcrayfordor if I get bored in the meantime
15:07stuartsierraI don't think it will change significantly from this point, but no promises.
15:08tcrayfordofc
15:08tcrayfordI might give it a go when these exams are over
15:09stuartsierraSomeone wrote an auditory test monitor: http://is.gd/bJ5Yb
15:09sexpbot"bgruber's lazytest-listen at master - GitHub"
15:10tcrayfordheh
15:10tcrayfordthat's pretty cool
15:10tcrayfordI like having green bar red bar type stuff (like java IDEs) though
15:11stuartsierrayeah, I thought about doing a little swing widget with that
15:12webbentcrayford: I've seen an implementation of those bars for vim.
15:12tcrayfordyou can get something similar out of emacs. I hacked clojure-test-mode to do that
15:12tcrayfordwebben: by @garybernhardt probably, the inspiration for my one
15:12webbentcrayford: maybe
15:13tcrayfordA swing widget might be interesting
15:13tcrayfordI keep on getting tempted to write a clojure ide in clojure
15:14webbenyou could update waterfront
15:14somniumso, as an experiment, I took a chunk of code that used a combination of refs and thread-local-vars, and rewrote it with a state monad.
15:14somniumAside from the moral victory of being completely stateless, they looked almost identical. The only real gain seemed to be zero bugs related to laziness under the monad.
15:15slyphonhrm, it seems like clojure.test sometimes swallows exceptions
15:15mabessomnium: fyi, this commit updates congomongo to c.c 1.2: http://github.com/bmabey/congomongo/commit/8798072f28d563b22d4d18553ab8c03e858d74bb
15:16somniummabes: cool
15:16tcrayfordsomnium: zero (apparent) bugs is a very nice thing to have no?
15:17mabesstuartsierra: do you see lazy-test and circumspec ever merging or collaborating more closely? i.e. the watcher functionality seems to be duplicated to both projects.
15:18tcrayfordiirc stu halloway is depreceating circumspec at some point soon
15:18tcrayfordin favour of lazy-test
15:18stuartsierramabes: lazytest is intended to subsume circumspec
15:18stuartsierraand eventually replace clojure.test
15:19tcrayfordwould clojure-core be tested with lazytest at that point?
15:19mabesstuartsierra: ah, ok. That makes sense.
15:19stuartsierratcrayford: maybe
15:19mabesstuartsierra: in that intention shared by stuart? (the other stuart)
15:19stuartsierramabes: yes
15:20stuartsierraBasically, we came at it from opposite directions.
15:20stuartsierraS. Halloway wrote circumspec by adding features he wanted in clojure.test.
15:20stuartsierraI started by rewriting the core internals from scratch.
15:20mabesstuartsierra: yeah. I have been trying out circumspec (I'm a big rspec user) and I like certain things about it.. the macro nature of it has gotten in the ways at times
15:21stuartsierraWith lazytest, I hope to provide convenient macros for all the common cases but open the door for constructing tests functionally as needed.
15:21stuartsierraI'm not there yet.
15:21slyphon:)
15:21slyphonstuartsierra: what are you doing talking in here then? go!
15:21stuartsierraheh
15:22slyphon;)
15:22stuartsierraseriously, I do need some feedback. What works about the current syntax, what doesn't work, ...?
15:22slyphonwhere is it?
15:22slyphonclojars?
15:22tcrayfordhttp://github.com/stuartsierra/lazytest
15:23tcrayfordI'm not sure about the `is` macro's syntax
15:23tcrayfordthe wording feels a little strange (coming from rspec anyway)
15:23stuartsierrayeah
15:23mabesstuartsierra: well.. I haven't taken too close a look at lazytest.. but from what I have seen it looks nice.
15:24stuartsierratcrayford: I tried "should" but that was too long
15:24mabesAlong those lines.. I didn't like how the word "spec" simply replaced "test"
15:24tcrayfordheh
15:24stuartsierratcrayford: and I don't like Rspec's habit of mixing language keywords in with doc strings
15:24tcrayfordmaybe the project should be called lazyspec
15:24stuartsierramabes: originally "spec" was "testing" actually
15:24mabesin rspec we originally had "specify" (still there I think but not used by many)
15:25stuartsierraI renamed it to "spec" because it was shorter. "test" is already taken in clojure.core
15:25tcrayfordif lazytest replace clojure.test, spec would get renamed to test?
15:25stuartsierraclojure.core/test has been around since 1.0, although it doesn't do much
15:26stuartsierraI thought about making the syntax even more abstract, like renaming "spec" to "T" (for test) and "is" to "A" (for assertion)
15:26mabesright, well, so the whole point of rpsec, BDD in general, was to have the tests read like an english sentence. So, if you are trying to make it like rspec I think taking an approach similar to circuspec (as far as syntax is concerned) makes more sense IMO.. Otherwise I don't see value in using BDD terminology as opposed to traditional TDD...
15:27stuartsierramabes: I'm trying to do BDD-style english sentences. The difference from Rspec or circumspec is that the macro names aren't part of the sentence.
15:28tcrayfordI liked circumspecs old munging of predicates (personally), but it was kinda klutzy
15:28stuartsierraI found that Rspec forced me to write sentences in a particular way, not necessarily the most clear.
15:28mabesBTW.. I'm very opinionated in this area, so please don't take this as criticisms against all your hard work on it
15:28stuartsierranot at all
15:29stuartsierraI want to discuss this kind of stuff, to figure out what direction I should go.
15:29somniumtcrayford: it was cool to be able to save a set of statements and have the luxury of running (seemingly) side-effecty code under any previous snapshot, with-out needing set-up/tear-down macros or doalls.
15:30tcrayfordsomnium: aye. Was this on congomongo or some other code I can have a look at?
15:30somniumtcrayford: ah, this is for a compiler experiment that has gone on for far too long, but may be out soon :/
15:31tcrayfordI'd be interested in seeing the monady stuff
15:31tcrayfordmonads really are very cool
15:32wlangstrothstuartsierra: with that naming convention, I'm sure you would get some takers. Just call it "T&A"
15:32stuartsierraha!
15:32mabesI know they aren't idomatic clojure but they seem like a tool that any FP programmer should have in their toolbox (disclaimer: I just started to learn about mondas)
15:33tcrayfordits kinda funny how simple they are
15:33tcrayfordand how powerful
15:34somniumtcrayford: the core of its here, (I found c.c.monads to be slightly too magical)
15:34somniumhttp://gist.github.com/360303
15:34tcrayfordsomnium: cheers
15:34slyphonso, it seems there's no simple way to "inherit" a defmulti stack
15:34slyphonand overload only one or two of the methods within
15:34somniumIll admit to probably trying too hard to make it look haskell :)
15:35tcrayfordheh, do notation in clojure :P
15:35tcrayfordI was more interested in the code that used the state monad, as opposed to the implementation of it :P
15:35tcrayfordbut still interesting
15:36mabesstuartsierra: WRT direction of lazy-test.. I think it would be very valuable to have the specs be allowed (encouraged?) to be written in such a way that when tacked onto the metadata of that function they provide great documentation...
15:36zakwilsonI'm uncertain about the utility of monads in most Clojure code, but one thing I'd like to see in a dynamically-typed language is a deeply-integrated maybe type.
15:36mabesstuartsierra: for example, this doco plugin for rspec allows that for ruby: http://lsegal.github.com/yard-spec-plugin/
15:36tcrayfordmabes: have you seen Ioke's documentation?
15:36mabestcrayford: Yes! that is exactly what I'm talking about
15:36stuartsierramabes: I tried that in clojure.test and nobody used it.
15:37tcrayfordmabes: so so cool for understanding the language
15:37mabestcrayford: except I don't like the word "should" in documenation
15:37tcrayfordaye
15:37tcrayforddocs are what it DOES
15:37stuartsierramabes: The problem is it bloats your source code files, especially when the tests/specs depend on external libraries that the main code doesn't need.
15:38mabesI stopped using "should" in any of my specs once I realized that they are executable documentation and should be written as such
15:38tcrayfordstuartsierra: I think he meant having it in external files, just referencing implementation files
15:39mabesstuartsierra: seems like that would be an acceptable trade-off for development. For production I don't think you would ship the extra meta-data.
15:39stuartsierraclojure.test supports that explicitly, the "with-test" macro.
15:39stuartsierraBut nobody uses it.
15:39stuartsierraI tried using it myself and found it cluttered the source too much.
15:40mabesstuartsierra: does that append the tests to the metadata?
15:40stuartsierrayes
15:41tcrayforddoes anybody here have any ide/tooling type things they'd like to see added to emacs for clojure?
15:42mabesstuartsierra: hmm.. well, the problem I am running into is that I/my team is duplicating a lot of the docstring verbage in the tests. So, it seems natural to pull the test verbage (not the entire tests) out into some metadata. Plus docstrings tend to get stale more than the test descriptions do...
15:42stuartsierratcrayford, mabes: What I'm working toward now is having specs/tests in a separate file from the main source, but defined in such a way that they attach themselves to metadata in the main source. The "describe" macro will be part of this, with significant changes.
15:42somniumIm curious, in general is (comp f g) slower than (fn [blah] (f-body (g-body blah))), or does the jit make such considerations irrelevant?
15:43stuartsierramabes: yes, I want to avoid duplication as much as possible. Of course, you don't have to include doc strings in the tests if they're redundant.
15:43tcrayfordstuartsierra: that'd add enough to get something like ioke's documentation features
15:43stuartsierraexactly
15:43chouserwould it be wrong to present a mutable work-queue as a seq?
15:43mabestcrayford, stuartsierra: yeah, all I'm after is something similar to what ioke provides
15:43chouseroh, nm, of course it's wrong.
15:44tcrayfordooh, if its on the metadata, I can get 'jump to spec for this function' kinda stuff going (and probably jump to function for this spec as well)
15:44tcrayfordprobably as a swank plugin
15:45stuartsierrayes, that would be useful, and the kind of thing I want to enable
15:46lambdatronichey folks. it's me again. I've still got the problem with map lookups not working on a collection of vector keys.
15:46tcrayfordif the metadata for the spec said which var it was attached to (if any), that'd be easy
15:46lambdatronicthe paste is here: http://paste.lisp.org/display/98512
15:47mabesstuartsierra: cool, well now that I know where the whole direction of the clojure testing libs is going I'll start experimenting with lazy-test some more and see if I can provide any useful feedback/patches
15:47lambdatronicAny chance anyone has the energy to help me with this?
15:47stuartsierralambdatronic: too much code, can you narrow it down to a specific problem?
15:47lambdatronicyes, the specific problem is the output of find-viewpath.
15:47lambdatronicjust that one function.
15:48lambdatronicit's creating a sequence of vectors ([0 0] [0 1] [0 2])
15:48stuartsierraI mean reduce the code to one example that fails
15:48lambdatronicThe example is that one, stuart. I don't mean for anyone to study the rest. It's purely the find-viewpath function (which stands alone).
15:48lambdatronicit creates this sequence of vectors, which won't work as lookup keys in the evil-map.
15:49lambdatronicthe evil-map is really just any boring map with vector pairs of integers as its keys.
15:49lambdatronicI can try to make a smaller example though.
15:49stuartsierraSo what's the problem?
15:50lambdatronictest-me is trying to illustrate it.
15:50lambdatronicIf I have a map (in this case, evil-map) which has vectors of integers as its keys.
15:50lambdatronicand I try to do a lookup in it using a literal vector, it works.
15:51lambdatronicif I try to do the lookup like so (map evil-map list-of-vecs), that also works.
15:51lambdatronicprovided a generate the list-of-vecs like so: for [i (range 3) j (range 3)] [i j])
15:51lambdatronichowever...
15:52lambdatronicwhen I try the lookup as (map evil-map list-of-vecs) when the list-of-vecs is created by find-viewpath, this fails and returns a sequence of nils.
15:52lambdatronicso my problem reduces to: why are the vectors from my find-viewpath function any different than those created with (for [i (range 3)
15:52lambdatronic j (range 3)] [i j]) ???
15:55stuartsierrahuh
15:55stuartsierraI don't know.
15:56stuartsierrathey look the same
15:56lambdatronici know. I'm trying to make a smaller test-case.
15:56lambdatronicjust a moment
16:00hoecklambdatronic: maybe it boils down to:
16:00hoeck,(.equals [1 1] [(long 1) (long 1)])
16:00clojurebotfalse
16:00lambdatronic...@hoeck: brilliant!
16:00stuartsierraI had a hunch it might be that, but I couldn't find the differences
16:01lambdatronicyeah, I was looking at it every which way too.
16:01stuartsierraah
16:01stuartsierraMath/round returns a long, not an int
16:01lambdatronicthe keys are always clojure.lang.PersistentVector both in the map and from find-viewpath.
16:01lambdatronicand they check out as =
16:01lambdatronicthat's the root of it, then I guess. So hashing on maps isn't using =, I take it.
16:02stuartsierra,(.equals 2 (Math/round 1.5))
16:02clojurebotfalse
16:02stuartsierrayes, hashing is required to use .equals instead of Clojure =
16:03lambdatronicWell, sob.
16:03stuartsierrajust coerce the result of Math/round back to Integer with "int"
16:03lambdatronicthanks, guys. you just resolved a seriously frustrating problem for me. well maybe. Let me try this fix.
16:07hoeckhad the same problem just recently while parsing a binary file, and I wondered why I didn't find any of the symbols I coded into a hashmap like (get {0xff TYPE_INT, ..} parsed-byte)
16:07cgrandbtw to "normalize" numbers there is clojure.lang.Numbers/reduce
16:07lambdatronichuh. seems like that's it after all. absolutely brilliant work guys.
16:07cgrand,(class (clojure.lang.Numbers/reduce (long 1)))
16:07clojurebotjava.lang.Integer
16:08lambdatroniceh?
16:08lambdatronic@cgrand by normalize you mean what exactly?
16:09patrkrisLauJensen: in your example where you define a macro turtle-motion, the macro has a reps parameter - where is that used? (In your latest blog post)
16:10LauJensenpatrkris: The macro just served to show the train of though which let up to the finaly iterative sotluion, I talk myself out of actually using the macro, but the reps is use in the reduce call
16:10patrkrisLauJensen: ok, good - just thought I was misunderstanding something
16:15cemerickstuartsierra: #79 actually makes 1.1/1.2 cross-compat more difficult, not less
16:15hoecklambdatronic: Numbers/reduce converts a number to its best-fitting datatype
16:15tcrayfordtechnomancy: need to test that patch on clojure 1.2 at some point soon
16:15stuartsierracemerick: why?
16:16cemerickThe various signature and fn name changes still need to be unraveled by any codebase that wants to target both, and choosing which impl to use is still easiest by eagerly loading whereever the new impls are in a try/catch.
16:16lambdatronic@hoeck will this always be Integer or Double for clojure types or will it also include BigDecimal, etc?
16:17stuartsierracemerick: I want to discourage people from trying to target both.
16:17hoecklambdatronic: e.g. a long in the range of 2^31 < x <= -2^31 to an int
16:17cemerickhrm, so roughly the same difficulty level.
16:17lambdatronicah, gotcha
16:17cemerickstuartsierra: I'm with you there, but that's not my call in a variety of projects.
16:17stuarthallowayif anybody is bored please test the recent commits to clojure and contrib
16:17cemerick(though I'll be lobbying more and more in those venues as the weeks wear on)
16:18LauJensenstuarthalloway: Thanks for doing that fantastic screencast on protocols, great job!
16:18cemerickAnyway, I'm not arguing against restoring the old namespaces, just pointing out that doing so doesn't impact 1.1/1.2 compat.
16:18stuartsierraIt's my fault: by making breaking changes in 1.2 , people started trying to support both with conditional loads.
16:18stuarthallowayLauJensen: glad you liked it
16:18stuartsierraThat is not sustainable or even sane.
16:19stuarthallowaywhile you guys are discussing 1.2 breakage I just broke contrib :-)
16:19stuartsierraheh
16:19stuartsierraoh well
16:19stuartsierraat least it wasn't me this time :)
16:19stuarthallowayand we aren't planning on turning back from it, but I would welcome review of the changes
16:19cemerickstuartsierra: Perhaps not sane, but it works. *shrug* Anyway, I don't think the breaking changes were a bad move.
16:20patrkrisstuarthalloway: will you be doing more videos on deftype, defrecord and reify?
16:20kotarakstuarthalloway: bug in reductions (f) should be (list (f)) or [(f)], mailed Rich already. The patch in Assembla is correct, however it's against contrib.
16:20wlangstrothstuarthalloway: ditto about the screencast - well done
16:20chouserstuarthalloway: my only complaint about your screencast is the title. I would have watched it sooner if I had known it was the best available description of the expression problem. :-)
16:21stuarthallowaychouser: clearly I suck at titles. BTW love the title for your book
16:21stuarthallowaykotarak: hopefully Rich is on it
16:21stuarthallowaypatrkis: dunno yet, time constraints :-)
16:22chouserheh. thanks. The machinations that finally led to it were amazingly painful.
16:22stuartsierracemerick: conditional loads should still work, by the way, as long as you try the newer version first.
16:22cemerickstuartsierra: right, yes. That's why I backed away from my "makes things harder" assertion.
16:23stuartsierraah, I see. OK.
16:23cemerickThough if someone didn't think about it too much, and eagerly loaded duck-streams, and then falling back to 1.2 stuff.... :-/
16:24stuartsierraWell, then their code will break on 1.3. :)
16:24stuartsierraBut hopefully by then we'll have succeeded in abolishing contrib altogether.
16:24cemerickright, I was suggesting that in that scenario, they might actually prefer 1.2 stuff, but not think about the fact that duck-streams might reappear in 1.2.
16:25cemerickAnyway, it's all water under the bridge now. :-)
16:25stuartsierrayep
16:25cemerickI will henceforth lobby for contrib namespaces to be timestamped monthly, so as to prevent people from thinking it's a standard library. :-P
16:25stuartsierraheh
16:25chouserstuarthalloway: you might consider putting those contrib fns back in contrib with deprecation notices, instead of the breaking changes.
16:26cemerickclojure.contrib.error-kit201026
16:26stuarthallowayconsidering, but not doing it yet
16:26stuarthallowayhow can I have the fns in with colliding names? You won't get far enough to have a deprecation notice
16:27cemerickfor those concerned about 1.2-SNAPSHOT compatibility?
16:27chouserhm.
16:27technomancycemerick: the other option is to spin libs out of contrib into independent any-clojure-version-works libraries: http://clojars.org/clj-io
16:27sexpbot"clj-io | Clojars"
16:27stuarthallowaynote today's problem applies only to seq fns promoted to core
16:27stuartsierratechnomancy: that's the way forward for sure
16:28chouserhm, for explicit :use :only cases, right. bleh.
16:28stuarthallowayeverything else will be promoted to its own namespaces
16:28cemericktechnomancy: Yeah, I think that's the side of things I came down on some months ago when there was a discussion about the charter of contrib.
16:28technomancymakes more sense for things that aren't destined for promotion clojure itself, but it neatly sidesteps a lot of pain
16:28stuarthallowayspinning things out makes it too easy to ruin provenance
16:29stuarthallowayreducing likelihood of ever being promoted to clojure
16:29cemerickThere's a lot of stuff in contrib that is barely touched, and likely never heading into core, though.
16:29stuartsierraprobably 9/10 of it
16:29cemericktechnomancy: not a fan?
16:30chouserthe likelihood of error-kit ever being promoted is already zero
16:30technomancycemerick: no, we use it and it's decent
16:30technomancycemerick: I just wish it were an independent library so it could introduce breaking changes in a 2.0 release
16:30cemerickah, right
16:31tcrayfordthe monad stuff in contrib could probably be a separate library as well
16:31technomancystuarthalloway: is there still a plan for "clojure.lib"? or has it just been boiled down to "get io and some other fns into clojure itself"?
16:31stuarthallowaytechnomancy: there are assembla tix for it
16:32stuarthallowaynothing called lib
16:32stuarthallowaythe io stuff goes to clojure.java.io
16:32stuartsierranot clojure.io?
16:32technomancyok cool; that's what I thought
16:32cemerickthat's surprising
16:32stuarthallowaystuartsierra: no, the io fns are very host-y
16:32stuartsierrathat makes sense
16:32stuarthallowaycemerick: antecedent?
16:41rhickeykeep - non-nil or truthy?
16:43rhickeyvote now or forever hold your peace
16:44chouserooh, if I vote now I can whine later?
16:44rhickeyerm, probably not
16:45stuartsierraI don't understand the question
16:45rhickeyI'm inclined towards non-nil
16:45chousermy first thought was truthy, so it's like 'if'
16:45rhickeystuartsierra: keep is like filter except instead of returning x when (pred x) is true, it returns (pred x)
16:46chouserbut non-nil means you can always use it and filter further if you *really* want to remove falses, which would surely be rare.
16:46technomancyfilter considers truthiness, so if we're going to say keep is like filter, it should probably be the same.
16:47rhickeyI think it will often be used with when, and to select e.g. settings that exist, such setting might be false
16:47chouser(filter (complement nil?) ...) vs. (filter identity ...)
16:47stuartsierraok
16:47stuartsierraI like non-nil then
16:47rhickeytechnomancy: we won;t necessarily say it is like filter if it isn't, most important to make it useful first
16:48chouserit's still like filter, just the pred changes, right?
16:48chouserI mean, the specific predicate is in question
16:48rhickeyno, the predicate is user supplied, this is about the interpretation of its result
16:48chouser(filter (complement nil?) (map f coll))
16:49chouserf is user-supplied
16:49rhickey(remove nil? (map f coll))
16:49technomancyit's also a lot like "some", but without stopping at the first
16:49rhickeybut more efficient
16:49rhickeytechnomancy: yes, exactly
16:49chouseroh, sorry -- it was take-while I was using today that had no complement.
16:50chouserso yes, I think remove nil? is best, though the docs should be a bit loud about it not being a normal truthy check.
16:50technomancyI can't think of any other core seq fns work by way of non-nil rather than truthiness. are there others?
16:51rhickeytechnomancy: I wish some worked non-nil often
16:52AWizzArdrhickey: do you have an example for that?
16:52rhickeybut when you are using keep you really care about the values, only sometimes with some
16:52technomancyas long as the docs are extra-explicit, it could work.
16:52slyphonis there a mechanism through which one can "extend" a multifn? i'm specifically trying to tweak some of the behavior of clojure.test/report
16:52slyphon(without having to cut/paste)
16:53amatosHow can I access a enum constant defined inside a Java class? I have a enum called Type inside a class called TradePeriod. I am trying to use TradePeriod.Trade.IN_SAMPLE. TradePeriod/Type/IN_SAMPLE doesn't work, neither does TradePeriod$Type/IN_SAMPLE.
16:53stuartsierraslyphon: defmethod clojure.test/report should work...
16:54LauJensenrhickey: My vote is on non-nil
16:55slyphonstuartsierra: yeah, but then there's no way to "super" ?
16:55stuartsierraslyphon: multimethods have no "super"
16:55slyphonyes, i know
16:55slyphoni mean conceptually
16:55chouserit'd be interesting to relegate 'false' to strictly interop situations, that is no core functions return it.
16:56slyphonif it were a regular var i'd bind over it
16:56slyphonhrm, that wouldn't work either
16:56slyphonblah!
16:56technomancyI'm just not used to ever thinking about the difference between false and nil.
16:57technomancythere are a lot of functions for which I don't even know which they return
16:57slyphontechnomancy: i've used it in the past to indicate "no action"
16:58slyphonwhen changing global state
16:58LauJensentechnomancy: we could unify false and nil in a new var 'faljure'
16:58replacatechnomancy: and while we're at it, let's rename true to t. Then the lisper in me will be at peace :-).
16:58slyphon"call start: nil" "you already called start on this: false"
16:59pjstadiglein doesn't reject at the var level...yet
16:59replaca(I'm only sort of kidding...)
16:59stuartsierrareplaca: the earliest pre-1.0 versions of Clojure used t/nil instead of true/false/nil
16:59technomancyLauJensen: great idea!
16:59stuartsierraBut t/nil was confusing for Java interop.
17:00replacastuartsierra: This is how McCarthy made the world and thus it was meant to be!
17:00stuartsierrahttp://globalnerdy.com/wordpress/wp-content/uploads/2007/10/john_mccarthy_successories_poster.jpg
17:00slyphonreplaca: "a foolish consistency..." though
17:01slyphonthen again, fuck knuth
17:01LauJensenslyphon: You should watch your language
17:01replacaWhat I love about it is that the symbols are so short
17:01slyphonLauJensen: sorry
17:02LauJensennp
17:02technomancyif Knuth were here, he'd wash your mouth with soap
17:03slyphontechnomancy: :D
17:03rhickeykeep - "Returns a lazy sequence of the non-nil results of (f item)"
17:03slyphoni was only being pejorative
17:03slyphonooh
17:03slyphonrhickey: that's nice
17:04stuartsierrarhickey: so 'keep' is like (remove nil? (map f coll)) ?
17:04chouser+ "Note, this means false return values from (f item) will be included."
17:04LauJensenstuartsierra: but where does 'like' start and stop ?
17:05rhickeystuartsierra: yes, but more efficient. Also coming: keep-indexed (and map-indexed)
17:05stuartsierraok
17:05LauJensenkeep - "Returns a lazy sequence of the non-nil results of (f item), no faljures"
17:06slyphonstuartsierra: if i bind over a multifn with my own version, is there a way of keeping a reference to the original so that i can call it?
17:06wlangstrothLauJensen: You should watch your languaje
17:07slyphonwow, i can't believe he called me on the f-word
17:07wlangstrothslyphon: the f-bomb is reserved for heavy debugging
17:07technomancywlangstroth: I prefer "reserved for legacy JVM interop"
17:09stuartsierraslyphon: sure, just def a reference to it
17:09stuartsierralike (def old-report clojure.test/report)
17:09slyphonmm'kay
17:09slyphonoh, that makes sense
17:10wlangstrothtechnomancy: oh man. That phrase is way worse than swearing.
17:11slyphonstuartsierra: in theory, then, if i (binding [test/report my-report]), have that old-report def, and define (defmethod my-report :default [m] (old-report m)), any method cases i don't explicitly define should fall through to the original?
17:11rhickeychouser: you have a homemade keep?
17:12rhickeyor just prepping for the push?
17:12stuartsierraslyphon: yes
17:12slyphonok, cool :)
17:12slyphonty
17:12stuartsierranp
17:12slyphonstuartsierra: that's what i kind of meant by "super"
17:16chouserrhickey: I have a homemade keep as of 15 minutes ago.
17:16rhickeychouser: chunk-aware?
17:16chouserI was staring at code that could use it, so I'm using it.
17:16chouserno.
17:16chouserlooking forward to your efficient version.
17:17wlangstrothno pressure
17:20rhickeytuned up into, added map-indexed, keep, keep-indexed
17:22AWizzArdoh good :)
17:23wlangstroththe crowd applauds
17:39hamzagents, any way to get prev item used in a map operation i need to calculate some delta values?
17:40technomancyhamza: if it's a vector you could use the brand-new map-indexed function
17:40raekyou could use partition with some step
17:41kotarak,(partition 2 1 [1 2 3 4 5 6])
17:41clojurebot((1 2) (2 3) (3 4) (4 5) (5 6))
17:41hamza,(doc map-indexed)
17:41clojurebotExcuse me?
17:41kotarakhamza: map-indexed is ca. 10 minutes old
17:44hamzahehe thanks both technomancy, kotarak. partition worked will check out map-indexed.
17:44AWizzArdhamza: http://github.com/richhickey/clojure/commit/9b78d483959e912a2ef77ff649b893b035144549
17:45AWizzArdThere you can see the doc strings.
17:53technomancyclojurebot: ticket #20
17:53clojurebot{:url http://tinyurl.com/3yrgpwo, :summary "GC Issue 16: Pretty printing", :status :new, :priority :normal, :created-on "2009-06-17T11:58:37-07:00"}
18:08The-Kennyhuh, that would be nice
18:10slyphonhrm, is it possible to start a repl from the repl?
18:10Chousukeprobably,
18:10slyphon(with-some-kind-of-state* (fn [] start-a-repl-in-here))
18:11slyphoner
18:11slyphonyeah, but with the correct syntax and stuff
18:11slyphon;)
18:12slyphonoooh
18:12slyphonrepl-in
18:17cemerickso the equivalent of indexed is (map-indexed #(vec %&) some-seq)?
18:18slyphonwell, that certainly doesn't work in slime!
18:18replacasometime folks complain about regular expression strings, other times they complain about CL format strings. But how about a mixture:
18:18replaca(GET (re-pattern (cl-format nil "/~@[~a/?~]" prefix)) (home-page prefix))
18:19slyphonand on *that* note
18:20AWizzArdcemerick: hmm yes, looks good
18:20cemerickYou probably want #(vector % %2) if you care about the cost of gathering rest args, but...
18:21replacatechnomancy|away: Yes, pprint is going into 1.2 - decided today
18:21cemerickThat's some micro-optimization there...
18:21technomancyreplaca: wow, nice.
18:22technomancyfor the greater good
18:22replacaindeed
18:24technomancywow, that really whittles down the amount of contrib usage for us.
18:24technomancyespecially if logging is spun off.
18:29The-KennyCan someone show me a correct combination of clojure, contrib and swank-clojure for use with clojure 1.2-master-SNAPSHOT?
18:30The-KennyMy current project.clj fails with java.lang.IllegalStateException: Var swank.swank/start-server is unbound (using M-x swank-clojure-project)
18:31The-Kennyhttp://gist.github.com/382829 That's my project.clj
18:35technomancyThe-Kenny: drop "-master" from contrib
18:36The-Kennytechnomancy: I think I've tried that, but I'll try again
18:36The-KennyNo, not working :(
18:38technomancyweird; works for me
18:39The-KennyWas there some important change to swank-clojure.el? Maybe mine is outdated
18:40technomancyrecent changes have been mostly about edge-cases
18:40technomancycould try lein swank tho
18:45The-KennyFails too :( "group-by already refers to bla"
18:45The-KennyLooks like someone out there don't want me to use clojure 1.2
18:46technomancyoh... that's new breakage as of like an hour ago; cripes.
18:47The-Kennyhm :(
18:48Chousukeerrors like these are just teaching people to avoid :use :P
18:49lancepantzanyone know if read-properties can be used to load a properties file as a classpath resource instead of a path?
19:17AWizzArd,(doc add-classpath)
19:17clojurebot"([url]); DEPRECATED Adds the url (String or URL object) to the classpath per URLClassLoader.addURL"
19:17livingstonhaving your build tool forbid names doesn't seem like the greatest of ideas? unless there is a technical reason this is just kinda silly
19:27technomancywhat's wrong with silly?
19:27slyphontechnomancy: stop that! it's silly!
19:30rhudsonIs Leiningen really going to abjure -jure?
19:32lancepantzhahahah, i thought he was just kidding about that
19:46stuarthallowaytechnomancy: collision with group-by is killing swank
19:46stuarthallowayare the semantics the same? can it be simply removed from swank.util?
19:46technomancystuarthalloway: I am one step (about 15 minutes) ahead of you. =)
19:47stuarthallowayawesome!
19:47technomancymy fix loads it conditionally; the semantics are the same (just no transients in swank's version)
19:47technomancyor rather, the only difference in semantics was an optional argument that was only used in the test suite
19:47technomancy(don't look at me; I didn't write it) =)
19:47stuarthallowayis the a leiningen way to say "give me the snapshot as of date d" so people can back off the edge?
19:48stuarthalloways/the/there
19:48technomancyyeah, you just replace SNAPSHOT with the timestamp of the build
19:48technomancyit should probably be better-documented though
19:49slyphontechnomancy: do you know if it's possible, or if someone has written, something like repl-ln that works over swank?
19:49slyphonso you can spawn a sub-repl in a certain context
19:49stuarthallowaywe need to encourage people to track to a timestamp, or at least make sure they know how
19:50technomancyslyphon: the swank.core/break debug repl is basically that; you can ask hugod how that works
19:50stuarthallowaya doc fix plus an email or blog post on "paddling back from the edge" would be most welcom
19:50slyphontechnomancy: w00t!
19:50technomancystuarthalloway: will definitely include that in the readme for the next lein release
19:51liebketechnomancy: what would be an example using the timestamp for the previous snapshot of Clojure?
19:52technomancyliebke: at work we're using version "1.2.0-master-20100426.160114-46"
19:52liebkeI just emailed the group about the swank problem, I definitely need to go back a snapshot
19:52liebkethanks!
19:52technomancyit's a little more complicated than timestamps I guess; it includes the hudson build number
19:53liebkewhat about clojure-contrib?
19:53liebkeis it the same?
19:54technomancyliebke: for contrib: "1.2.0-20100427.200505-82"
19:54liebkeexcellent, thanks
19:55technomancyposted to the mailing list with the magic numbers
19:56slyphontechnomancy: for the record: C
19:57slyphonC
19:57slyphonJ
19:57slyphonGAH
19:57slyphonhttp://hugoduncan.org/post/2010/swank_clojure_gets_a_break_with_the_local_environment.xhtml
19:57sexpbot"Hugo Duncan : Swank Clojure gets a Break with the Local Environment"
19:57slyphonstupid paste
19:58technomancyoh, I thought you wanted details on how it's implemented
19:59slyphontechnomancy: hah, no, i just want the feature :)
19:59technomancyoh yeah, it's the best
19:59slyphon:D
19:59slyphoni've been *wanting* that for a while
20:00slyphonesp. since i have a whole ton of (with-blah-context* ) methods
20:28unlinkHas anyone released a reader for Clojure that implements sweet expressions?
20:52cemerickunlink: oh, I'd hope not
20:53somniumit looks like even the PLT mailing list was slightly hostile to them :p, not sure how you'd implement { ~infix } in clojure either
20:53somnium{{ x + y + z }} is kinda salty
20:55cemerickit seems like a complete waste to me *shrug*
20:56_atoI think there was one a long time ago, sweetjure or something like that, but it didn't get much interest and now seems to have disppeared
20:56cemerickI think the influx of people willing to use clojure from java-land is at least encroaching on voiding their premise
20:56somniumit feels like a half-measure to me, if you really want syntax, why not write a preprocessor and feed it to the reader
20:58somniumI like the syntax of haskell and ocaml, but template haskell and camlp4 are terrifying
20:59unlinksomnium: the infix part is of dubious utility
21:00somniumhttp://github.com/apatil/pleajure
21:03_atoah yep, that's the one I was thinking of
21:04currivanQuestion about type hints: I can use #^Lbyte in a defn binding but I can't get it to work in let (error) or binding (still have reflection warning). Anyone know why?
21:18slyphonanyone use swank.core/break ?
21:30tomojis a quick recovery from what happened to 1.2 impossible in general?
21:58_brian2_noob question, why the first item returned from lazy seq by (first.. ) is not the same as I see when I use doseq? : http://clojure.pastebin.com/SasLCeBF
22:00slyphondoseq doesn't keep the head of the seq?
22:01slyphonhrm
22:01_brian2_don't know , thats what I get
22:01slyphondepends on what (hn-body) is
22:02_brian2_all lazy seq's aren't equal?
22:02slyphonnope
22:02slyphona lazy-seq could be bytes coming out of a socket
22:03_brian2_ok
22:03_brian2_so what (first .. considers to be first is not what doseq does
22:05slyphonwell
22:05slyphonactually, i'm gonna stop talking, because i'm kinda new to this
22:05slyphon;)
22:05_brian2_ok, lol
22:06tomoj_brian2_: I think what you want is (doseq [v (hn-body)] ...)
22:06_brian2_ok
22:07_brian2_thnks
22:07tomojthe issue you're seeing is interesting
22:07tomojwant to know why you see that output?
22:07_brian2_yes
22:07tomojdo you know about destructuring yet?
22:07_brian2_a bit
22:08tomoj,(let [[a b c] (iterate inc 1)] [a b c])
22:08clojurebot[1 2 3]
22:08tomojif you have a vector in a binding form, this means that you expect a seq to be bound to it, and the symbols you put into the vector will be bound to elements in that seq
22:09_brian2_i'm gonna copy this and think about it
22:09tomoj,(let [[x] "foo"] x)
22:09clojurebot\f
22:09tomoj,(let [[x y z] "foo"] [x y z])
22:09clojurebot[\f \o \o]
22:09tomojthe repeated newlines you're seeing is because each time through the doseq, v is bound to the first character of each string
22:10_brian2_hmm
22:10tomojand they all start with newlines
22:10_brian2_ok, and then [space]
22:10tomoj,(doseq [x ["foo" "bar" "baz"]] (println x))
22:10clojurebotfoo bar baz
22:11slyphonhrm
22:12tomoj,(doseq [[x y z] ["foo" "bar" "baz"]] (println [x y z]))
22:12clojurebot[f o o] [b a r] [b a z]
22:12tomoj,(for [[x] ["foo" "bar" "baz"]] x)
22:12clojurebot(\f \b \b)
22:12_brian2_actually I would have thought one variable "v", then it would not destructure, but obviousl I am wrong
22:13tomojwith just the symbol v, it doesn't destructure
22:13tomojbut when you have a vector or map, you get destructuring
22:13_brian2_but what about my output
22:13tomojyou have a vector
22:13tomojyou've got (doseq [[v] (hn-body)] (prn v))
22:13tomojwhat you want is (doseq [v (hn-body)] (prn v)), no vector in the binding form
22:14_brian2_ahh
22:14tomojwhen the vector has fewer elements in it than the number of elements in the thing bound to it, the rest are just ignored
22:14tomojso v is bound to the first element of each string
22:14tomojand the seq for a string is a seq of characters
22:14_brian2_hmm, ok
22:15tomoj,(seq "\n blah")
22:15clojurebot(\newline \space \b \l \a \h)
22:15_brian2_yes ok, that clarifys it much for me
22:15_brian2_clarify
22:16_brian2_thanks!
22:18_brian2_actually I think I was confused because these [] is also used as arguments for functions.
22:18tomojright
22:18_brian2_but not when calling
22:19tomojI guess this is somewhat like learning the syntax of clojure :(
22:19tomoj,(doc doseq)
22:19clojurebot"([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."
22:19_brian2_yes
22:19tomojat least the syntax is consistent
22:20tomojlet, for, doseq, and others all use the same syntax here
22:20_brian2_what do they mean b "head of sequence" ?
22:20_brian2_the first element
22:20_brian2_?
22:20tomojyeah, the head is the first element
22:20tomojwhat that means is that doseq will allow that element to be garbage collected
22:21_brian2_hmm
22:21tomojif you write code which keeps a reference to the first element of a lazy seq, it "holds the head", and this means that the entire seq will be stored in memory
22:21_brian2_ok
22:21tomojif you don't hold the head, you can traverse an infinite seq as long as you like without running out of memory
22:21_brian2_yes, hmm important point
22:21tomojso for instance a clojure program could (doseq [i (iterate inc 0)] (println i))
22:22tomojand it would just sit there printing out the natural numbers practically forever
22:22_brian2_yes, this is very important to my application
22:24_brian2_it seems only particular cases you would not want to use it
22:33chouseraaargh!
22:33slyphonchouser: sup?
22:33slyphonchouser: remember: *don't* fry bacon naked
22:33chouserI've been getting bit 3 evenings in a row now by (I think) the same problem, and it's something I *knew* but was somehow overlooking
22:34slyphondoh
22:34chouserthe comparator you give to sorted-set-by controls not just order, but the set's concept of uniqueness.
22:34slyphonah
22:34slyphoninteresting
22:35chouser,(sorted-set-by #(compare (:a %1) (:a %2)) {:a 2 :b 1} {:a 1 :b 2} {:a 2 :c 3})
22:35clojurebot#{{:a 1, :b 2} {:a 2, :b 1}}
22:35chouserI mean, it has to. It's the only thing that makes sense from the set's perspective.
22:36chouserI probably made fun of the person who last complained about it to me.
22:36slyphon:)
22:36chouser,(sorted-set-by #(compare [(:a %1) %1] [(:a %2) %2]) {:a 2 :b 1} {:a 1 :b 2} {:a 2 :c 3})
22:36clojurebotjava.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.lang.Comparable
22:37slyphonthat's different than ruby & python
22:37chouserhm, interesting.
22:38slyphonheh, that's like today, i was going *nuts* trying to figure out some weird JMS behavior, turns out you have to explicitly call "start" on your connectoin
22:38slyphonconnection
22:38slyphon(which i *knew*, dammit)
22:38rhudson,(sorted-set-by #(first [0 %1 %2]) :a :b :c :d :e)
22:38clojurebot#{:a}
22:39chouser,(sorted-set-by #(compare [(:a %1) 0] [(:a %2) 1]) {:a 2 :b 1} {:a 1 :b 2} {:a 2 :c 3})
22:39clojurebot#{{:a 1, :b 2} {:a 2, :c 3} {:a 2, :b 1}}
22:39chouserhm...
22:39chouser,(sorted-set-by #(compare [(:a %1) 0] [(:a %2) 1]) {:a 2 :b 1} {:a 1 :b 2} {:a 2 :c 3} {:a 2 :c 3})
22:39clojurebot#{{:a 1, :b 2} {:a 2, :c 3} {:a 2, :c 3} {:a 2, :b 1}}
22:40chouserfascinating. this might work just fine in my case.
22:40chouserI don't need the set for removing duplicates
22:40slyphonis a lazy-seq kind of like a monad if you're wrapping something like a socket?
22:41slyphoni.e. representing a stream of IO as a seq of values
22:42slyphoni hear people discuss "monadic IO" but i haven't had the time to learn haskell yet
22:44tomojI don't see the lazy-seq <=> monad connection there
22:44tomojI'd think in haskell you'd have an IO [a] to represent the stream of values coming out of a socket
22:44slyphonhow is that different from a seq?
22:45tomoja seq is just an [a]
22:45slyphonIO is the class, no?
22:46tomojif you have an IO [a], you can get from it an [a]
22:46tomojthen you just process the [a] like you would a lazy-seq
22:47tomojthe lazy seq actually has the mechanisms for doing more IO contained inside it
22:47tomojI am still confused by haskell so don't trust me
22:47slyphonhahahaha
22:48chouserha! ok, don't do my always-unique thing above
22:48chouserif your comparator never returns 0, you can never find or remove anything in your set.
22:48chouserduh
22:50rhudsonSo the comparator for a sorted set has to define a total ordering, sounds like
23:01rhudsonchouser: are you trying to define a priority queue?
23:05chouseryessir
23:05chouserit was working fine until I moved from vectors to records
23:15chouserI'm going crazy
23:15chouser((.comparator wd) (first wd) (first wd)) ;=> 0
23:16chouser(wd (first wd)) ;=> nil
23:16chouserI don't see how a set can do that.
23:16unlinkWhat is the idiomatic way to write to stderr?
23:17slyphon(binding [*out* *err*] ...)
23:17slyphoni think
23:17unlink(binding [*out* *err*] (println blah)) ?
23:17unlinkoh, :(
23:17slyphonsomeone will correct me, though
23:17slyphonwell
23:17slyphonyou can wrap that in a macro
23:17unlinkI mean I understand
23:17slyphonyeah, i also though that was kind of "meh"
23:18rhickeychouser: what is wd?
23:18rhudsonchouser: what's wd?
23:18chousersorted-set-by
23:18chouserI just spotted it
23:19chousermy sort-by fn is (defn work-order [a b] (cond (= a b) 0 (< (:cost-est a) (:cost-est b)) -1 :else 1))
23:19chouserthe problem is that if a bunch of items have the same :cost-est, the two equal ones might not end up next to each other
23:20chouserso simply guaranteeing that it returns 0 for equal items isn't sufficient. it must *always* put things in the same order.
23:22rhudsonsounds right
23:23chouserso to get the behaviour I want I have to take into account every field of the record
23:24chouserI mean, I have to actually *order* on every field, not just check equality.
23:24hiredmanor order on :cost-est then hashcode
23:24chouserperhaps I'd be better off implementing Comparable in the record itself
23:24rhudsonIf you had a serial # / index on each record, you could sort by [(:cost x) (:serial x)]
23:25chouserhiredman: I thought of that, but I could get incorrect 0's if the hashcodes happend to be different
23:25chouserand items would mysteriously disappear
23:25hiredmanchouser: uh, for immutable objects?
23:26hiredmanoh
23:26hiredmanright
23:26hiredmansorted-sets
23:26hiredmanwhat a pain
23:27chouserugh. Actually, I'd be better off just using a vector
23:27hiredman:)
23:27rhudsonUnless one of the elments in the vector was a map, then you'd have the same incomparability problem
23:28hiredmanhuh?
23:29rhudsonMaps aren't Comparable
23:29chouserright. it's not. I have a number and a 2-element vector of numbers.
23:30unlinkIs there any datetime convenience code for clojure
23:30unlinkmy use case is printing out a string of the form "2010-04-29 03:30:44.950063"
23:31hiredmanclojurebot: javadoc java.text.DateFormater
23:31hiredmannuts
23:31hiredmanwhat is that thing called
23:31unlinkSimpleDateFormatter?
23:32unlink* SimpleDateFormat
23:32hiredmansure
23:32hiredmanthat'll do
23:32rhudsonThat's what I always use
23:32unlinkOK. I'm just asking because that is a horrible class O:-)
23:32hiredmanright
23:32hiredmanwell
23:32hiredmanright
23:33rhudsonformat's something like "yyyy-MM-dd hh:mm:ss.SSS"
23:35replacaunlink: my advice is skip java dates and pick up jodatime. It's still pretty nasty but at least it makes sense
23:37unlinkthis is inspiring
23:38unlinkin a bad way, I mean
23:38slyphonunlink: it's java, it's not supposed to be inspiring
23:38slyphonit's supposed to be hackable by your replacement who you will undoubtedly train
23:38unlinkas in, inspiring me to write something for clojure
23:38slyphonhah
23:40chouserI think there's a clojure wrapper around jodatime somewhere.
23:40slyphonyou know, come to think, i think the problem with most date/time libs is that time is a *terrible* abstraction
23:42unlinkwell it's a nasty concept
23:42unlinkand calendars are inherently tricky
23:42slyphoneyah
23:43rhudsonAt least there's options beyond "Wed Apr 28 23:42:28 EDT 2010" these days -- that's gotta be the worst format in the world
23:43slyphon"Time is of an affliction" - Frank Zappa
23:44rhudson"Without time, everything would happen at once. Without space, everything would happen to me"
23:44replacachouser: brad cross and technomancy did something for incanter, but even they don't like it. Someone's working on something new over there. I have high hopes