#clojure logs

2010-11-30

00:09RaynesKirinDave: Any particular reason for not mentioning Practical Clojure.
00:09Rayness/Clojure./Clojure?/
00:09sexpbot<Raynes> KirinDave: Any particular reason for not mentioning Practical Clojure?
00:09KirinDaveRaynes: Haven't ready it yet
00:10RaynesNeither have I. Still think I'd recommend it, after hearing stuff like "It's like Programming Clojure for Clojure 1.2"
00:12RaynesNot as much recommend it as point it out. Can't really give a solid recommendation without having read it.
00:12RaynesI was going to buy a copy at the Conj, but didn't get around to it.
00:58ossarehzippers are fkin cool
00:59ossarehjust wrote a fn that takes a map of errors and zips across a hiccup vector set and inserts errors in the right place
01:57replacahiredman: are you here?
02:03hiredmanreplaca: yes
02:32LauJensenMorning people
02:35zkimAnybody know why alter-var-root is preferred over binding for mocking? My google-fu is failing me on this.
02:54LauJensenI didnt know that it was ?
03:01zkimLauJensen: http://twoguysarguing.wordpress.com/2010/10/25/the-conj/ search for alter-var-root, I've heard this a couple of times but can't seem to find an explanation
03:02LauJensenAh. I think that can only be because of the threading issues related to binding. Which I believe are solved in the lastest git code actually
03:03zkimah cool, thanks lau
03:03LauJensenuser> (def x 5)
03:03LauJensen#'user/x
03:03LauJensenuser> (binding [x 10] (pmap #(+ % x) (range 10)))
03:03LauJensen(5 6 7 8 9 10 11 12 13 14)
03:03LauJensen
03:34LauJensenWhich S3 libs to we have ?
04:21cpfrare atoms the correct way to implement cyclical data structures?
04:55drdocpfr: What do you mean?
04:55cpfrdrdo, nevermind I think I got a handle on this for now
05:36djpowellurgh - tomcat's classloader caches every resource forever with no option to reload
05:38djpowellthings like this give 'caching' a bad name. if it isn't referentially transparent, it isn't caching, it is in-built staleness.
05:38djpowellend-rant
05:40djpowellit is clojure-related tho. I'm trying to have some clojure files get reloaded if they change, so this behaviour makes all the clojure.lang.RT/load stuff not work for me
05:47lpetitcpfr: did you solve your problem ?
05:48cpfrlpetit, I won't be sure until I evaluate my code in the cold clarity of tomorrow morning ;)
05:49djpowellIs it safe to use Compiler.load() from Java? Does all the initialisation happen?
05:50lpetitcpfr: there's always some tension between fp and cyclical data structures, the risk to conflate identity and value by (ab)using reference types ...
05:51cpfrlpetit, I am using atoms, and vectors of references
05:52cpfrthen using identity to check if I have encountered the item before
05:53cpfridentity is for p==q, value is for *p==*q ... to borrow C parlance
05:57lpetitcpfr: hm, I was not talking about object identity, but with "state" semantics, as defined by Rich. "identity" = "set of values over time", "value"=immutable thing, "state" = snapshot of an identity at some point in time.
05:57cpfrah yes, I remember that talk
06:11fliebelmorning
06:19mduerksenfliebel: morning. i checked yesterday, and most functions with their name in the docstring have it in the first sentence (before the first occurence of '.').
06:20fliebelmduerksen: What is your conclusion from this?
06:22mduerkseni'm not sure. i certainly would guess that these cases (about 100) should not be masked. given that about 140 functions in total have their name in the doc, and there were about 30 functions with the (<name pattern, there is a chance that these sets are mostly distinct. in that case, the pattern should do well
06:23mduerksenbut i haven't checked if the groups mix
06:23fliebelmduerksen: putting both in a set should make that a one-line I believe.
06:24fliebelBut you're saying replacing (name is the best bet?
06:26mduerksenwith the given data, yes. but if you want to have more certainty, it would help to check which function have their name in it *after* the first dot
06:26mduerksenwith or without the paren, i mean
06:27fliebelI see.
06:44fliebelI'm using some old compojure code, but it seems the html code was removed from compojure, where do I get it?
06:45raekfliebel: it was split off into the 'hiccup' project
06:45fliebelah, will try...
06:45raekmuch of the middleware has been merged into ring
06:49fliebelraek: So redirect-to and run-server are to found in ring?
06:50raekyes
06:50raekhttp://mmcgrana.github.com/ring/ <-- docs
06:51raekring.util.response/redirect and ring.adapter.jetty/run-jetty
06:52fliebelraek: Awesome, thanks. Now, off to clojars to find their versions and such...
06:53raek[ring/ring-core "0.3.5"] and [ring/ring-jetty-adapter "0.3.5"]
06:53fliebelyou're fast… But I must say clojars does a bad job at searching.
06:53raekor [ring "0.3.5"] for the big bunch
06:54raekI usually look in the project.clj file at github
06:54raekclojars.org/<project-name> gives accurate info most of the time
06:54raekbut not always
06:54fliebelraek: Smart, I hadn;t thought of that. Do you bother to look at the correct branch, or just assume trunk is the right one?
06:55raekthe later I suppose :)
06:57raekhttps://github.com/raek/lcug-guestbook <-- guestbook example web application written for one of the Linköping clojure meetings
06:57raekwritten with Moustache (the other routing lib) and Enlive (alternative to hiccup), though...
07:04fliebelWhy is this an unsupported binding form? (defroutes reddit (GET "/" (reddit-home session))) He's doing with-session later. Ugh, I hoped this was a clone-and-run job.
07:04raekI think the defroutes syntax has changed a little
07:04fliebelouch :(
07:04raekit used to have magic variables (request, and params, IIRC)
07:05raekso you need to att a binding vector somewhere
07:05fliebelso more like (GET  "/" [session] (reddit-home session))?
07:05raek(GET "/" [] (reddit-home session)))
07:05fliebelokay, so the session is still magic
07:05raekhttps://github.com/weavejester/compojure/wiki/Routes-In-Detail
07:06raekoh, compojure has already passed 0.5
07:06raekI haven't used it myself since the 0.3 days
07:07fliebelwith-session is nowhere to be seen.
07:07raekhttp://mmcgrana.github.com/ring/middleware.session-api.html
07:08raekmiddleware seems to use the wrap-_____ naming convention nowadays
07:08fliebelright…
07:10fliebelSo, :session is now on the request, so I should use wrap-session and then [session] in the route?
07:11raekI think the binding vector is for path segments
07:11raekoh wait
07:11raekseems like you can replace (GET "/" [] ...) with (GET "/" {:keys [session]} ...)
07:12fliebel"This can either be a vector of parameters you want, or a full Clojure destructuring form." so a vector of just session wil work as well, right?
07:13raeklooks like [a b c] is a shorthand for {{:keys [a b c]} :params}
07:13raekbut I dunno...
07:13raekthis is one of the reasons I started using Moustache
07:14raekMoustache is very regular and non-magic
07:14fliebelraek: I can't agree more.
07:16raekI'm sure compojure is great nowadays, but I learned what know about it before The Great Compojure Turbulence
07:17raekone style I've come to use myself is to pick out the interesting parts of the request map with ordinary clojure destructuring in a handler function
07:17raekand only let the routing choose which handler function that gets called
07:18fliebelI see...
07:19fliebelWhere can I find more about the destructuring syntax?
07:19raekof clojure?
07:20raekI think its main documentation is at the docs for let: http://clojure.org/special_forms#Special Forms--(let [bindings* ] exprs*)
07:22raek(defn my-handler [{{:keys [a b c], :as params} :params, session :session, :as request}] ...)
07:22raekit's probably more readable to split up that into multiple steps i a let...
07:23fliebelhuh, that is magic...
07:23raek*excplicit* magic... :-)
07:25raekhrm, replace {:keys [a b c], :as params} with {:strs [a b c], :as params}...
07:25fliebelSo can I write [{:keys [id]} session {:keys [title turl]} params]?
07:26raekalmost
07:27raek,(let [{:keys [id]} :session, {:strs [a b], :as params} :params} {:session {:id 0}, :params {"a" 1, "b" 2}}] [id a b params])
07:27clojurebotUnmatched delimiter: }
07:27raek,(let [{:keys [id]} :session, {:strs [a b], :as params} :params}} {:session {:id 0}, :params {"a" 1, "b" 2}}] [id a b params])
07:27clojurebotUnmatched delimiter: }
07:28fliebelActually I want the whole of session and parts of params, but using a vector, compojure gives me their value in params?
07:28raekI now next to nothing about Compojure's binding syntax sugar...
07:29raekbut from what I can tell from https://github.com/weavejester/compojure/wiki/Routes-In-Detail
07:29raekit seems so
07:29raekit hints that [id] is the same as {{id "id"} :params}
07:30fliebelstrange thing to do.
07:31raek,(let [{{:keys [id], :as session} :session, {:strs [a b], :as params} :params} {:session {:id 0}, :params {"a" 1, "b" 2}}] [id a b session params])
07:31clojurebot[0 1 2 {:id 0} {"a" 1, "b" 2}]
07:33fliebeljust {session :session} :session will give me session as well, right?
07:34raeksession :session
07:34raekor
07:34raek:keys [session]
07:34fliebelokay, I think I know enough now :)
07:34fliebelLets see
07:35raekif the key is a keyword, the second thing is what you lookup in the map
07:35raek*if the key is a symbol
07:36raek...and that symbol is bound to the value of looking up the second thing in the map
07:36fliebelright, but compojure params are keywords, right?
07:36raekring's wrap-params gives them as strings
07:39fliebeloh, so I need "id" and all :(
07:41raek{id "id"} or {:strs [id]}
07:42raek(:keys and :strs is a short form for "I want to bind these symbols to the value associated with the keyword/string with the same name")
07:42fliebelright
07:50AWizzArdHi rhickey, good morning.
08:10fliebelThere we are, a version of cloneit that work. https://github.com/pepijndevos/cloneit
08:10fliebelLauJensen: ping
08:21@rhickeyhas anyone tried *unchecked-math* yet?
08:22djpowelli had a quick go - but I was a bit confused about how it interacts with the compiler
08:22djpowellyou can't binding *unchecked-math* can you?
08:22@rhickeydjpowell: no, it's like in-ns
08:23@rhickeyit is looked at by the compiler (and some macros) when compiling, not at runtime
08:23djpowellcould it get promoted to a ns macro flag? in theory
08:24@rhickeydjpowell: it is not a property of the ns
08:25djpowellso, you set! it, define a funciton, then set! it back to off (?)
08:25@rhickeyyou could turn it on before a few defns and off afterwards
08:26djpowellit seems useful anyway, ignoring the performance aspects - particularly for doing stuff with bytes, which is pretty horrible without it
08:27@rhickeybut putting a single set! true at the top of the file will cover you
08:27djpowellwill it automatically revert to false at the end of the file?
08:28@rhickeyyes, it is pushed on file load/compile and popped after
08:31djpowellbtw: are those cheap LazyPersistentVector things a big performance win?
08:33djpowellI was looking at finger-trees, and the profiler seemed to suggest a lot of time was spent making vectors, and as they are from concatting odd bits of vectors together, they fail to take the fast-path through LazyPersistentVector. (not sure I trust the profiler, haven't investigated in detail yet)
08:33LauJensenfliebel: pong
08:33fliebelLauJensen: I made that redit clone of yours work with more recent versions of everything.
08:34LauJensenI didnt work?
08:34fliebelno, compojure has changed quite a lot
08:35LauJensenfliebel: If you left the dependencies alone, it worked right?
08:35fliebelDidn't try very hard. Cake said something weird and then I changed the version numbers.
08:36LauJensenfliebel: Looks OK - If I can find the time I'll do a clojureql/moustache/enlive version. Should be quite nice
08:36fliebelawesome :)
08:51dnolen,(meta (cons 'a (with-meta '() {:type ::foo})))
08:51clojurebotnil
08:52dnolenhmm so metadata isn't preserved with cons?
08:52raek,(meta (rest (cons 'a (with-meta '() {:type ::foo}))))
08:52clojurebot{:type :sandbox/foo}
08:53raek,(meta (conj 'a (with-meta '() {:type ::foo})))
08:53clojurebotjava.lang.ClassCastException: clojure.lang.Symbol cannot be cast to clojure.lang.IPersistentCollection
08:53raek,(meta (conj (with-meta '() {:type ::foo}) 'a))
08:53clojurebot{:type :sandbox/foo}
08:53raekgood question
08:53chouser,(class (conj '() 'a))
08:53clojurebotclojure.lang.PersistentList
08:54chouser,(class (cons 'a '()))
08:54clojurebotclojure.lang.Cons
08:54chouserSo metadata isn't propagated with Cons.
08:55pdk(doc conj)
08:55clojurebot"([coll x] [coll x & xs]); conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type."
09:00fogus`rhickey: Should *assert* act similarly?
09:01@rhickeyfogus`: assert begs for higher-level debug build control, I don't want set! *assert*'s in code
09:02@rhickeyit should instead follow a parameter for the build
09:02tonydark00Ciao
09:03@rhickeywe never got a good proposal for debug builds, but perhaps now as we're getting deeper into maven-land...
09:04lrennrhickey: what is your Go rank? Inquiring minds want to know :)
09:04fogus`Maven-land sounds so ominous.
09:05@rhickeyominous is the least of it
09:05chouserSpeak, friend, and enter.
09:05fogus`In the heart of Maven-land lies Mount Pom!
09:08@rhickeylrenn: dunno, not very high, last ranked tournament was when I was first learning - AGA 7k then, played at up to 2k-ish at the NYC club (years ago), slipping ever since due to lack of playing :(
09:08lrennrhickey: I know the feeling. #clojure should move off of irc and onto KGS or IGS :)
09:10dnolenrhickey: is the lack of metadata on the result returned by cons a bug? I'm looking at the code of Cons.java, seems like it should work.
09:16charliekiloClojureQL Q: Does anyone know if LIKE is supported by current version (I couldn't find anything in the code)? ... and if it is not, if there is a reason and what the reason is.
09:20LauJensencharliekilo: like is defined in predicates.clj
09:21charliekiloLauJensen: Dooh ... there is it! Sorry about that!
09:22LauJensenno worries :) You might also stop and wonder about the simplicity of its implementation - If it hadn't been there, it would be trivial for you to put it there
09:29lenwhi all
09:30lenwusing contrib.seq
09:30lenwis this right
09:30lenw(contains? [1] 1) returns false
09:31LauJensenyes
09:31lenwbut (contains? [1 2 3] 1) is true ?
09:31LauJensen,(doc contains?)
09:31clojurebot"([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric k...
09:32LauJensenJust like the doc string says
09:32LauJensen&(contains? {:one 1 :two 2} :two)
09:32sexpbot⟹ true
09:32lenwmy pardon its the key not the value
09:32dnolen,(some? #{1} [1 2 3])
09:32clojurebotjava.lang.Exception: Unable to resolve symbol: some? in this context
09:32charliekiloLauJensen: a follow-up question, there is no '!like' (-> name NOT LIKE 'test%')? the recommended way is the use of "restrict-not' ... how far am I off (be honest ;)?
09:32dnolen,(some #{1} [1 2 3])
09:32clojurebot1
09:32dnolen,(some #{9} [1 2 3])
09:32clojurebotnil
09:32lenwyes thats it
09:33LauJensencharliekilo: right on. But defining !like wouldn't be a bad idea
09:33Chousukemake it not-like :P
09:33LauJensenmm
09:34ChousukeI don't thikn ! is idiomatic for "not"
09:34lpetit,(doc not=)
09:34clojurebot"([x] [x y] [x y & more]); Same as (not (= obj1 obj2))"
09:35LauJensenits not. We only use it for !=
09:35lpetit,(doc not-nil)
09:35clojurebotIt's greek to me.
09:35lpetitwoop
09:35lpetitHello all !
09:35lpetitLauJensen: hello bro :;)
09:35LauJensenlpetit: yo buddy :)
09:47lpetitNew ccw REPL integration is over. It's now fully functional, some (scarce) regressions have been tackled. Beta release by thursday, probably.
09:49LauJensenlpetit: great! Hows the OSGi coming along?
09:51lpetitLaujensen: that's one of the additional features I'd like to add as a bonus before releasing. aav has been working on adding a clojure.osgi/with-bundle* function which allows to evaluate code in the (classpath) context of the bundle whose name is passed in first argument => this will really (finally !) let me have proper interactive env. for ccw dev !
09:51LauJensenAnd thats close now?
09:53lpetitLaujensen: well, the with-bundle* feature comes with a bunch of additional ones in clojure.osgi which lead to some regressions, still fighting them
09:53LauJensenOk. Looking forward to seeing the next release :)
10:11kjeldahlAny Incanter users on? If I just type the name of a dataset in repl, it shows me a list of vectors, the first is the column header and then the rows, but if I iterate over it, it shows me two vectors, one with column names, and one with rows inside.
10:11kjeldahlIs there a special "show" method being called by default if I just tell it to show itself through repl?
10:18chouserkjeldahl: I don't know Incanter, but normal REPLs use the print-method multimethod to print things
10:19chouserso it could be that Incanter datasets have their own (defmethod print-method ...) to print specially.
10:20raekkjeldahl: how do you iterate over it?
11:40cemerickOT, but this is remarkably helpful, especially for someone like me that doesn't know IEEE bit layouts by heart: http://download.oracle.com/javase/6/docs/api/java/lang/Math.html#nextUp(double)
11:41cemerickI vaguely remember someone here some months back mostly convincing me that the above wouldn't be generally useful; any mathy folk have opinions of such an operation?
11:43fogus`nunjudd in Action: http://blog.fogus.me/2010/11/30/take-6-justin-balthrop/
11:44fogus`s/nunjudd/ninjudd/
11:44sexpbot<fogus> ninjudd in Action: http://blog.fogus.me/2010/11/30/take-6-justin-balthrop/
11:45zmyrgelhi, can the clojure.walk's postwalk function's walking be limited to certain types?
11:45DeranderWhat's the best way of implementing a callback system? I have a series of sub-modules that I'd like to subscribe to filetypes
11:46DeranderEach time I loop I generate a list of files that have changed and would like to hand them over to the appropriate functions
11:46zmyrgelI tried the postwalk-demo function for my game tree and it walked the fields of my record I'm storing in the gametree
11:46Deranderbah, nevermind.
12:04kumarshantanuis it possible to access Java enums in Clojure?
12:04chouserkumarshantanu: yep
12:06alexykhow do you join together a vector into a string with "\t"?
12:06chouser,(clojure.string/join \tab [1 2 3 4])
12:06clojurebotjava.lang.ClassNotFoundException: clojure.string
12:06chouser,(require 'clojure.string)
12:06clojurebotnil
12:06chouser,(clojure.string/join \tab [1 2 3 4])
12:06clojurebot"1\t2\t3\t4"
12:07kumarshantanuchouser: can you give me a simple example? I just need to read enum values
12:08alexykchouser: thx! I always forget where I get the join from :)
12:12kjeldahlraek: Iterate over clojure dataset: ($ :all nameofdataset)
12:12kjeldahlraek: s/clojure/incanter/
12:13kjeldahlraek: or (doall (map println nameofdataset))
12:14kjeldahlraek: Eh, doall not needed.
12:14kumarshantanuchouser: found it! (it was an inner class that I figured needs $ as separator)
12:14fliebelWhoohoo, my automatic Reddit clone works: http://77.164.81.181/
12:21chouserkumarshantanu: sorry, I stepped out. glad you found it.
12:31zmyrgelHow to represent "" as char?
12:32Chousukehm?
12:32Chousukedoes that even make sense?
12:33zmyrgelprobably not
12:33Chousukeif you must, perhaps nil will work
12:33zmyrgelthat gave NPE
12:33raekzmyrgel: what is you use case?
12:33zmyrgelraek: removing certain char from string
12:34zmyrgelbut I changed the code to just use strings
12:36raekpstree, even
12:37fliebelwhat?
12:37clojurebotwhat is short for ,(doc ...)
12:39fliebelraek: Where is that to be found?
12:39raekit is a command line program
12:40raekfor unix-like systems
12:42fliebelraek: Oh, I was trying what clojurebot suggested.
12:43raek'tree' is neat too
12:45raekhttp://pastebin.com/cMuE1mxN
12:46fliebelI know tree, but not ptree and pstree
12:47raekptree was just a typo :)
12:48fliebel-bash: pstree: command not found
13:13LOPPman I must be too dumb for clojure
13:14LOPPEvery time I try to do a beginner exercise for java in clj I end up using loop/recur as impromptu for loop
13:15LOPPcase in point: given height (lines), print out a pyramid (triangle) out of "*"
13:16LOPPclojure code ended up messier than java
13:24dakroneLOPP: how were you doing it in Clojure?
13:25LOPPI tried in many way
13:25LOPPeventually it was the least hassle just approximating java for loops with loop/recur
13:26raek,(take 5 (iterate #(str % "**") "*"))
13:26clojurebot("*" "***" "*****" "*******" "*********")
13:26raek,(count (let [s "***", n 7, spaces (repeat (/ (- n (count s)) 2) \space)] (apply str (concat spaces s spaces))))
13:26clojurebot7
13:26raek,(let [s "***", n 7, spaces (repeat (/ (- n (count s)) 2) \space)] (apply str (concat spaces s spaces)))
13:26clojurebot" *** "
13:26LOPPexercises for java programmers that can't be easily converted into operations over lists typically end up in ugly clojure code, at least for me
13:27LOPPI don't think you need to add spaces at the end
13:32nickaugustdoes clojure work on the non-oracle JVMs?
13:33fliebelLOPP: ##(let [star (take 5 (iterate #(str "**" %) "*")) space (take 5 (iterate #(apply str (next %)) " "))] (dorun (map (comp println str) space star)))
13:33sexpbot⟹ * *** ***** ******* ********* nil
13:33raekLOPP: my try: https://gist.github.com/722136
13:34technomancynickaugust: works great on openjdk, ok on IBM, and not at all on gcj.
13:35nickaugusttechnomancy: thx
13:38joshua__How would I get a timestamp/datetime in Clojure? I'm working on making a function for rate limiting.
13:41fliebelLOPP, raek: Now, how about a christmas tree?
13:42bortrebambient? are you there
13:43bortrebI was wondering how (defn lo-pass [d coll] (reductions #(+ (* %2 d) (* %1 (- 1.0 d))) coll)) manages to implement a lo-pass filter
13:43bortrebis it exact or approximate?
13:44bortrebanyone know??
13:46nickaugusttechnomancy: so clojure is very much dependent on oracle not doing anything dumb with openjvm
13:48LOPPraek
13:48raekyupp?
13:48technomancynickaugust: not really; openjdk 1.6 is always going to be there and free.
13:48LOPPnow compare the complexity of your code with this
13:48LOPPhttp://pastebin.com/np42jLT5
13:50nickaugustalso whats the advantage of being on the JVM? dont you basiclly have platform independence by adhering to posix? being such a pain to maintain the JVM what is the benifit we get for using it? library support?
13:52LOPPbbl
13:53Chousukenickaugust: you get the platform for free.
13:54Chousukenickaugust: libraries, portability, garbage collection, optimisations
13:55Chousukenickaugust: if you implemented Clojure "from scratch" you'd have to take care of everything yourself.
13:55LOPPyep
13:55Chousukeand the end result would probably be inferior, since the JVM is rather awesome.
13:55LOPPnobody cares about languages with crap libraries
14:01raekLOPP: https://gist.github.com/722184
14:02raekmy previous attempt had more reusable parts, though...
14:03nickaugustno not trolling! not atm anyway :P just trying to make smart decisions. :)
14:03nickaugustIve heard the JVM is hard to maintain
14:04kumarshantanunickaugust: oracle is pissing lots of devs these days, but clojure is ported to CLR too
14:04LOPPin what way
14:04nickaugustCLR isnt open though :/
14:04chousernickaugust: the JVM is a whole bucketful of engineering compromises. When their decisions line up with your needs, it can be truly fantastic.
14:04technomancyconsider that Clojure was implemented by one person in a handful of years and is much faster than Ruby, which has had a large team of developers working on it for decades.
14:04LOPPawesome raek
14:04LOPPgood work
14:04kumarshantanunickaugust: yeah, and there are people interested for Parrot too
14:05LOPPyeah I ended up using loop recur too
14:05LOPPthe other looping constructs seem limited
14:05raekLOPP: the last version is basically just a translation of the java code
14:05raekmodulo fixing the initial stars value
14:06LOPPI see
14:06LOPPbbl
14:06raekLOPP: now, star-seq might not be something you use very often, but centering a string in a fixed width column might
14:06jsandai'm not a ruby dev, but i've heard that in many instances jruby has outperformed the c implementation of ruby, so in terms of performance, i think the jvm is an attractive choice
14:07nickaugusti guess i just dont understand why VMs are the future. i mean why abstract away the OS like that? is it easier to be compatible with VMs that with OSes? I thought thats why we had posix standards. im not trolling im really trying to make a good decision on what technology to use and clojure looks awesome. im just worried i'll kick myself later for choosing to be dependent on the decisions of
14:07nickaugustoracle. i guess thats why support for the other open JVMs is important
14:07raekI think one of the powers of functional programming is that code tends to (at least IMHO) be easy to compose and reuse
14:07jsandaand as far as performance goes there is work being done to improve performance for dynamic languages. java 7 or maybe 8 now is going to add a new byte code to significantly improve the performance of dynamic method invocation
14:08jolyI remember there being problems with posix implementations, where systems like NT were declared posix compliant but still missed out on much functionality people relied on
14:09nickaugustis ther performance benifits from using a bytecode compiler? obviously theres something attractive to M$ and oracle about VMs
14:09nickaugustyeah posix isnt perfect by any means
14:09kumarshantanunickaugust: I know at lest one person who thinks a C port of Clojure (with FFI) would be awesome, but I am not sure how good library support will be there
14:10kumarshantanus/lest/least/
14:10sexpbot<kumarshantanu> nickaugust: I know at least one person who thinks a C port of Clojure (with FFI) would be awesome, but I am not sure how good library support will be there
14:10nickaugustwell thats the kicker... in order to get library support you need to gain the acceptance of the wider community but to gain thier acceptance you need... well library support
14:10chousernickaugust: using a VM is not primarily a performance decision, though there are things that can be done with live profiling of a running code of the sort hotspot does that isn't done on processors today.
14:11jsandai have read that there are lots of potential performances gains for runtimes like the JVM as well as the CLR since they can perform compiler optimizations at runtime based on the given runtime profile
14:11nickaugustso portability is the advantage of using a VM?
14:12kumarshantanunickaugust: portability + libraries written in non-clojure languages
14:13hiredmanthe advantage to using a vm is the same as it every was
14:14hiredmanthe unix process model is a vm, the interface it provides is an abstraction on top of hardware
14:22pjstadighiredman is getting philisophical
14:23technomancyit's like a machine... but virtual. whoa.
14:26hiredmanfrom what little experience I have with old gray beard unix dudes that is how they refered to it "the unix vm"
14:27Chousukeit's vms all the way down
14:28Chousukethe processor offers a virtual interface nowadays too :P
14:28Chousukesort of
14:38nickaugust hmm interesting way of looking at it..
14:55fliebelraek, LOPP: This beats them all: (doseq [l (take 10 (iterate #(str % "*") ""))] (println (format "%1$30s*%1$s" l)))
14:56KirinDaveAm I misreading this
14:56KirinDaveor is there no way to import all classes in a java package?
14:56hiredmancorrect
14:56chouserit's a feature
14:57KirinDavechouser: A feature which makes me type more.
14:57cemerickAnd not particularly possible given a dynamic environment.
14:57chouserKirinDave: a feature that makes your code better
14:57KirinDavechouser: When a package name ends in "schema" you know things are about to get exciting with import, eh?
14:58chouserI do wish there were a way to alias classes and/or package names.
14:59KirinDaveI've got probably 30 classes to import. I can feel the typing making my programming skills grow. :)
14:59KirinDaveOh wait, I'm going to use ack and awk.
14:59KirinDaveI guess using those every once in awhile does constitute the kind of mental gymnastics that help keep one's edge sharp.
15:00chouserwell, you could use a macro
15:00chouserit you're desperate
15:00pjstadigcan you write a program to generate the import for you?
15:00KirinDavepjstadig: That's what ack + awk is.
15:00KirinDavechouser: Hah, that's my kind of solution
15:00pjstadigsure you could use that
15:01KirinDavechouser: Reflect on a package in a macro?
15:01KirinDavechouser: (import* com.banksimple.accounting.schema) ; THIS IS ABOUT TO HAPPEN.
15:01kjeldahlWhat's the recommended way to force a clojure lein project to use specific versions of jars from another project that I also work on? Symlink into lib?
15:02hiredmanput the versions you want in the project.clj
15:02chouserKirinDave: oh, you really can't name just the short name of the classes you're going to import?
15:02KirinDavechouser: ?
15:02KirinDavechouser: I'm not sure I understand.
15:02kjeldahlhiredman: But the version is under development. If it gets copied into lib, updates will not be catched. Or maybe they will if I add -SNAPSHOT?
15:03KirinDavechouser: There are like 30 ORM classes from squeryl in this package. I want them all available for use.
15:03kjeldahl(assuming leiningen does things similar to maven...)
15:04cemerickKirinDave: I think chouser means (import [package.name ClassName1 …]).
15:04chouserKirinDave: I just mean that I really hate reading code that has names dropped into it from no observable place.
15:05cemerickand I'm almost certain someone wrote an import* already, posted it to the ML
15:05hiredmankjeldahl: look up checkout depedencies in the lein readme
15:05KirinDavechouser: Normally I agree.
15:05kjeldahlhiredman: Thanks.
15:05KirinDavecemerick: I do not read the ml. There is too much mail and not enough me time as it is.
15:05chouserperhaps instead of ORMClass1 you could say (mymacroresolver ORMClass1)
15:05cemerickchouser: ooh, I'll bookmark that msg of yours for prior art on my arguments against an automatic make-Foo factory fn for records! ;-)
15:06KirinDavechouser: I understand that concern. I'm not doing that without reservation.
15:06KirinDavechouser: ORM schema mappings are one of the rare cases where I think it makes sense.
15:06cemerickKirinDave: Sure, I meant just searching for the topic. It's been around the block a couple dozen times.
15:06KirinDavechouser: You probably need all the nouns to make even basic coherent conversations about this.
15:07dnolenanybody ever tried to make their own version of Cons?
15:09cemerickdnolen: just out of lambdas? Long time ago…
15:09joshua__How do I grab the current time in clojure? Sorry for being so noobie.
15:09cemerick,(System/currentTimeMillis)
15:09clojurebot1291147791868
15:09KirinDavejoshua__: If you're using clj-time you can use (now)
15:09cemerickjoshua__: ^^
15:10joshua__Thanks cemerick!
15:10KirinDavejoshua__: If you're working with time you probably want to use clj-time, even if it's basic stuff. Java's time support is pretty rudimentary without some helper libraries.
15:10joshua__I'm making a rate limiting function so really I'm just looking for something that I can turn into seconds.
15:10joshua__It 'looks' like (System/currentTimeMillis) would be fine for that.
15:11arohnerKirinDave: OT, but how happy are you using squeryl in clojure? imports aside...
15:11dnolencemerick: no I mean in Clojure. Cons in clojure expects the right hand side to be a seq. I'm interesting in something that allow anything on the right hand side, like Scheme. At the same time I'd like to some aspect of seqs, but I'm wondering what the pitfalls are ...
15:11KirinDavearohner: I have no idea.
15:11dnolenplanning on go over the abstractions in detail of course, but helpful to hear of other experiences.
15:11cemerickdnolen: hrm, that's called a dotted pair in CL, right?
15:11dnolencemerick: yup.
15:11arohnerKirinDave: that sounds like a good blog article, once you've formed an opinion. I'd certainly be interested
15:12KirinDavearohner: Yeah.
15:12cemerickdnolen: I guess I'd wonder what the advantage would be over just [a b]
15:12cemerick(unless this is an academic exercise)
15:12dnolencemerick: Prolog I believe expects a traditional cons (as does miniKanren)
15:13chouserbut you don't get the seq abstraction unless you assume the cdr is itself a dotted pair, right?
15:13KirinDavePeople talk about clojure being a difficult peer in cross-language discipline
15:13chouserI mean, it doesn't make sense.
15:13KirinDavebut man is scala unfriendly sometimes
15:13dnolencemerick: this make cons a relationship, allowing relational operators that can "grow" lists
15:13KirinDave"Oh sorry, these collections... they are not real"
15:13dnolenchouser: In my case I only need to support twoo cases. A logic var or a real Seq.
15:15cemerickdnolen: I guess I'd say that if you're looking to do real work with this thing, make a protocol and model it out properly (as opposed to thinking about some specialized concrete impl).
15:16dnolencemerick: that's what I'm doing.
15:16joshua__How do I turn a ratio into a decimal?
15:16chouserdnolen: (deftype pair [a b] clojure.lang.ISeq (first [_] a) (more [_] b) (next [_] b) (seq [this] this) (equiv [this that] false))
15:16cemerickoh; well, then those two cases should be straightforward?
15:16chouser(pair. 1 (pair. 2 (pair. 3 nil))) ;=> (1 2 3)
15:16joshua__(.Decimal 1232/232)?
15:16chouserdon't tell rhickey I said that
15:17joshua__A double rather
15:17cemerickchouser: (equiv [this that] false) << LOL
15:17cemerickwhoa, that'll end up as an example for deftype on clojuredocs!
15:17chouserequality is hard to get right. that's my best effort.
15:18tonyljoshua__: have you try ##(double (/ 12 34))
15:18sexpbot⟹ 0.3529411764705882
15:18dnolenchouser: heh, I've already gotten that. that causes - ClassCastException clojure.lang.Symbol cannot be cast to clojure.lang.ISeq
15:18joshua__that works thanks
15:18dnolenthat far.
15:18joshua__tonyl: that worked, thanks!
15:19tonyljoshua__: np
15:19chouserdnolen: because ISeq promises that rest returns an ISeq, but dotted pairs explicitly break that
15:19chouserso ... what did you want again?
15:19dnolenchouser: some thing that can handle some other than nil on right side for the terminator.
15:20chouserfor example, how should map behave given a chain of dotted pairs that ends with a logic var?
15:20@rhickeyCL is full of special cases and hand-waving due to dotted pairs
15:21dnolenchouser: this isn't for maps , or vectors, I've already thought about that. supporting them is intractable.
15:21@rhickeynot worth it
15:21chouserso what
15:21chouserso what "aspect of seqs" are you trying to keep?
15:23dnolena new type LCons which can hold a logic var on the right hand side, which also function properly when printed at the REPL. LCons can be chained together and traversed like seqs. But during unification if we get to a logic var, we can suck in another seq into it's place.
15:24chouserbut not traversed using map, filter, etc?
15:25dnolenyou'll be using relational operators, little need for that. LCons is just special kind of sequence for relational operations. Not useful outside.
15:27mefestodeftype supports java annotations. does gen-class also?
15:28dnolenI hacked something together and realized I need something like LCons to keep it clean, otherwise unification on Prolog style append is bunch of crazy hacks.
15:28cemerickmefesto: yes, in the gen-class declaration in ns
15:30ChousukeHmm, IFn specification is pretty scary. :P
15:30mefestocemerick: something like (ns ^{MyAnnotation true} my.namespace) ?
15:31cemerickmefesto: I'm not sure off the top of my head whether the class-level annotations can go on the namespace symbol itself or if you need to put it on a :name symbol in the gen-class form
15:31mefestocemerick: or (gen-class :name ^{Blah true} my.class.Name)
15:32mefestocemerick: ok i'll mess around with it, thanks!
15:32cemerickmefesto: the latter is what's demonstrated in the tests, FWIW: https://github.com/clojure/clojure/blob/master/test/clojure/test_clojure/genclass/examples.clj
15:53dnolenchouser: well that was helpful, I think I may have figured out a workaround, LCons implements IPair and ISeq. Might be issues with that but at least I can learn along the way. Really this is just so that people can play around with standard miniKanren operators in Clojure.
16:01dmart_I've been trying to find an example of rebinding *in* to a reader, but I'm not having any luck
16:03fogus`dnolen: are you unifying with &rest?
16:04dnolenfogus`: that's already working and pretty easy.
16:04dnolenfogus`: much harder is (== (cons 'a logic-var) '(a))
16:04fogus`dnolen: Then I will probably steal that from you. ;-)
16:05dnolenfogus`: :D
16:06dnolen(== (conj logic-var 'a) ['a]) also presents some interesting challenges. == is unify.
16:15jweissI don't understand this lein compile error: https://gist.github.com/722420
16:16jweissit's complaining about line 1, but something about println?
16:16clizzindoes clojure have a function that's like python's strip? i.e. if given no arguments, it does what trim does, but if given a string, it will trim not whitespace but the set of characters in the string
16:16clizzinor is this in any contrib package?
16:17brehaut,(.trim " hello ")
16:17clojurebot"hello"
16:18brehautstr-utils2 in contrib might have a function version?
16:18dmart_something like (with-open (clojure.lang.LineNumberingPushbackReader. (java.io.FileReader f)) I guess?
16:18clizzinbrehaut: no, what i want is something like (trim "abtokenbaa" "ab") -> "token"
16:18dmart_hmm
16:18brehautoh right, my bad
16:18ChousukeI think String supports a regex replace
16:19Chousukelook up the javadoc :)
16:20mefestoclizzin: clojure.string/replace might work for you
16:20clizzinjava has a replace for charsequences, but doesn't allow you to specify that the chars to be replaced must be at the start/end of a string. it also has a replace for regexes, but i was hoping to avoid the hassle of translating a string into a regex for the chars, dealing with escaping and everything.
16:20mefestoclizzin: (clojure.string/replace "abtokenbaa" #"a|b" "")
16:21mefestoah
16:21clizzinmefesto: yeah, i'll probably use that and write a function on top of that which translates other structures into a regex
16:21brehautyou want to anchor the character set at each end
16:22tonyldmart_: have you tried (binding [*in* my-reader] ...)
16:22dmart_tonyl: yeah, I did, but I was using a BufferedReader which wouldn't work
16:22dmart_so it was more the step prior to that
16:22dmart_but I've got that I think
16:22clizzinbrehaut: what do you mean by anchoring? is it possible to have an object that implements charsequence but also requires being at the start/end of a string?
16:23brehautthe example above the regex should be #"^[ab]*|[ab]*$" shouldnt it?
16:23clizzinbrehaut: yes
16:24brehauthmm, might want groups
16:24rlbI noticed that string split suppresses trailing empty fields, but not leading ones -- assuming that's intentional, it might be worth a mention in (doc split).
16:29mefestobrehaut: yeah sorry that example wasn't thought through
16:29brehautmefesto: no worries
16:51raekI declared autodoc 0.7.1 as a dev-dependency for my project that uses clojure 1.2, and now lein deps tries to download org.clojure:clojure:jar:1.3.0-alpha3...
16:51raekwhat do I do?
16:52LauJensentry cake? :)
16:53cemerickanyone have a link to Stu H's slides from the conj? #lazyirc
16:53cemerickthe google has failed me somehow
16:53LauJensencemerick: the ones on protocols?
16:53brehautcemerick: https://github.com/downloads/stuarthalloway/clojure-presentations/Clojure-Simplicity.pdf ?
16:53cemerickbrehaut: cheers, thanks :-D
16:54brehautno worries :) i knew AR tagging of links would pay off one day
16:55freakazoidAR?
16:55clojurebottar pit is http://web.mac.com/ben_moseley/frp/paper-v1_01.pdf
16:55brehautanal retentive
16:56freakazoiddamn I thought it was some bookmark service
16:56brehautoh, no sorry
16:56freakazoidI haven't found a good bookmark workflow other than chrome bookmarks and instapaper for stuff I want to read later
16:56brehauti havent either, so i built my own
16:57freakazoida searchable, complete, immutable browser history with starring would be sufficient
16:57freakazoidi don't even need tagging
16:57freakazoidbut a full gmail-like interface to it would be awesome
17:00hiredman~delicious
17:00clojurebotdelicious is http://delicious.com/clojurebot
17:02freakazoideh
17:02KirinDaveClojure interop to scala is weird.
17:02freakazoidthat seems more focused on socialness than usability
17:02brehauthiredman: that is very cool
17:02KirinDaveScala interop into clojure? Extra weird.
17:02freakazoidI mean, delicious is
17:02freakazoidTHAT is very cool.
17:04tonylKirinDave: never tried it. now you made me curious
17:06lancepantzKirinDave: have any impressions of scala vs clojure so far? is there anything a clojure programmer could get out of it?
17:06KirinDavelancepantz: Oh Scala seems very cool
17:06lancepantzaside from say, a job :)
17:06KirinDaveAs cool as CLojure, if you're into the world of statically typed programs
17:07lancepantzthe shootout numbers for scala v clojure v java caught my attention
17:07joshua__Wait so clojure can interop to java, but there are other languages on the JVM like python for instance.. so you could interop to python from clojure.. theoretically?
17:07lancepantzsome have said the clojure wasn't optimal, but what really stuck out is that scala is faster than java on some, albeit very slightly
17:07brehautjoshua__: theoretically. clj->jython interop was a bit hairy last time i tried it
17:08KirinDavejoshua__: Absolutely
17:08KirinDaveBut i think that it's something you have to be very deliberate about
17:08KirinDaveWhen i was writing clothesline, I definitely was careful
17:08lancepantzjoshua__: i've seen examples of jruby and clojure interop that looked relatively clean as well
17:08KirinDaveto make it scala friendly. For example, no making people rely on thread locals.
17:08KirinDaveOtherwise the code just gets extremely painful to work with
17:09KirinDaveGod, the web developers I work with are such badasses
17:09KirinDaveWe just launched our new promo site (not live product), and even that they made a badass html5 app
17:09KirinDavehttps://www.banksimple.com/
17:11joshua__KirinDave: Which are you in the pictures of the team (6)?
17:12KirinDavejoshua__: The joke response is "the one with the beard"
17:12brehautKirinDave: complete with the html5 approved museo typeface
17:12KirinDavejoshua__: The real response is, "The one with the epic sideburns."
17:12KirinDavejoshua__: (upper right)
17:14joshua__KirinDave: =) thanks and yea the site is nice
17:14KirinDavejoshua__: Part of why I like the site is how crazy they did it.
17:14KirinDaveFor example, that guilloche pattern behind the card?
17:14KirinDaveIt's procedurally generated
17:18tonylthat is an awesome website KirinDave. I always get excited about the BankSimple initiative and hopefully soon services
17:18KirinDavetonyl: :)
17:19lancepantzKirinDave: i imagine you guys are pretty excited about this wikileaks bank of america stuff too :P
17:22KirinDavelancepantz: We're ambivalent.
17:22KirinDaveIt's not like suddenly people are going to be more pissed at banks. ;)
17:23joshua__What command am I looking for to do a few commands and than return the last thing I do?
17:23joshua__do itself is returning nil =/
17:23chouser& (do 1 2 3 4)
17:23sexpbot⟹ 4
17:24lancepantzvery true
17:26dalecemerick: You around? I wanted to give you a heads up that I was taking a swing at implementing the SLIME (Swank) protocol atop nREPL.
17:28cemerickdale: I am, but only for another 5 minutes.
17:28cemerickdale: That's great though. I am at your disposal to answer questions and make changes to nREPL if necessary to ease the way.
17:29dalecemerick: No worries, just wanted to put it on your radar. Hugo Duncan was doing some work on swank-clojure but I gather that tapered off as he realized nREPL had more momentum.
17:30cemerickI've been meaning to claim a spot on dev.clojure.org's confluence for nREPL, so having some external collaborators will make that happen finally. :-)
17:30dalecemerick: I'm just getting started but only modifications I've made so far are breaking nrepl/read- and write-message out as arguments in a few places. I'm hoping that nREPL and swank-clojure are similar enough that I can just swap out the protocol (then implement/copy all the Swank backend functions).
17:31cemerickdale: I'm not sure that nREPL should necessarily impact hugod's swank-clojure work, at least not yet ;-)
17:31cemerickin any case, yes, I hope that they're fundamentally similar enough
17:32cemerickor, rather, that nREPL's protocol is simple enough to effectively superset what swank provides
17:32dalecemerick: At some point I'll push my nREPL changes up to Github for your review. Is that OK?
17:41technomancydale: good to hear you're tackling this; I can try to help if you have swank questions, though I'm not actually that familiar with the codebase.
17:42cemerickdale: that's fine for review -- just make sure you have a CA lodged so I can take your patches
17:45dalecemerick: Ooh, OK, didn't think of that.
17:45daletechnomancy: Cool, thanks.
18:48seancorfieldcemerick: do you know who approves clojure-dev group membership?
18:49cemerickseancorfield: I think rhickey and chouser are the admins on the lists?
18:49seancorfield'k thanx... i applied ages ago and i'm still pending :(
18:49cemericksurely an oversight :-(
18:50seancorfieldbut rhickey has my CA and i'm listed on the contributors page (although my surname is misspelt with an 'n') so most of the process has gone thru :)
19:02@rhickeyseancorfield: you should be all set now
19:50seancorfieldthanx rhickey !!
20:19technomancy,(= 4)
20:19clojurebottrue
20:20technomancythanks, clojurebot.
20:26Lajla&(=)
20:26sexpbotjava.lang.IllegalArgumentException: Wrong number of args (0) passed to: core$-EQ-
20:26LajlaHmm