#clojure logs

2011-03-24

02:56raek(defn switcheroo! [atom newval] (let [oldval @atom] (if (compare-and-set! atom oldval newval) oldval (recur atom newval))))
02:59scottj(defn swap!* [a f & args] (let [ret (atom nil)] (apply swap! a (fn [x & args] (reset! ret x) (apply f x args)) args) @ret))
03:57TobiasRaedermorning
03:59ephconmorning
03:59thorwilmorning
04:09taliosevening
04:52ejacksonMorning
04:52mduerksengreetings
04:59angermanxin chao
05:39angermanok, now this is strange, as nice as FF4 is… it chews 33% CPU just for downloading a file.
05:39angermanwtf?
05:46mduerksenangerman: just downloading libreoffice - cpu ist almost idle
05:46angermanmduerksen: yes, this is very confusing. it shouldn't be a cpu intensive task to download afile.
05:46mduerksenmaybe its the final virus check you observed?
05:47angermandownload is maybe 25% done.
05:47angermanwill go on for another 70 min
05:48mduerksenok, so that can't be it. do you have more tabs open? with flash etc.?
05:48angermanno, nothing is open.
05:48angermanexcept for the download window.
05:52mduerksenbeats me...
05:53angermanmaybe it's the file size.
05:53angerman4.5gb
05:53clgvangerman: is it https?
05:53angermanclgv: hmm, that might be.
05:54angermandoes apple serve the xcode+iso bundle from behind a https uri? … lets see
05:54angermanhmm no.
05:54clgvI guess youi would notice https in cpu usage but not that much on a modern cpu
05:55angermanyea, I'm simply subsum it as weird. If it doesn't persist, it's ok.
05:56angermanif it stays that way… FF4 has to go
05:56clgvoh you are an early adopter ;)
05:57angermanIt's been FF most of the time, than for a short period of time Safari, because I simply felt faster. Until Chrome arrived, which basically just improved on Safari. But FF4 feels snappy again.
05:59angermanToo much of any one vendor is just not good. And I have a semi-sceptical relationship with google. But by the end of the day, what is the least hassle wins.
05:59clgvhumm a different question: is there something like partial that also updates metadata?
06:00clgvI am building a configuration DSL for my algorithm and would like to check at least arity of the functions to provide an early error to the user
06:01angermanI don't think anyone would have ventured down that way yet.
06:02clgvhm I could have a look at the partial definition and hack it myself. or wrap the partial functionality in another fn or macro that keeps and updates metadata
06:09raekclgv: function objects do not carry metadata about the arity... or did you add it yourself?
06:10clgvraek: they do indirectly in the argslist when you use defn. but only if it's not overriden manually
06:11raekthat metadata is on the var, not the function
06:11clgvdoes that distinction really matter?
06:11clgvI am not going to assign the same function to a different var
06:12raekyou'd have to make your variant of partial a macro
06:12clgvbut it would indeed fail if someone would be using fns
06:12raekor force the user of it to pass the var instead of the function
06:13clgvmaybe I should define my own definition of these kind of functions
06:14clgvit's only intended to be at the configuration layer
06:16angermanjikes...
06:19clgvangerman: ?
06:20angermansomehow sandbar pukes at me.
06:20angermanclaims that sandbar core is not found.
06:20angermanmake zero sense.
06:27angermanah. it did make sense. on a very sad level.
06:27angermansandbar `uses` hiccup 0.3.0 which conflicts if you use hiccup 0.3.4
06:34clgvso you are doing web development in addition to your tikz rendering
06:35angermanweb stuff is mainly a side gig.
06:35angerman(Research/Univ. is mostly Math / Sidestuff is Websites and iOS dev)
06:41pyrmorning
06:41angermanmornig.
06:44pyri'm splitting up a rather large clojure project into several files
06:45pyrand wondering what the best thing would be
06:45pyri suppose i can't use one ns for all files
06:45pyrbut should all independant files cross-reference the other namespaces declared ?
06:46angermanpyr: I usually pack them up in seperate namespaces and require them.
06:46angerman(:require [geometry :as g])
06:46pyr'k
06:46angerman(g/with-geometry …)
06:48_atoyou can actually use one ns with multiple files, use the "load" function from the main file
06:48_atoclojure.core uses that technique for example
06:49pyrthat sounds nice
06:49clgvpyr: I guess you have a reason for splitting the project into separate files. I also guess that you will group the functions together that somehow belong together semantically. so why not take that "semantic reason" and derive an appropriate namespace from it? ;)
06:50pyrclgv: you're right
06:50pyrclgv: but i'm doing it a step at a time
06:50pyrsince splitting up reveals toe-stepping
06:50pyrbetween semantical units
06:53raeka good partitioning of the namespace would be a "layered" one, since namespaces cannot have circular dependencies
06:56pyrok
06:56pyrthanks for your pointers
06:58raeke.g. (ns apple) (defn make-apple ...) (ns basket) (defn make-basket ...) (defn apple-in-basket? ...) rather than (ns apple) (defn make-apple ...) (defn apple-in-basket? ...) (ns basket) (defn make-basket ...)
06:58raekthe rationale being that the "apple" does not have to be conserned with what might contain it
07:00angerman? (case …) has no fall through?
07:01angermanalright. it's the last item… weird.
07:47angermancan I injetct a multi-method in a foreign ns?
07:48raekangerman: a defmulti or a defmethod?
07:48angermandefmethod
07:50raekyes you can. (ns foo) (defmulti m ...) (ns bar (:require foo)) (defmethod foo/m ...)
07:51angermanraek: great!
07:53angermanwow. library fail!
07:53angermanmethod not public.
07:55angermanreak is there some macro, that would allow me to go into a ns, mess with the stuff, and come back?
07:55angermanor would I have to write one?
07:55clgvangerman: there is an with-private macro I found and used for tests
07:55angermanI don't want to use it for tests only. It's a little bit like money patching.
07:56angermanCurrent solution is to just copy the private function into my source tree.
07:56angermanbut that's rediculous!
07:56angermanAhh well, too much complaining. It works, is ugly, who cares.
07:57clgvhttp://pastebin.com/CMKsKKeF
07:57clgvit is not limited to tests. I also used it with hooks
07:57angermanclgv: I basically want to patch functionality into a library.
07:58clgvjust try it ;)
07:58angermanusing defmulti was a good idea by the library author.
07:58angermanusing a private method for essential computation inside of the multimethods was not.
07:59clgv"private" is only metadata that is enforced by the clojure environment though ...
07:59clgvbut it would be better if you wouldnt have to work around
07:59angermanyes. It's just a mistake by the lib's author.
08:00angermanwhat the library does is great, but how it does, is not so.
08:01clgvbut it's not only an error by 3rd party libs. this case can also be found in clojure e.g. core
08:01angermanI don't know I don't "privatize" my fns.
08:02angermanmaybe put them in a different namespace, for hygenic reasons.
08:02angermanThat reminds me.
08:02angermanCan I extend a Java Class's final method?
08:03angermanor is final enforced on a jvm level?
08:03clgvgood question. but I guess it must be enforced on jvm+compiler level, since you often have no source ;)
08:04angermando I need the source?
08:04angermanclass X { final int do() { System.out.println("I do"); } }
08:05angerman(defprotocol Do (do [_] "does soemthing"))
08:05clgvI mean. if you only have the super class as jvm bytecode it must contain some information about final
08:05angerman(extend-type X Do (do [_] (println "I don't!") ))
08:05angerman(.do X)
08:05clgvthat means as soon as you want to compile a class extending it, the compiler will forbid you to
08:06angermanbut in this case, the method is final, not necessarily the class.
08:06angermanEven though, is it a feature of the Java Compiler, or a JVM enforcement?
08:07clgvI dont know if the classloader would forbid you to load the class if you somehow managed to get it compiled
08:08angermansound's like it's up for an experiment.
08:08angermanHmm. will do that next on my todo list
08:10clgvbut it might be a hard assignment if the compiler doesn compile it for you and you have to generate the bytecode yourself ;)
08:10tsdhDo I see it correctly that in order to call clojure functions from Java, I :gen-class my ns, declare the function signatures using :methods, and create wrapper defn's starting with a -?
08:10angermanNah. I'm only interested if clojure allows me to.
08:13_atoangerman: Exception in thread "main" java.lang.VerifyError: class bar overrides final method eep.()I
08:13_atoat runtime
08:13tsdhAt least, that's what's suggested in http://java.dzone.com/articles/java-clojure-interop-calling. Especially the -wrapper-functions seem a bit redundant...
08:13angerman_ato: ohh, thanks.
08:14_atoeven if you could turn off the bytecode verifier it probably wouldn't work right anyway because optimisation likely depends on it, eg final methods can be inlined
08:15angerman_ato: good point.
08:15angermanHmm life surgery on java's heart.. no thanks.
08:16thorwilhow do i get at the contents of a #<params$wrap_params$fn__1835 ring.middleware.params$wrap_params$fn__1835@25be8e06> ?
08:17angermaneval it?
08:20thorwilcan't in a way i get to see anything
08:20angermanmaybe I'm completely wrong, but that looks like a function to me.
08:22thorwili don't know what it is, but surely not what i'm after :/
08:22_atoheh, where did you get it from?
08:23angermanthorwil: what you posted looks like a method handle.
08:23angermanthorwil: evaluating that method will get you to it's contents.
08:23_atooh it's the lambda inside this: http://clojuredocs.org/ring/ring.middleware.params/wrap-params
08:24thorwilhmm. my trouble seems to start elsewhere.
08:24thorwil(app [[path not-empty] &] (submit-article (wrap-params get-form-params) path))
08:25angerman&] ?
08:25sexpbotjava.lang.Exception: Unmatched delimiter: ]
08:25thorwil^ it looks like get-form-params is not evaluted before submit-article
08:26thorwilangerman: it matches urls with or without trailing /
08:26Raynesangerman: Congratulations! I think you're the first person ever to accidentally set off sexpbot's evaluation. I had a cookie for you, but I ate it.
08:27angermanRaynes: i c
08:27thorwilnow it dawns on me. have to try (eval (wrap-params get-form-params))
08:27Raynes:>
08:28angermanthorwil: ((wrap-params get-form-params))?
08:28_atoer, I don't think that's going to help. I think angerman meant 'call' rather than 'eval'
08:29angermanthorwil: I'm not really sure what you are doing but it looks a little confused.
08:29angermanget-form-params sounds like a function rather than a value
08:30thorwilangerman: http://groups.google.com/group/clojure/browse_thread/thread/a9fa0022c9d06a93?hl=en#
08:30thorwilangerman: there surely is a lot of confusion in my head
08:31thorwilget-form-params is a function for getting the stuff i want out of the request map that has been added to by wrap-params
08:31angermanwell then your calling is reverse already.
08:32thorwilif i just wrap my handler, i can't pass another argument
08:32angermanso you want something like (get-form-params (wrap-params request)))
08:32thorwilangerman: wrap-params takes a handler, nothing else
08:33thorwilstrike that
08:33_atoit takes a handler and returns a function that takes a request
08:33thorwilbut it does not take a request, that i already implied
08:33angermanthorwil: the primariy idea of that line was to show that the logic is somehwat reverse.
08:34angerman(def wrapped-app-handler (wrap-params app-handler))
08:34raekthorwil: note that the form to the right of the vector should eval to a (possibly wrapped) ring handler fn
08:35angermanthen within app-handler you can appy (get-form-params to the request)
08:35raekmoustache has syntax for wrapping too
08:35raek(app ["foo"] [wrapper1 (wrapper2 arg) handler])
08:38raek(clarification: if a form is not a vector or a map in moustache, it should usually eval to a ring handler)
08:40thorwilraek: it seems to me that i need either a wrapper that binds the form-params, or one that adds "path" to the request map (?)
08:41raekparsing form params is not done by moustache. you can use the standard ring wrap-params for that.
08:41raek(basically, moustache only does routing)
08:41thorwilyes, that's why i use wrap-params already
08:42thorwilthe problem is passing another argument to my handler, alongside
08:42raekah
08:42angermandoesn't wrap-params just extend the request map?
08:43thorwilyes
08:43raekI guess you can do something like (fn [req] (handler something req)) or (partial handler something)
08:44raekor make a middleware fn that adds it to the reuqest map
08:44thorwilpartial leads to fun like: results in "nth not supported on this type: PersistentHashMap"
08:44raekso this extra argument is not something in the form params?
08:45clgvraek: do you know where in clojure.core the "&" in parameter declarations of functions is handled?
08:45_atopartial would make path the first argument and request the escond argument
08:45raekthat doesn't sound like something that is introduced by partial itself
08:45thorwilraek: no, the argument is part of the url, taken from moustach's destructuring
08:45_atosounds like maybe you want: (app [[path not-empty] &] (wrap-params (fn [req] (submit-article req path))))
08:46angermanthorwil: maybe you should give more high-level explanation of what you are trying to archive
08:46angermanI still think you are stuck somewhere in the core without a clear understanding of how things are designed to work.
08:48thorwiltrying _ato's suggestion, first :)
08:49_atoI'm assuming your submit-artcle is like: (defn submit-article [request path]) ; partial would assume it's like: (defn submit-article [path request])
08:49_atoclgv: in destructure https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L3837
08:50_ato(= firstb '&) ...
08:50angermanlater
08:51clgvsure? I dont see destructure being called in defn
08:51Chousukedestructure is called in fn :)
08:51Chousukeor well, no.
08:51clgvah maybe-destructured is called in fn
08:52Chousukefn destructuring is a bit different from let-destructuring :/
08:52_atoit turns it into a let doesn't it?
08:53_atoand let calls destructure
08:53clgvyep it does
08:53clgvmaybe-destructured is building a let
08:53thorwilworks, and i know how to take the map apart!
08:53thorwil_ato: thank you!
08:53thorwilraek and angerman, too :)
08:54clgvuuuuh! destructure is a monster
08:56ChousukeIt is. Fortunately, it works
08:56thorwil_ato: to be sure, i take it the deciding thing about the anonymous function is that it takes a single argument, where the name there is just a binding?
08:58_atothorwil: yeah, wrap-params expects to be given a function that takes a single request argument, which we bind to 'req'.
08:59kjeldahlwI'm struggling with some clr interop issues, need to figure out what classes/methods are available for a namespace etc. Any pointers on nice examples on how to "inspect" similar stuff in the java world?
08:59kjeldahlw(clojure jvm world I mean)
08:59_atokjeldahlw: are you asking how to list the methods on a java class?
09:00kjeldahlw_ato: Yes, for anything inside something from the java world that one would require into the current namespace or similar.
09:01_ato(seq (.getMethods String)) will get you a list of all the methods on the String class
09:01_atofor nicely formatted output check out the 'show' function in clojure.contrib.repl-utils
09:02thorwilbut i'm an idiot, (app [[path not-empty] &] (wrap-params (partial submit-article path))) works, too
09:03_atokjeldahlw: oh and the other half of the question (ns-imports *ns*) will list the classes imported into *ns*
09:06clgvkjeldahlw: seems the "ns-*" functions are of interest
09:10samlwhat's the clojure eval bot that you are using?
09:10saml> (+ 1 2)
09:10hsbot No instance for (GHC.Show.Show (a -> a)) arising from a use of `M43891536.show_M43891536' at <interactive>:(2,0)-(4,32) Possible fix: add an instance declaration for (GHC.Show.Show (a -> a))No instance for (GHC.Num.Num (...
09:10_ato,(+ 1 2)
09:10clojurebot3
09:10_ato&(+ 1 2)
09:10sexpbot⟹ 3
09:11samlis it open source?
09:11_atosaml: https://github.com/cognitivedissonance/sexpbot https://github.com/hiredman/clojurebot
09:11saml,source
09:11clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
09:12_ato~source
09:12clojurebotsource is http://github.com/hiredman/clojurebot/tree/master
09:12samlwhat's the difference?
09:13_atothe , means eval clojure code, ~ means run a bot command
09:13samlsexpbot vs clojurebot
09:13clgvsexpbot is way cooler ;)
09:13clgv$source map
09:13sexpbotmap is http://is.gd/Fd9Ag4
09:14samlsexpbot, is web scale
09:14samlit is mongodb
09:15kjeldahlwExcellent. (ns-imports *ns*) shows the stuff I was looking for. And given a key from that map, how do I list all symbols in the namespace?
09:16samlwhy clojure no new release?
09:16samlis it abandoned?
09:16clgvkjeldahlw: there is also ns-map.
09:17jolysaml: not abandoned
09:17clgvjust do a ##(find-doc "ns-")
09:17sexpbot⟹ ------------------------- clojure.contrib.logging/commons-logging ([]) Defines the commons-logging-based implementations of the core logging functions. End-users should never need to call this. ------------------------- clojure.core/ns-aliases ([ns]) Returns a ... http://gist.github.com/885030
09:17_atosaml: releases are here: https://github.com/clojure/clojure/downloads
09:18samlit's alpha
09:18jolysaml: still means there is active development
09:18clgv1.2.0 is not alpha ;)
09:18raeknor is 1.2.1...
09:18clgvraek: 1.2.1?
09:18samlwill stuff change a lot on 1.3?
09:18samlshould i use 1.3 or 1.2?
09:19samlin production
09:19raekI think it was released this week
09:19clgvfor real?
09:20kjeldahlwclgv: Thanks, but how do I use it? If I put in as parameter anything from the (ns-imports *ns*) (keys or values) I get "no namespace" errors. Feel free to give an example from the jvm world..
09:20raekmaybe it hasn't been announced yet, but leiningen 1.5.0 (also released this week?) uses it as the default now
09:20clgvraek: dont see it on clojure.org
09:20_ato1.3 changes are shown here: https://github.com/clojure/clojure/blob/master/changes.txt there are breaking changes, I think mostly it's just adding :dynamic when you want to rebind stuff
09:20raekhttp://build.clojure.org/releases/org/clojure/clojure/1.2.1/
09:21clgvkjeldahlw: I just meant you can lookup functions with it. ns-map sounds promising
09:21clgvraek: changelist?
09:21clgvraek: or better update notes?
09:22raeksaml: there has been discussions of changing the version from 1.3 to 2.0, so there might be some breaking changes
09:23raekthough, I know that there are people who use 1.3 in production already
09:24kjeldahlwclgv: Sounds easy, maybe I'm just being dense. If I do (ns-imports *ns*), the first pair I get in the map is UriBuilder System.UriBuilder. Trying (ns-map UriBuilder), (ns-map System.UriBuilder), and also with the quote symbol in front, I still get errors. Do I need to "look up" the namespace some other function before passing it to ns-map?
09:24raekclgv: http://groups.google.com/group/clojure-dev/browse_thread/thread/f1b1fbfd2a6c1a9f
09:24samlraek, ah thanks
09:24clgv,(ns-map *ns*)
09:24raek,(ns-publics 'clojure.core)
09:24clojurebot{sorted-map #'clojure.core/sorted-map, read-line #'clojure.core/read-line, re-pattern #'clojure.core/re-pattern, keyword? #'clojure.core/keyword?, val #'clojure.core/val, ProcessBuilder java.lang.ProcessBuilder, chunked-seq? #'clojure.core/chunked-seq?, Enum java.lang.Enum, find-protocol-impl #'clojure.core/find-protocol-impl, SuppressWarnings java.lang.SuppressWarnings, ...}
09:24clojurebot{sorted-map #'clojure.core/sorted-map, read-line #'clojure.core/read-line, re-pattern #'clojure.core/re-pattern, keyword? #'clojure.core/keyword?, val #'clojure.core/val, chunked-seq? #'clojure.core/chunked-seq?, find-protocol-impl #'clojure.core/find-protocol-impl, vector-of #'clojure.core/vector-of, object-array #'clojure.core/object-array, *compile-path* #'clojure.core/*compile-path*, ...}
09:25clgvraek: thx
09:26kjeldahlwraek: How about anything that is not from the clojure namespace, but java?
09:27_atokjeldahlw: Java classes aren't clojure namespaces, so you need to use Java reflection to list their methods. AFAIK there's no Clojure functions for doing it (in core), you just use: (.getMethods SomeClass)
09:27kjeldahlw_ato: Ah, ok. Similarly for clr then. Ok, I'll keep digging. Thanks.
09:28_atomaybe (.GetMethods System.UriBuilder)
09:29_atofor CLR
09:29clgvkjeldahlw: how does clojure CLR work for you so far?
09:29_atojust guessing from some example C# code
09:46tsdhWhat's the right way to coerce a ratio into a double with proper rounding?
09:46tsdh(double (/ 1001876 11)) ==> 91079.63636363635, which is wrong.
09:47tsdhCorrect would be 91079.63636363636.
09:48tsdhHm, doing the same in Java gives 91079.63636363637, which is wrong, too. :-)
09:50amalloytsdh: wtf, that doesn't look wrong to me
09:51amalloyer, yes it does
09:51tsdhThe correct result is 91079.[period 63].
09:51amalloybut doubles are pretty vague. if you care about precision in the 20th digit you shouldn't really use doubles
09:52amalloy&(/ 1001876. 11)
09:52sexpbot⟹ 91079.63636363637
09:53tsdhamalloy: I don't care too much, but that forces me to using a custom comparison function in my tests, where I compare Java results with Clojure results.
09:53amalloytsdh: you should be doing that anyway for doubles. never compare doubles for equality
09:54amalloythe way you compute something can cause rounding errors to appear in different places, so that results which "should" be the same will differ
09:56tsdhIn the concrete case, I really compare "1001876 / 11.0" with (double (/ 1001876 11)), so it's really only the coercion that makes the difference.
09:58tsdhAnd in this case, the Java result is about twice as near at the exact value.
09:59tsdhOr better, the Clojure error is twice as big as the java error.
10:38devnmorning gents
10:39Raynesdevn: Morning.
10:39fliebelI saw dnolen inherit Object in a deftype and overwrite equals and hashCode for speed. Why? Any deftype inherits those from Object already, doesn't it?
10:40Raynesdevn: You know, it's impossible to tab complete your name because of Derander and devhost. (sorry for the pings)
10:40RaynesNot that it's difficult to type out. Just an observation.
10:40dnolenfliebel: for improving the speed of putting LVars into a collection (PersistentHashMap/Set)
10:41fliebelRaynes: depends on your client and how many chars you type before completing.
10:41amalloyfliebel: i saw that too and was puzzled
10:41amalloydnolen: did your original version use defrecord instead?
10:41fliebeldnolen: Sure, but why are your methiods better than those on Object?
10:41dnolenamalloy: no
10:42tsdhMy leiningen project depends on a foo.jar contained in lib/. How can I teach leiningen not to add that into the uberjar, because now I want to use my project in the foo project (which of course contains its own classes anyway)?
10:42amalloydefrecord comes with value-based versions of = and hash, but i had the same thought as fliebel: this looks just like the built-in
10:42Raynesfliebel: Not really. In this case, if you type d, you get a list of everyone with d in the name. de, you get Derander; dev, you get devhost. The only way around that is to set it to prefer the people who have spoken last.
10:42amalloytsdh: circular dependencies are not cool
10:43RaynesOr get a client that doesn't understand the order of the alphabet. But I digress.
10:43amalloyRaynes: or get privs and boot anyone whose name gets in the way of your tab completion
10:44Raynes:)
10:44tsdhamalloy: Well, I agree. What I really want is to use my clj project in another Eclipse Java project that depends on the Eclipse Java foo project.
10:46fliebeldnolen: equals of Object is really identical, and uses == ultimately. hashCode does call some other function that may take some time.
10:46fliebelVMMemoryManager.getIdentityHashCode
10:47amalloyi rule my filesystem with an iron fist. it messes up tab completion of something more important, it gets the whip
10:47amalloyfliebel, Raynes: you could also find a client that uses fuzzy completion like emacs. then dvn would probably complete to devn
10:48amalloytsdh: then don't build an uberjar
10:48thorwili wonder why (ds/save! (flatten `(Article. ~(vals form-params) timestamp)))
10:48thorwilis not equivalent to (ds/save! (Article. path (form-params "title") (form-params "body") timestamp))
10:49dnolenamalloy: fliebel: all I know is that (.hashCode x) is ~2X faster when I've defined it myself.
10:49amalloythorwil: um, because the former has a list where the latter has a function call
10:49amalloydnolen: that i can believe, for reasons fliebel gives. but is = faster?
10:50fliebeldnolen: Yea, I can imagine, the hashCode of Object goes deep down into native code.
10:50amalloyfliebel: all the native code really does is return the object's memory address, so it seems like it should be trivially fast, but not as fast as returning a number you cached at ctor time
10:51tsdhamalloy: Oh, you are totally right. I had the impression that uberjar is needed to make :gen-class work. But that is a false assumption.
10:51fliebelamalloy: I see. What about… the speed of lookup of local vs class vs superclass?
10:52kjeldahlwclgv: Re: CLR, just getting started. Struggling with getting assemblies loaded and figuring out the CLR interop stuff (obviously).
10:52fliebelI imagine Java tries them in that order, so for a really fast function, it might be faster to have it on the class, rather than have Java go up the chain. But otn the other hand, this might be optimized away anyway.
10:53dnolenamalloy: yeah, defining equals like that doesn't make it any faster/slower.
10:53amalloyfliebel: java doesn't have to try them in any order - it's doing a dynamic dispatch on type anyway
10:54fliebelOh, right.
10:54clgvkjeldahlw: ah ok. you could let me know whether it went well when you did some progress
10:57kjeldahlwclgv: It seems to be working. I've managed a Windows "hello world" style app importing the System.Windows.Forms namespace and instantiating a MessageBox instance with the text hello world in it. But if I want to use WPF and similar, I need more access to classes and methods, which is what I'm struggling with.
11:04dnolenamalloy_: thx for the point about equals, updated my code and blog post.
11:09saml, 1 + 2
11:09clojurebot1
11:09clgv,(+ 1 2)
11:09clojurebot3
11:10scottj,1 + 2
11:10clojurebot1
11:10scottjoh it only evals the first form?
11:10angermanlol, what? IndexOutOfBounds exception?!
11:29fliebelIt'd be useful if this page mentioned which ones where lightning talks: http://clojure.com/blog/2011/03/23/conj-talks-all-up.html
11:32hvAssume I have made the JVM load a class from a SomeFile.class in CLASSPATH (file is directly there, not in a .jar). After SomeFile.class is regenerated, can I make the JVM reload it, at least for new uses of that class?
11:39Fossihv: afaik there are some hacks to do that, but normally you can't
11:40Fossijrebel and the like use proxy classes and javaagent privileges to reload some stuff
11:41Fossibut even then some things can't be replaced like enums or anonymous inner classes
11:44cemerickI seem to recall there being another library released recently (not scriptjure) that emits javascript for a subset of Clojure code. Does anyone have the name handy?
11:44cemericknm, got it: https://github.com/kriyative/clojurejs
11:46angerman&(keyword? (symbol ":foo"))
11:46sexpbot⟹ false
11:47angermanhm.
11:47clgva symbol is not a keyword
11:47clgv&(keyword? (resolve (symbol ":foo")))
11:47sexpbotjava.lang.SecurityException: You tripped the alarm! resolve is bad!
11:48angermanclgv: i'll just go with :: :D
11:48angerman&(keyword ":foo")
11:48sexpbot⟹ ::foo
11:48clgv&::foo
11:48sexpbot⟹ :clojure.core/foo
11:49clgv&:::foo
11:49sexpbotjava.lang.Exception: Invalid token: :::foo
11:49angerman&::::foo
11:49sexpbotjava.lang.Exception: Invalid token: ::::foo
11:49angermantoo bad :D
11:49hvFossi: thanks. that's unfortunate that JRebel is not open source :(
11:49angerman&::-::foo
11:49sexpbotjava.lang.Exception: Invalid token: ::-::foo
11:49clgvangerman: I guess you violate conventions with (keyword ":foo")
11:51angermanclgv: I assume I can live with that for now.
11:51clgvwhy do you need the extra ":"?
11:51angermanI get the :… stuff from the database.
11:51angermandon't really want to strip the first character prior to converting it to a keyword.
12:05samlhow can I install clojure?
12:05angermansaml: define "install"
12:06samli downloaded clojure jar and contrib jar and put it on ~/opt/clojure/
12:06samlI'm trying to run sexpbot .
12:06samljava -cp lib/*:src/:resource clojure.main -e "(use 'sexpbot.run) (-main)"
12:06angermanahh ok.
12:07amalloycemerick: clojurescript too, right?
12:07angermanwell you need $ java -cp ~/opt/clojure/clojure.jar:~/opt/clojure/clojure-contrib.jar:lib/*:src/:resources clojure.main -e "(use 'sexpbot.run) (-main)" then.
12:08jlftechnomancy: nathanmarz resolved the previous missing dependency issue with the cascalog package, but the next issue is a "org/apache/hadoop/conf/Configuration [Thrown class java.lang.NoClassDefFoundError]" exception when i do (use 'cascalog.api). is this another package issue, or do i need to manually add the location of my local hadoop installation to my classpath in package.clj?
12:08angerman(e.g. clojure and clojure-contrib should be in you classpath)
12:08amalloysaml: cake deps will download sexpbot's dependencies, including clojure
12:08jlfor anyone... :)
12:08samlah i see
12:08chouseramalloy: clojurescript is something else. Clojure semantics, not JS semantics.
12:08samlis cake recommended over lein?
12:09clgvhow can I access the meta-data of a function that I passed into another function?
12:09amalloysaml: by cake users, yes. by lein users, no
12:09amalloyit's pretty split
12:09samlhow about by clojure users?
12:09amalloyfor specifically sexpbot i'd suggest cake
12:09amalloyi doubt it matters, but that's what all the sexpbot devs use
12:09samlis cake ruby?
12:10amalloycake is clojure with a thin layer of ruby, like lein is clojure with a thin layer of bash
12:13technomancyjlf: I'd be surprised if you were meant to manually tweak things around like that, especially if the readme doesn't make it clear. I suspect it's another case of misdeclared dependencies.
12:13technomancyodd that cascalog would be so delinquent in this regard; I've heard good things about it. =\
12:14amalloyjlf: i had a similar problem using cascalog, and added hadoop to my deps
12:14amalloyi think the reason is so that it will work with whatever version of hadoop you want, rather than depending on version x
12:15technomancythen again, these kinds of problems do remind me of the brief time I spent investigating the hadoop ecosystem. =\
12:15samlCaused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission createClassLoader)
12:15samlwhen I run sexpbot
12:15jlfis there no way to express version ranges in lein dependencies?
12:15amalloysaml: did you read the readme?
12:15amalloy[clojure "[1.2.0,1.3.0)"]\
12:16samlamalloy, do you think it's mongodb?
12:16samli thought i removed all plugins that use mongodb
12:16jlfamalloy, technomancy: thanks, i'll try adding the hadoop dependency manually for the moment and report to nathanmarz as well
12:17Raynessaml, amalloy: #sexpbot
12:17amalloysaml: no, it's the jvm sandbox
12:23jlftechnomancy: hmm, i noticed that running deps from lein interactive doesn't seem to check for updated dependencies in project.clj
12:24technomancyjlf: deps doesn't auto-trigger unless lib/ is empty
12:24technomancythough there's code to turn that on in the latest version; disabled by default since it's fairly untested
12:25jlfi'd expect deps to rescan project.clj dependencies if its mtime has changed since last invoked
12:26technomancyjlf: it checksums the value of the :dependencies map if you turn this option on
12:26jlfah ok
12:27technomancy:checksum-deps true in project.clj; will probably be default in 2.0
12:28jlfnice, ty
12:29angermanyikes.
12:29angermanSandbar is _very_ strange.
12:30ev4lgood morning everyone
12:30ev4lanyone know an easy way to perform the following operation:
12:31ev4li'd like to merge to seqs ("aaa" "bbb" "ccc") and ("111" "222" "333") into a vector of vectors: [["Aaa" "111"] ["bbb" "222"] ["ccc" "333"]]
12:31ev4lis there some sort of "vector-interleave" function for it?
12:31amalloy$google transpose in clojure
12:31sexpbotFirst out of 243 results is: Matrix transposition - Rosetta Code
12:31sexpbothttp://rosettacode.org/wiki/Matrix_transposition
12:31amalloyev4l: ^
12:32amalloy&(vec (map vector '[a b c] [1 2 3]))
12:32sexpbot⟹ [[a 1] [b 2] [c 3]]
12:33ev4lamalloy: thanks! i need to get some speed with this seq transformations
12:49angermanwe'll get rain… the local rainman is drumming again...
12:49angermangrr.
12:50amalloyev4l: do you mean, the seq transformation needs to be fast; or, you need to get familiar with seq transformations so you can write them quickly?
12:50ev4lamalloy: the latter one. :)
12:51ev4lamalloy: pretty ambiguous statement..haha
12:54DeranderRaynes: sorry :-(.
12:54RaynesDerander: I don't mind. Like I said, it was just an observation. :p
12:55samlis there a collection of good clojure snippets? to show off people
12:57dakronesaml: clojuredocs.org has short snippets for examples for functions, if that's what you're looking for
12:58amalloyrosettacode has some, of highly variable quality
12:58amalloy$google rosettacode clojure fibonacci
12:58sexpbotFirst out of 39 results is: Fibonacci sequence - Rosetta Code
12:58sexpbothttp://rosettacode.org/wiki/Fibonacci_sequence
12:59samlthanks dakrone and amalloy
13:18clojure-ludditeok, I haven't touched clojure for a while now. turns out clojure development moved from svn to git, development sites went through google code, assembla, jira, and what not. in github the repositories were changed for clojure and contrib, and the old ones are still what google returns on the top. the docs are totally out of date everywhere, including the very nice clojuredocs. it seems there...
13:18clojure-luddite...are multiple schemes for fetching jars and building projects, and every project adheres to only one of those schemes. contrib has been split, rearranged, moved, and some of it imported into core (docs not included). sure, I like it that clojure is innovative and cutting edge, but right now it's a moving target I'm sure even the best of us can't hit. simple file utils went from duck-streams to s
13:18clojure-ludditeomething else to contrib.io to java.io to who knows where, and I can't find the freaking latest read/write-lines functions. can anybody help find them before I lose it?
13:18clojure-ludditesorry /rant
13:20clojure-ludditeso, anyone knows where I can find the latest read/write-lines?
13:20technomancyread-lines was dropped because it's a common cause of resource leaks
13:21clojure-ludditeso what's the up to date idiomatic way to lazily read lines from a file?
13:22dakrone,(doc line-seq)
13:22clojurebot"([rdr]); Returns the lines of text from rdr as a lazy sequence of strings. rdr must implement java.io.BufferedReader."
13:22technomancyneed to use with-open+reader to manage the scope of the file opening yourself
13:23clojure-ludditewas the reader fn that automatically sets up the reader also dropped?
13:23ampleyflytechnomancy: are you aware of any problems with running "lein plugin install swank-clojure 1.3.0" on windows? yesterday, I got the message that the jar could not be found in any of the places tried (like clojars, I presume)
13:24dakroneclojure-luddite: (with-open [r (clojure.java.io/reader "/tmp/foo")] (doall (map println (line-seq r))))
13:25drewrdakrone: doseq println please :-)
13:25dakronedrewr: right, my mistake :-/
13:25clojure-ludditedakrone: wasn't the all purpose of the read-lines to do just that?
13:25technomancyampleyfly: weird, my push didn't seem to go through last night; re-pushed
13:25technomancythanks for the heads-up
13:26ampleyflythat explains it =)
13:27dakroneclojure-luddite: you're welcome to do (.split (slurp "/tmp/foo") "\n") if you need something simpler
13:28technomancyclojure-luddite: the difference is that read-lines closes the file non-deterministically
13:29technomancywhereas with-open makes the scope explicit
13:30devnsomeone who writes clojure, but only with pen and paper, not none of them newfangled computar(sic) contraptions
13:33alpheusThat's honestly the way I learned C. Had a book, couldn't afford a computer.
13:36sritchiealpheus: that's the way I went through The Little Schemer
13:37sritchieI've been working my way through the exercises in SICP, too -- I do them all by hand, and type them in later, when checking answers
13:46Lulu58e2sritchie: by "hand"? Is that a new language?
13:46devn*nod* yeah I'm not making fun of that approach -- i've used it as well, but i find the REPL feedback loop to be really instructive
13:46Lulu58e2;)
13:46sritchieLulu58e2: haha, felt like it at first
13:47sritchiedevn: definitely! The repl's been amazing, switching to clojure. we can't all be don knuth
13:49Lulu58e2I feel more like Don Knotts most of the time
13:52angerman&(case (keyword ":foo") ::foo "Hi" "Ho")
13:52sexpbotjava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.MapEntry
13:56amalloy,(case (keyword ":foo") ::foo "Hi" "Ho")
13:56clojurebot"Ho"
13:57amalloyangerman: there's something wrong with sexpbot's macroexpansions in certain cases; i'm still not sure why
13:58hiredman,::foo
13:58clojurebot:sandbox/foo
13:58hiredman,(keyword ":foo")
13:58clojurebot::foo
13:58angermanamalloy: hehe :)
13:59angermanstill sad that (keyword ":foo") != ::foo
13:59amalloyangerman: that is not sad at all
13:59angermanamalloy: sad for me :)
14:08amalloyangerman: sad only if you are crazy. (keyword ":foo") properly "should" throw an exception, but its error handling is minimal
14:10ataggartamalloy: it's not clear to me why a keyword's name should be constrained to only those which can be literally represented.
14:19kumarshantanuhi, is it possible to access `this` object in (proxy ...) ?
14:19hiredman,(doc proxy)
14:19clojurebot"([class-and-interfaces args & fs]); class-and-interfaces - a vector of class names args - a (possibly empty) vector of arguments to the superclass constructor. f => (name [params*] body) or (name ([params*] body) ([params+] body) ...) Expands to code which creates a instance of a proxy class that implements the named class/interface(s) by calling the supplied fns. A single class, if provided, mu...
14:21dnolen,(keyword (str *ns*) "foo")
14:21clojurebot:sandbox/foo
14:21dnolen,(doc keyword)
14:21clojurebot"([name] [ns name]); Returns a Keyword with the given namespace and name. Do not use : in the keyword strings, it will be added automatically."
14:22dnolenangerman: ^, that doesn't work for you?
14:33dnolenI don't suppose anyone here's read the Dybvig Subcontinuations paper.
14:37devnamalloy: the more i look through your utils the happier i am -- im looking through my projects and adding to a devn/utils.clj || devn/utils/macros.clj
14:38devnin a fork
14:38amalloydevn: glad to hear you have your own utils. what do you mean by "in a fork"?
14:39devni forked the project and am adding mine in a devn.utils ns -- not sure if you'll want to pull them back in, but i figure it could be neat to generalize the project and make it a mix of different clojurians' utils
14:39devnso i could do dnolen.utils, amalloy.utils, etc.
14:39amalloyinteresting
14:40amalloyi hadn't thought of that, and i think it would wind up with somewhat too much bloat if it caught on, but as long as it's unpopular it's pretty clever :)
14:40devnhaha yes i was just thinking the same thing
14:41devnhowever, with judicious pull requests it could mean that duplicated effort is not cool
14:41devni phrased that wrong: what i mean to say is, generalizing the project to make it less specific to one person and making it sort of a swiss army knife of things that aren't in contrib, could be cool
14:42dnolenwow, Simon Peyton Jones, Amr Sabry, Dybvig: A Monadic Framework for Subcontinuations (2005).
14:42devneven if it was a giant project, if it was well-organized by category, it could be a really useful set of things which dont fit in contrib
14:42technomancyisn't contrib just a set of things that don't fit anywhere else? that didn't work out so well.
14:43jlfamalloy: btw adding the hadoop dependency resolved the issue, cheers
14:44devntechnomancy: how did contrib not work out?
14:46amalloydevn: it's being modularized for 1.3
14:47devnwow...someone is out of the loop
14:48amalloyno kidding
14:48devnouch
14:51devntechnomancy: well, im not acting like it's revolutionary -- but it would mean a bit less ceremony for people to just drop a nice resuable function in here and there
15:21devni think i killed chat
15:33amalloydevn: looks like you deleted the fork and created a separate repo?
15:34not-timmcWatching from over here in my don't-hide-even-JOINs-and-PARTs account, I now see that empty conversational space is in fact filled with virtual users popping into and out of existence.
15:39devnamalloy: i did
15:39devngoing to roll my own amalloy
15:40amalloyvery well...only know, you can never equal the true amalloy!
15:40devni have like 50-60 mini toy projects that have snippets here and there, just spending the rest of the day walking through them and compiling what I like
15:40devnamalloy: :D
16:03mecAny thoughts on making this implementation of life a bit faster? Currently it takes about 1/4 of a second to iterate https://gist.github.com/885740
16:05raekyou are dereferencing the world a lot (not a very expensive operation, maybe). any reason why you don't swap! instead?
16:07amalloyreset! is crazy when the new state depends on the old state, even if it won't improve performance to change to swap!
16:08mecI checked and dereferencing once vs for each cell makes no difference.
16:08mecI suppose I could switch to swap! but then i'd have to pass world to all the functions
16:08raek(using reset! that way is unideomatic, that's all)
16:09amalloythe horror. those functions all depend on the world; you're just pretending they don't by making the world a global
16:09dnolenmec: you should expect any game of life implementation written that way to be slow.
16:09dnolenmec: https://gist.github.com/420036, similar and can do 2000x2000 in 480ms.
16:09mecdnolen: thanks i'll have a look
16:11brehautdnolen: thats 1.3 code?
16:11dnolenbrehaut: pretty sure 1.2
16:12brehautso it is
16:12raekprotocols supported primitives, but not functions?
16:12raekhrml, that makes sense, though
16:13dnolenraek: protocol don't support primitives.
16:13raekah, definterface, I see
16:14brehautah right. thats where i went wrong too
16:14mecis this better? https://gist.github.com/885740
16:18amalloymec: next-world isn't passing along the world arg
16:19mecya i fixed those
16:21meci was hoping i could get next-world faster with pmap, but it was actually slower
16:21amalloyso this is not at all a performance issue, and really kinda questionable style advice too, but you could avoid repetition by defining update-cell as (apply alive? (map #(% world x y) [cell neighbors]))
16:25amalloyerrr, ends with [count-neighbors get-cell]
16:25mecdnolen: how come cells is defined as ^longs ^longs but only ever used as a plain array
16:25amalloyor the other way round, whatever. you see what i mean, i hope
16:26mecamalloy: less repetition but harder to comprehend i think
16:26amalloyup t'you
16:26amalloyactually that map is a little more verbose than necessary: ((juxt get-cell count-neighbors) world x y)
16:27amalloywhich is basically what juxt is for
16:27mecnow thats not bad
16:28amalloytechnomancy, raek: we have another juxt fan
16:28raekamalloy: :)
16:28raeknice fit
16:33dnolenmec: what do you mean used as 'plain array' ?
16:34mec(aget cells n)
16:36dnolenmec: that's how Clojure array support works. i.e. aget-long would be wrong and slow.
16:36mecIs there any difference using ^longs ^longs cells over ^longs cells?
16:37dnolenmec: multidimensional array access is slow.
16:37brehautdnolen: i think mec is talking about your type hint on line 12
16:38dnolenheh, typo
16:38dnolenfixed
16:38mecah
16:39mecI couldnt figure out why it was hinted as a 2 dimensional array but built and accessed as one dimensional
16:39dnolenmec: yeah sorry about that.
16:40dnolenwhile I'm at it: defrecord -> deftype.
16:40dnolenno need for defrecord here.
16:41brehautdnolen: can you explain that distinction a bit more?
16:42dnolenbrehaut: between deftype and defrecord?
16:42mecyes please
16:42brehautyeah, in particular in this context
16:43Licenseraloa
16:44dnolendefrecord creates fields for metadata and an extension map, not required here. It also declares a lot of unnecessary methods.
16:44brehautthanks
16:47mecNow some UI code, be gentle its my first time ;p https://gist.github.com/885740
16:50mecAlthough it is somewhat copied from the ants demo
16:56brehautmec, you've copied an old style meta hint for Graphics
16:56brehautjust use a hat, you dont need the hash any more
16:57brehautmec (line 53)
16:57mecthanks
16:58mecwas thinking that was in 1.3 for some reason
16:58brehautmy memory of these things is shaky, but i think its 1.2
16:59mecya it works fine
16:59amalloybrehaut: i think that's correct, but i've never written any 1.1 code
17:00brehautmec asside from being a giant bag of globals your swing code is as decent as swing code normally gets :P
17:01mecHows the bottom there? I was using agents like in the original ants, and I just kind of guessed at how to correctly do this
17:01mecwith futures
17:01brehautlooks fine
17:01amalloyaugh dorun/for. plz use doseq
17:03mecthanks I can never remember which combination that is
17:03amalloyre: globals, this code seems pretty easy to wrap up into a big let instead
17:04brehauti think that (dorun (for is another artifact of the ants demo being such old code
17:04mecis there a shortcut for doall/for
17:05brehauti think that would also be doseq
17:06brehautit just makes you be explicit that its side effecting (because it doesnt return the head)
17:06CaffeineI'm writing my first potentially big enough Clojure program and I'm wondering if there is a commenting convention for documentation production, like what is JavaDoc to Java.. ??
17:07mecI think the autodoc for like http://clojure.github.com/clojure/clojure.core-api.html is just the function comments
17:08_atoCaffeine: do you mean like /** ... */ ? Clojure has explicit docstrings, eg (defn foo "Docs go here" [])
17:09semperosyou can use marginalia and include comments in markdown format, both in your function docs and throughout your code base
17:10semperoshttps://github.com/fogus/marginalia
17:10technomancy_ato: thanks for the thorough reply re: clojars ops =)
17:11Caffeine_ato: ahh I think that's what I'm looking for
17:12_atotechnomancy: no worries. I'm not too good at documenting things until someone asks me :p
17:13Caffeine_ato: semperos: I know how to make comments, but I want the standard Clojure way of documenting, so that it's conform and that I could eventually generate documentation .. kindof javadoc but not necessarily that.. dunno how that would be called for clojure... ClojureDoc?
17:13semperosmarginalia generates documentation
17:13tsdhIf I have a seq of 1-ary predicates, how can I combine them using AND into one function?
17:13semperosit's not formatted like javadoc, but it's worth a look to see if it suits your needs
17:13Caffeinesemperos: ok good, thanks!!
17:14semperosnp
17:14_atoCaffeine: also have a look at http://tomfaulhaber.github.com/autodoc/
17:14Caffeineyeah it should be okay, I don't need any particular format, just good looking.. better looking than through code, that is
17:14Caffeine_ato: ok thanks
17:14semperosautodoc is what is used for the official api docs, whereas marginalia is like read through your code with help; you probably want autodoc
17:15semperos*like reading
17:15Caffeineahh probably then
17:15mectsdh: #(apply and (apply juxt predicates) %)
17:16tsdhmec: I've thought it would be something with juxt. :)
17:16brehauton #clojure its always something with juxt
17:17mechmm that doesnt quite work because and is a macro
17:17brehaut#(and %&)
17:18amalloymec: http://groups.google.com/group/clojure-dev/browse_thread/thread/899349c6a9b526e0/41f1a8012f861309?show_docid=41f1a8012f861309
17:18amalloybrehaut: that function is equivalent to identity
17:18amalloyoh, and tsdh also, ^
17:18brehautoh so it is
17:19tsdhI've just got aware of that...
17:19mecidentity would work, it doesnt handle varargs
17:20mecr/would/wouldnt
17:20brehautmec, amalloy is pointing out that due to the magic of macros etc, that function i wrote is just an identity
17:20amalloymec: my point is that brehaut's implementation doesn't work. it's not *exactly* like identity, but it's close
17:20brehautit doesnt actually apply and
17:20amalloyit's more like (complement (comp zero? (comp count list)))
17:20brehaut(or more correctly, it applies and but its not what you think)
17:20amalloyie, "true iff you pass at least one arg"
17:21amalloynot sure why i used two comps, there
17:21amalloy(comp pos? count list)
17:21tsdhmec: Then I'll use this AND: #(if %1 %2 false)
17:22amalloytsdh: #(when %1 %2)
17:23mec(fn [arg] (reduce #(and %1 %2) ((apply juxt predicates) arg)))
17:23mec(fn [& predicates] (fn [arg] (reduce #(and %1 %2) ((apply juxt predicates) arg))))
17:24tsdhOh, that's nice.
17:24meclol i just opened that page amalloy linked, its almost exactly that
17:25mec(defn conjoin [& preds] (fn [& args] (every? (fn [arg] (every? #(% arg) preds)) args)))
17:25brehaut&(apply every? identity ((juxt (constantly true) pos?) 1))
17:25sexpbotjava.lang.IllegalArgumentException: Wrong number of args (3) passed to: core$every-QMARK-
17:26brehaut&(every? identity ((juxt (constantly true) pos?) 1))
17:26sexpbot⟹ true
17:26brehaut&(every? identity ((juxt (constantly false) pos?) 1))
17:26sexpbot⟹ false
17:31amalloyi've finally figured out a way to use paredit-convolute-sexps!
17:32amalloyit makes it easier to turn (if test (f a1 a2 special-value) (f a1 a2 other-value)) into (f a1 a2 (if test special-value other-value))
17:33brehautthats cool
17:34mecall I can do is move parens around, i havnt figured out how to move sexprs
17:34amalloymec: with paredit mode, you're not allowed to move parens anymore :P
17:34mecwhat do you mean? thats all I use paredit for
17:35amalloyi mean, all of the paredit functions operate on sexps. that happens to cause parens to move around in some cases, but you're always working with sexps
17:36amalloymaybe it's just a spiritual thing, i dunno
17:37meclol all i have interned is C-<left> and C-<right>
17:37pauldoowhen inside a transaction, is there a way to 'deref' but without without the guarantees of the transaction? I.e. I want to get some value out the ref, but don't want it to cause my transaction to fail on commit
17:37brehautmec learn M-s and C-k next
17:38amalloyeg paredit-forward-slurp-sexp doesn't "move a paren forward", it "modifies current sexp to include next sexp, then deletes next sexp"
17:38amalloybrehaut: i rarely use M-s
17:38TimMcmec: C-M-k kills the next form. Very useful.
17:38amalloyM-<UP> ftw
17:38mecoo how do you kill previous
17:38pauldooI guess I can deref before entering the transaction and grab the last comitted value, and then use that inside the transaction
17:39pauldoojust wondering if I can do that from inside the transaction
17:39mecyou can deref inside a transaction to grab the latest if you're retried
17:39amalloymec: i don't think paredit has a command for that. you don't really need it
17:40mecamalloy: right M-<UP> is what i wanted
17:43amalloymec: M-<DOWN> and M-r are similar to that, if you want to do something slightly different
17:44mecmy m-l and m-r just move the cursor a word
17:45amalloyM-r, really?
17:45brehautmy problem with paredit is that ive interned enough of it to be useful (and so that i dont have to reference the cheat sheet) but ive forgotten what i havent interned
17:45ejacksonbrehaut: I even have the damned cheatsheet on my desk, and fail to look at it.
17:45amalloytry C-h k m-r, or C-h f paredit-raise-sexp
17:46meci gave up trying to remember too much, it takes more time to look it up than just do something by hand
17:46amalloythose two should be bound to each other
17:46meca ya m-r does
17:52amalloybrehaut: if you find yourself wondering whether paredit can do X for you, try C-h f paredit-<TAB>, maybe?
17:52brehautamalloy: its not that i wonder, its that i dont wonder. im using it to half efficiency but its so much more efficent than not that i never stop to learn more
17:53amalloyfeh. always wonder. improve your tools. various curmudgeonly unhelpful advice
17:54brehautim sure ive mentioned my non-tool-using monkey ways before. i spent my time wondering about my code and not about the tools.
17:54brehautand despite trying a lot, i cant seem to rewire my brain to think about both
17:55Licenserclojure is pretty darn sweet for sysadmin tasks :D
17:56ejacksonLicenser: despite the startup time ?
17:56Licenserejackson: yap doesn't matter
17:56ejacksoni guess if its cron, who cares ?
17:57LicenserIt's a data collection task
17:57Licenserso even 1m startup won't be trouble
17:58LicenserI've a program to ssh to multople hosts, run commands collect the results and evaluate the output
17:59mecDo I still use proxy for an abstract class?
18:01Licenserhttps://gist.github.com/51d43bff9d076d36f4f3 < reads ifconfig -a and parses the interface details
18:01Licenserdarn easy :)
18:07amalloymec: reify
18:07amalloy(that is, you *can* use proxy, but reify is much lighter-weight and usually suffices)
18:08mecreify doesnt allow abstract classes
18:11amalloyreally?
18:11amalloy&(doc reify)
18:11sexpbot⟹ "Macro ([& opts+specs]); reify is a macro with the following structure: (reify options* specs*) Currently there are no options. Each spec consists of the protocol or interface name followed by zero or more method bodies: protocol-or-interface-or-Object (methodName [a... http://gist.github.com/886009
18:12mecdeftype is the same way
18:12amalloyclojure's big "screw you" to implementation inheritance i guess
18:13mecThey throw an exception if you call a method from an interface that isnt explicitly defined right?
18:13TimMcamalloy: Rich was pretty clear on that in one of his talks.
18:14amalloyTimMc: sure, and i'm happy to not be allowed to define abstract classes
18:14amalloybut it seems like the definition of reify (both in english and in clojure) is compatible with an abstract class
18:15mecwell for swing I either proxy WindowAdapter or reify WindowListener and have to specify all the methods myself
18:17TimMcI haven't done much work in Clojure that requires a bunch of functions to all operation on the same custom data structure, but namespaces seem to work fine.
18:19amalloyTimMc: it seems to me that you are arguing against a point nobody is making
18:20TimMchaha
18:33amalloyyou have to wonder how anyone could write the WindowAdapter class and not ask themselves "is my language so lame that i really have to do this?"
18:42ossarehmorning
19:00amalloywow, immutability has gotten really deep in my head. i saw the following PHP (no, no idea what the code is actually for) and was sure it could never terminate: while (isset($PROFS[$desc]['end'])) {$desc .= '*';}
19:01dnolenfinally something worth using clj-cont for, nestable engines / coroutining.
19:11TimMcamalloy: Well, it was an issue I ran into with Javascript, for instance.
19:11TimMcI'm delighted that I haven't had the same problem yet in Clojure.
19:11amalloywhat issue/problem?
19:14TimMcNot having a good way of organizing a group of functions that all operate on the same custom data structure.
19:14TimMcNone of the techniques I tried in JS was very satisfying.
19:26lucianTimMc: uh, classes?
19:26TimMclucian: In JS?
19:26lucianTimMc: sure. they're just more verbose to write
19:27lucianlook at CoffeeScript's classes
19:27luciannote what they compile to http://jashkenas.github.com/coffee-script/
19:27TimMcWell, that's not raw JS.
19:27luciandoesn't matter, you can write the raw js if you want
19:27lucianor you can use one of the many (and tiny) libraries that can do that for you
19:28lucianbut really, there's no reason not to use CoffeeScript if you like
19:28TimMcMy experience with JS predates CoffeeScript. :-)
19:29TimMcI may investigate it.
19:59TimMcAnyway, I now find it convenient to represent a "class" as a namespace full of constructors, accessors, and other methods. Then I (:require [class :as c]) so can do (c/constructor ...) etc. Seems to be a useful and natural pattern.
20:09amalloyTimMc: why are you doing this kind of oop in clojure? interop or something?
20:09TimMcNah, it just seemed natural a couple of times.
20:10amalloyi'd like to take your word for it, but criticism and evangelism are so much more fun :)
20:10TimMc:-)
20:12TimMcTo use a weak but close at hand example, I had a representation for triangles in my 3D rendering program. I wanted to keep implemenation details from leaking to the rest of the program, so I kept them in one namespace: https://github.com/timmc/CS4300-HW4/blob/master/src/timmcHW4/tri.clj
20:13TimMcAs it turns out, I'll probably need to redo the implemenation drastically for HW5, so this abstraction barrier may have to fall anyway.
20:15amalloyi'm not against this sort of separation of concerns. i thought you actually meant (defn constructor) and other gross OO stuff like mutators
20:16amalloyand +1 for the unicode. i intend to configure emacs to let me type in that crap more easily sometime
20:16amalloy(good idea or no)
20:17FrozenlockGreetings gentlemen, I'm currently trying to install clojure with swank and slime. I downloaded swank with the ELPA, but now that I'm trying to M-x slime, I'm unable to get the swank-clojure jar file. "byte-code: Failed to download Clojure jars." I would be very grateful if one of you could give me a hint on how to proceed.
20:18technomancyFrozenlock: the swank-clojure readme should have you covered; short version is instead of M-x slime you use lein swank plus M-x slime-connect
20:20FrozenlockOh thank you, I'll read that right away
20:20no_mindis there a way to have dynamic routes in compojure instead of hardcoding the routes in a function ?
20:21brehautno_mind: what do you mean by 'dynamic' ?
20:22no_mindbrehaut, I want to define a ogic in which based on the url, the application should dispatch the request to suitable module. for eg. a url abc.com/home/add should call add function in a module called home
20:23brehautogic ?
20:23amalloylogic, smartypants
20:23brehautoh right :)
20:23brehauti thought it was an abbreviation i didnt know
20:24amalloysometimes i wonder if "logic" is something i don't know about
20:24hiredmanno_mind: https://github.com/hiredman/graft
20:26hiredmanhttps://github.com/hiredman/place-for-things
20:27technomancyhiredman: ITYM "utils"
20:27technomancyoh wait, nm
20:27hiredmanI know what you meant
20:27technomancyI thought "place-for-things" was your "bucket-o-stuff" repo
20:29brehautdo you attach an arbitrary ring handler into a compojure app?
20:30brehautcan you just put it in place of the (GET whatever) ?
20:30hiredmanI donno
20:30hiredmandunno
20:30brehautno matter
20:30hiredmanI haven't done any compojure in maybe a year or more
20:31brehautneither. i switched to moustache and never looked back
20:39ossarehbrehaut: what are the key differences between moustache and compojure? I took your advice on the enlive vs hiccup and chose enlive and <3 it a lot.
20:39brehautossareh: much smaller than between enlive and hiccup
20:39ossarehyou mean the reasons are?
20:40brehautthe difference sorry
20:40brehautthey both achieve very similar things
20:40brehautand through quite similar mechanisms
20:41ossarehi've been butting heads with compojure in a few ways recently - most notably I want email addresses in my routes and I need to supply a regexp to clout to get that to work.
20:42brehautthe biggest differences as far as i can see is that moustache's RHS of a route basically has to be a ring handler function, whereas compojure has a lot more flexibility there
20:42brehauti think in terms of actually routing facilities the two are about equal
20:43brehautbiggest difference is that moustache requires a vector of rules to match, whereas clout has some sugar to let you use a string
20:44brehautpersonally i have a preference for moustache's simplier apps; its very clearly glue for ring handlers
20:45brehautossareh: heres a very simple example https://github.com/LauJensen/SocialSite/blob/master/src/socialsite/core.clj#L83-96
20:53technomancyis compojure mostly just routing?
20:54brehauttechnomancy: give or take yeah
20:54brehautall the non-routey stuff got extracted out into other libraries (including the routing engine 'clout')
20:55brehautit knows how to take a bunch of different types of things and turn them into responses, and has some utilities for applying middleware too
20:58TimMcamalloy: In Ubuntu (probably thanks to GNOME) I just use C-S-u and type the hex code for Unicode -- works in Emacs and everything. In this case, I used copy and paste. :-P
20:59amalloythat's control-super-u?
21:00amalloydoesn't do anything for me
21:00TimMcCtrl-Shift-u
21:00TimMcC-U, sorry
21:00technomancyM-x ucs-insert if you want to use the code-point's name
21:01technomancy‽ is especially handy for functions that are destructive but also happen to be predicates
21:01amalloy*laugh*
21:01hiredmanwow
21:02hiredmangrowl rendered that as an alpha and an omega
21:02technomancyyou and your ridiculous MacRoman.
21:02amalloy(defn was-eaten‽ [atom] (reset! atom nil) true)
21:03amalloyaw, i forgot to write "eat it" in there, whatever
21:09ossarehI kinda sorta hate AOT.
23:27devn*goal*
23:44amalloydevn: you could probably list all existing namespaces and require them all
23:46_atodevn: if you write a program that uses every core function purposely (like it actually achieves something useful with each) I will be extremely impressed :D
23:46_atofor the ultimate challenge use every core function exactly once
23:47devn_ato: I was thinking I might start with the cheat sheet
23:47devnand then work my way out
23:47devnHow many core functions (that are usable) are there?
23:47devnand by usable I mean "regular" and "occur in regular programs"
23:47devnI think it's somewhere around 4-600?
23:55amalloydevn: heh. 4 <= x <= 600? surely you can manage a smaller window than that