#clojure logs

2011-01-19

03:51_na_ka_na_hey guys can I get a reference to the thread-pools that Clojure creates?
03:51_na_ka_na_for the futures & agents
04:15amalloy_na_ka_na_: it's probably using java.util.concurrent.xxx classes
04:30Licenserdun dun dun
06:29bartjwhat does ::blah mean in Clojure?
06:30bartjunforunately, Google cleans up the query clojure "::"
06:30raekif you are in the namespace "user", it means :user/blah
06:31raekif you have required foo.bar.x with the alias x, ::x/blah means :foo.bar.x/blah
06:34bsteuberany ideas on why this might give a VerifyError on some machines? https://gist.github.com/786039
06:35bartjraek, can you please point me to some documentation on that?
06:36raekbartj:
06:36raekhttp://clojure.org/reader
06:37raekthe doc is not very detailed for this feature
07:03clgvFor a Swing Tree control I want to build a structure of tree nodes. The control will (indirectly) call GetChild(this, index) on a deftype I wrote. Straightforward, I could just return a new tree node on every call but that isnt very elegant.
07:03clgvFurthermore I need the special deftype to map datatypes to the appropriate tree nodes
07:05clgvI know the proxy style creation of protocol implementations within functions where I can use let before the proxy statement. but this way I wont have a class for the above mentioned mapping
07:05clgvThere is only one way that comes to my mind to solve this right now. using factory functions instead of the classes in the above mentioned mapping
07:07clgva constructor method for a deftype would also solve the problem, if I could implement it so that it creates the constant tree nodes ...
07:17fbru02_hey guys i have this (def datas (atom {:a #{ "a"}}) .. how do i swap! a new value (using conj?) in the set ?
07:17fbru02_been playing with that but couldn't make it
07:20hoeckfbru02_: (swap! datas update-in :a conj "b")
07:20Chousuke(swap! datas update-in [:a] conj "foo")
07:20hoeckah right, forgot the [ ] around :a
07:20clgv,(let [data (atom {:a #{"a"}})] (swap! data update-in [:a] conj "b"))
07:20fbru02_hoeck: Chousuke : nice ! didn't have that idiom !! sweet
07:21clojurebotExecution Timed Out
07:21Chousukechaining the update functions is fun
07:21clgv$(let [data (atom {:a #{"a"}})] (swap! data update-in [:a] conj "b"))
07:21clgvthe bots dont like me... ;(
07:22Chousukeweird.
07:23clgv##(let [data (atom {:a #{"a"}})] (swap! data update-in [:a] conj "b"))
07:23sexpbot⟹ {:a #{"a" "b"}}
07:23clgvah now ;)
07:28raekclgv: &, not $ (I often forget that too)
07:28clgvthx, raek :)
07:31clgvok, I am using factory-methods and reify now, for the problem I mentioned before
08:21LauJensenAny low-level brutes in here ?
08:25LauJensennvm
08:25LauJensenthe brutes may rest
08:29clgvlow-level brutes?
08:33LauJensenclgv: I need some education on low-level communication with usb devices, but Ive found it elsewhere
08:34clgvok, I didnt know who to make sense of that "nickname" before ;)
08:35clgvs/who/how/
08:35sexpbot<clgv> ok, I didnt know how to make sense of that "nickname" before ;)
08:44ordnungswidrig(let [a (agent 3)] (send a (fn [a s] (* s 2))) (await a) (prn a))
08:44ordnungswidrigwhy does this block?
08:45clgv&(let [a (agent 3)] (send a (fn [a s] (* s 2))) (await a) (prn a))
08:45sexpbotjava.lang.IllegalArgumentException: Wrong number of args (1) passed to: sandbox6318$eval8426$fn
08:46ordnungswidrigI see, must be (fn [s] (* s 2)...
08:46clgv&(let [a (agent 3)] (send a (fn [s] (* s 2))) (await a) (prn a))
08:46clgvguessed so ;)
08:46sexpbot⟹ #<Agent@bab945: 6> nil
08:46ordnungswidrigthanks
09:17ordnungswidrigI have a list xs [1, 3, 4…] and an expression like (for [x xs] (do-something-with x)) how can I expand the "for" at compile time, so that I have (do (do-something-with 1) (do-something-with 3) (do-something-with 4))? I tried with macros but i failed
09:18chouserordnungswidrig: 'for' is lazy ... are you asking for something eager, with side effects, *and* unroll it at compile time?
09:20ordnungswidrigchouser:I don't care about lazyness. I need the list to be expanded at compile time.
09:21ordnungswidrigchouser: having the result of the expression as a sequence (lazy or not) gives bonus points
09:21chouserI'm still curious as to why, but realize that you need to have the value of xs at compile time to even consider this.
09:22tonylfor is already a form, name it differently
09:24ordnungswidrigchouser: I'll give you some background. I'm doing some experiments with "recording" clojure expression in a tx log so that I can "replay" those expressions later. That part is working fine. However the actual expression must be free from side effects. For testing I wanted to record expressions with some random values and look if certain invariants hold. But that means that the "randomization" must occur at compile time.
09:25ordnungswidrigI.e. there is a macro to evaluate and record an expression. I use it like this
09:26ordnungswidrig(logged (let [i (rand-int 100)] (alter foo + i) (alter bar -i)))
09:27ordnungswidrigI want to execute a bunch of them in parallel, so I thought of sending a bunch of those expressions to some agents for execution.
09:32clgvordnungswidrig: then you have to write a macro
09:35ordnungswidrighm, I think there is another problem. If I have an expression like (foo bar baz) and I wan't to "record" the evaluation then I must declare which expression of foo, bar and baz have to be evaluated at "recording time" and which have to be evaluated on "runtime".
09:36clgvI have an example for your first description
09:36ordnungswidrigIs there a clojure lib for expression rewriting?
09:36clgv(defmacro rand-ct [max] (rand max))
09:37clgvusing it gives random values on compile time
09:37ordnungswidrigclgv: exactly.
09:37clgvuser=> (macroexpand-1 '(rand-ct 100))
09:37clgv86.17588352116391
09:37clgvuser=> (macroexpand-1 '(rand-ct 100))
09:37clgv27.471785126598846
09:37clgvuser=> (macroexpand-1 '(rand-ct 100))
09:37clgv62.612066942592605
09:38clgvthere is the clojure.walk library that is also used from macroexpand-all
09:38ordnungswidrigclgv: but even this fails in my case because the expression (prn (rand-ct 100)) would be recorded, not (prn 5.8972348907)
09:38clgvbut I guess it's more general than expression rewriting
09:39clgvordnungswidrig: that is due to the definition of the surrounding expression
09:39clgvdid you define it yourself?
09:39ordnungswidrigyes
09:39ordnungswidrigI could go with the definition (logged [form & args]) where form would be recorded literally and args would be recorded evaluated
09:39clgvit's most likely a macro
09:39ordnungswidrigyes, it is a macro
09:40clgvwhats it's definition? you can rewrite it to do compiletime evaluation, most likely.
09:40ordnungswidrighttps://gist.github.com/534499f402463b935d62
09:41ordnungswidrigthe macro "logged" records the form to a vector ref and evaluates the form
09:42ordnungswidrigso after calling (logged (ref-set counter 0)) and (logged (alter counter inc)) the log contains [(ref-set counter 0) (alter counter inc)] (properly expanded with full namespace)
09:44clgvok the change would definitely involve some kind of expression rewriting
09:44clgvyou would have to search for the macro expressions you want to have evaluated at compiletime
09:46ordnungswidrigthe simplest solution would be to record only a function name and the arguments where the arguments would be evaluated at time of recording (runtime)
09:46clgvyou could try to take the definition of macroexpand-all and change it so it evaluates only specified macros
09:47ordnungswidrigI think that makes all this too complicated.
09:47clgvhttps://github.com/clojure/clojure/blob/c1c39162608551d50cfb18998d015974b11cfecc/src/clj/clojure/walk.clj#L127
09:48clgvit's definition is pretty simple
09:48ordnungswidrigI'll look into this
09:48clgvyou will have to replace the call to macroexpand
09:49ordnungswidrigOn the other hand I can live with sth like (logged #(prn (foo) %1 %2) (bar) (baz) where foo is evaluated at runtime and bar and baz are evalutated on "recording time"
09:49clgvjust to convince you: (prewalk (fn [x] (if (seq? x) (macroexpand x) x)) form))
09:49clgv;)
09:50ordnungswidrig*g*
09:51ordnungswidrigI' d have to invent some syntax to declare which form should be evaluated at recoding time: (logged (prn (at-recording (foo)) (bar) (baz))
09:51ordnungswidrigLike quote/unquote
09:52clgvnope you dont have to
09:52clgvyou could just provide a list of symbols
09:53clgveither to your macro or via thread-local binding
09:53ordnungswidrigthe same symbol might required to be expanded at runtime and at recording time
09:54ordnungswidrigI don't know if that would really be an issue.
09:54ordnungswidrigso far. thank you very much for your suggestions.
09:54clgvnp
09:55ordnungswidrigcu all
10:07phenom_hey, can anyone explain why the ants demo in scala performs much better than that of clojure ? I don't want to incite a riot but I'm new and I'd like to understand where to begin :)
10:10dnolenphenom_: I don't think the Scala version even does the same thing - it doesn't use STM right?
10:17no_mindwhat is the prefered way to develop a plugin based software using clojure ?
10:18clgvno_mind: good question. If you get no other answer, then you probably have to fall back to use java solutions
10:19no_mindclgv: kind of confused, should I use protocols ?
10:21clgvoh well, maybe you have to specify your problem in more detail. I was referring to the problem to be able to load implementation from specified locations (like a plugin folder)
10:22Raynesno_mind: Clojure's dynamic nature makes it relatively easy to develop plugin systems.
10:22RaynesBeing able to load and reload code on the fly and such.
10:22Rayneshttp://github.com/Raynes/sexpbot is entirely plugin based.
10:23RaynesIt's hard to answer the question, because plugin systems are very tailored to specific tasks, and thus I can't tell you how to design your own.
10:23no_mindclgv: the problem is not about dynamic loading, that is easy in clojure using s-expressions
10:26no_mindRaynes: I am looking for some sort of generic plugin/module based system. Something like hook based design of drupal
10:26Raynes$google technomancy Robert Hooke
10:26sexpbotFirst out of 25 results is: technomancy/robert-hooke - GitHub
10:26sexpbothttps://github.com/technomancy/robert-hooke
10:26Raynesno_mind: ^ Check that out. Could be what you're looking for. :)
10:26clgvno_mind: if you want to make your plugin interface more explicit I think using protocols is the tool. it's even easier to be able to write plugins in java then...
10:27clgvbut you dont need to use protocols
10:27clgv*in general
10:27no_mindclgv: Raynes actually i am exploring if ti is possible to allow plugin in any JVM language
10:28RaynesYes, it most certainly is. I've done it.
10:28RaynesCake and Leiningen both do it.
10:28no_mindRaynes: how ?
10:29no_mindRaynes: If I can write core in clojure and let my devs build plugins in PHP, it will a blessing ;)
10:29clgvPHP is a JVM language???
10:30RaynesProjects do it in different wants. sexpbot has a system for loading, reloading, and unloading arbitrary code. If code is on the classpath, it is really easy to work with it at runtime.
10:30RaynesOh.
10:30RaynesYou want to be able to do plugins in languages that aren't on the JVM?
10:31RaynesThat's a different level of difficulty. Never done anything like that, so I can't really help you there.
10:32jcromartieWould protocols/deftype be a good fit for building an associative data structure that tracks history over time?
10:32jcromartieBasically a sequence of "update" maps
10:32jcromartiewith timestamps
10:32jcromartieand maybe authors?
10:32no_mindRaynes: PHP is on JVm, though partially
10:41harishtellakinda off topic, but I'm wondering what other IRC channels you clojurians like to visit.
10:42robonoboclojurians? is that an official term?
10:42robonobobecause it sounds completely amazing
10:43harishtellarobonobo: haha, I think I saw it on one of the clojure meetup.com groups.
10:45octeis there a function for generating a map based on either a list of keys/values and then a generator function for the other part? i.e. the key/value
10:45jcromartieanybody want to comment on the design here? https://gist.github.com/202a9d047123fcb37f24
10:45chouserocte: there are a couple. zipmap and into are the favorites
10:46chouseroh, and (apply hash-map ...)
10:46octei thought zimap as used for lists of both keys and values only?
10:46pdkquick q
10:46pdkwill clojure let me define mutually recursive functions with defn in a file
10:46chouserocte: maybe I don't understand what you're asking.
10:46chouserpdk: letfn
10:46pdkor is it reserved for letfn or some deal
10:47chouserpdk: defn's can call each other too
10:47AWizzArdpdk: you can (declare your-fn) ahead.
10:47pdkoh cool beans
10:47pdk(doc declare)
10:47clojurebot"([& names]); defs the supplied var names with no bindings, useful for making forward declarations."
10:47jcromartiehmm, need to sort by time
10:47octechouser, for example, i have a list of values '("a" "b" "c"), and i want to create map with those values but the keys generated based on the element in the list
10:47octehard to explain..
10:48chouser(let [ks '(a b c)] (zipmap ks (map #(str % "val") ks))
10:48chouser,(let [ks '(a b c)] (zipmap ks (map #(str % "val") ks))
10:48clojurebotEOF while reading
10:48chouser,(let [ks '(a b c)] (zipmap ks (map #(str % "val") ks)))
10:48clojurebot{c "cval", b "bval", a "aval"}
10:49AWizzArd,(reduce #(assoc %1 (keyword %2) %2) {} '("a" "b" "c"))
10:49clojurebotExecution Timed Out
10:50chouser,(into {} (for [k '[a b c]] [k (str k "val")]))
10:50clojurebot{a "aval", b "bval", c "cval"}
10:51octeah, thanks
11:24bhenryis the only advantage of using defalias over def understandability?
11:25clgv&(doc defalias)
11:25sexpbotjava.lang.Exception: Unable to resolve var: defalias in this context
11:25bhenry&(doc clojure.contrib.def/defalias)
11:25sexpbot⟹ "Macro ([name orig] [name orig doc]); Defines an alias for a var: a new var with the same root binding (if any) and similar metadata. The metadata of the alias is its initial metadata (as provided by def) merged into the metadata of the original."
11:26bhenryi take it def doesn't keep metadata from the original?
11:27clgv&(doc def)
11:27sexpbotjava.lang.SecurityException: You tripped the alarm! def is bad!
11:27clgvlol
11:28clgvI dont really know, but I think everything declared with def has its own metadata
11:29clgvQuote: " If init is supplied, it is evaluated, and the root binding of the var is set to the resulting value."
11:30clgvrefering to: (def symbol init?)
11:30clgvso def always creates a new rootbinding which has its own meta data
11:43devn,(doc def)
11:43clojurebotDENIED
11:56clgv&(doc #'def)
11:56sexpbotjava.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.Symbol
11:56clgv&(doc 'def)
11:56sexpbotjava.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Symbol
11:57clgvnot much there anyway ;)
11:57tonyldef is denied all together it seems
11:57clgvuser=> (doc def)
11:57clgv-------------------------
11:57clgvdef
11:57clgvSpecial Form
11:57clgv Please see http://clojure.org/special_forms#def
11:57clgvnil
12:08arohner&(set? (.keySet {:a 1 :b 2 :c 3}))
12:08sexpbot⟹ false
12:08lpetit,(doc set?)
12:08clojurebot"([x]); Returns true if x implements IPersistentSet"
12:08arohner&(ancestors (.keySet {:a 1 :b 2 :c 3}))
12:08sexpbot⟹ nil
12:09arohner&(contains? (.keySet {:a 1 :b 2 :c 3}) :a)
12:09lpetit&(set? (keys {:a 1 :b 2 :c 3}))
12:09sexpbot⟹ false
12:09sexpbot⟹ false
12:09dnolen&(class (.keySet {:a 1}))
12:09sexpbot⟹ clojure.lang.APersistentMap$2
12:10lpetit&(keys {:a 1 :b 2 :c 3})
12:10sexpbot⟹ (:a :b :c)
12:10lpetit(.keySet {:a 1 :b 2 :c 3})
12:10lpetit&(.keySet {:a 1 :b 2 :c 3})
12:10sexpbot⟹ #< [:a, :b, :c]>
12:12arohnerhttp://dev.clojure.org/jira/browse/CLJ-69
12:13devn,
12:13clojurebotEOF while reading
12:13S11001001arohner: the code highlighting is humorous
12:13devn&(doc ancestors)
12:13sexpbot⟹ "([tag] [h tag]); Returns the immediate and indirect parents of tag, either via a Java type inheritance relationship or a relationship established via derive. h must be a hierarchy obtained from make-hierarchy, if not supplied defaults to the global hierarchy"
12:14devn(meta #'ancestors)
12:14devn&(meta #'ancestors)
12:14sexpbot⟹ {:ns #<Namespace clojure.core>, :name ancestors, :file "clojure/core.clj", :line 4434, :arglists ([tag] [h tag]), :added "1.0", :doc "Returns the immediate and indirect parents of tag, either via a Java type\n inheritance relationship or a relationship established v... http://gist.github.com/786464
12:14robonobodevn: you can PM the bot
12:20robonobowhen i use an anonymous function, is that function then evaluated every time I call it?
12:20devnrobonobo: you could quote it
12:21robonobowhat would that do?
12:21devn&'(fn [x] (+ 1 x))
12:21sexpbot⟹ (fn [x] (+ 1 x))
12:21devnleave it unevaluated
12:21hiredmanrobonobo: no
12:21devn&(fn [x] (+ 1 x))
12:21RaynesI'm not sure I understand your question. Anonymous functions are evaluated to function objects when they're read and then stay that way. ##(fn [])
12:21sexpbot⟹ #<sandbox6318$eval8457$fn__8458 sandbox6318$eval8457$fn__8458@188665b>
12:21sexpbot⟹ #<sandbox6318$eval8466$fn__8467 sandbox6318$eval8466$fn__8467@1a66ed5>
12:22Raynesdevn: o/
12:22robonoboRaynes: that's what I meant
12:22hiredmanrobonobo: feel free not to pay any attention to devn, I am sure he means well, but he is new so it's something like the blind leading the blind
12:22devn\o Raynes
12:22robonobothanks
12:22robonobohiredman: i mean well
12:22RaynesTalk about the village asshole.
12:24devnhiredman: I'm defn.
12:25robonobois there any way I could cancel the current command in slime?
12:25mrBlissrobonobo: C-c C-c
12:25devnC-c C-c
12:25RaynesAnd, he merely misinterpreted an easy to misinterpret question.
12:25hiredmandevn: well, then I don't see why you would suggest using quote
12:26robonobohiredman: there are nicer ways of putting that
12:26hiredmanhe is talking about calling a function, and you don't even have a function if you quote the form
12:27lpetitrobonobo: internally functions are compiled to classes. evaluating a function definition will produce a class for the function. calling the same function over and over will just call an invoke(..) method on an instance of the class the function compiled to. A function returning an anonymous function will return a new instance of th anonymous function's compiled class.
12:28robonobolpetit: i think i get it, thanks
12:29lpetitrobonobo: because returning an anonymous function means "capturing" the values of the lexical scope for this anonymous function instance, and this scope will be captured in a particular instance of the function's class.
12:29lpetitrobonobo: np
12:30devnhiredman: misunderstanding
12:44LauJensenhttp://www.ifitweremyhome.com/compare/US/DK
12:44LauJensenJust sayin' :)
12:44robonoboLauJensen: reddit eh
13:00AdamantLauJensen: someone pointed out something interesting about the US, which is that if you look at performance by ethnic group, all major ethnic groups in the US are outperforming the majority-their group nations elsewhere... the essential problem is that doesn't mean the US as a whole is outperforming everyone else.
13:02LauJensenAdamant: That sounds like a myth
13:02jcromartieLauJensen: no, it's true
13:02LauJensenDocumentation?
13:03jcromartieespecially related to school performance,
13:03gtrakprobably b/c the US isn't using clojure enough
13:04Raynes*rimshot*
13:04jcromartiewe like our Visual Basic, thank you very much
13:06LauJensenI think my general perception of American Intelligence can be summed up on two words: Fox News
13:07S11001001Fox News is allied with the CIA?
13:07RaynesI think my general perception of American Intelligence can be summed up in two words: John Stewart.
13:07robonoboRaynes: right on the money
13:07gtrakhe's a powerful guy
13:07S11001001Jon Stewart is also allied with the CIA?
13:07robonoboS11001001: i want to believe
13:10jcromartieThe US is just so polarized.
13:10robonobois there any way an error from the repl can be made to point to the actual point (line) of failure?
13:10jcromartieThe congressional Republicans want to defund our public radio and TV.
13:11jcromartiethey literally don't want their constituents to be too smart
13:11LauJensenjcromartie: Ah, you mean the great party that gave your country such treasures as the Patriot Act which voided 5 or 6 of your ammendment rights? :)
13:11chouserjcromartie: I'm sure that's exactly why.
13:11jcromartieI understand the revenge motives too
13:11jcromartieJuan Williams and all
13:12mrBlissGreat article: http://articles.sfgate.com/2010-09-12/opinion/23999768_1_major-parties-household-income-deficit
13:13pdk(doc every)
13:13S11001001The real question is how does all this affect Clojure adoption?
13:13clojurebotExecution Timed Out
13:13pdk(doc some)
13:13clojurebot"([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"
13:13pdkbeautiful
13:13pdkok so refresh me
13:13robonobo,(doce every?)
13:13clojurebotjava.lang.Exception: Unable to resolve symbol: doce in this context
13:14pdk(doc every?)
13:14clojurebot"([pred coll]); Returns true if (pred x) is logical true for every x in coll, else false."
13:14robonobo,(doc every?)
13:14clojurebot"([pred coll]); Returns true if (pred x) is logical true for every x in coll, else false."
13:14pdkwhy tf does it have a ? on it
13:14gtrakwe need to poll political preference of clojure users vs a control group
13:14robonobopdk: i don't know, it'sconfusing to me as well
13:16LauJensenmrBliss: Is that article for real1?
13:16LauJensen!?
13:16raekpredicates (functions returning booleans) in clojure have names ending in question marks
13:17mrBlissLauJensen: I believe it ;-) Another shocking revelation: http://www.huffingtonpost.com/2009/07/10/only-six-percent-of-scien_n_229382.html
13:17LauJensenmrBliss: If those numbers can be verified, it should be illegal to vote republican
13:18KirinDaveOf course
13:18KirinDave"Republican" is not a terribly descriptive term. :)
13:18KirinDaveI know staunch conservatives who believe the bible should be the only textbook allowed in schools and they'd NEVER identify themselves as "republican."
13:19mrBlissLauJensen: IMO you are evil when you vote republican, you just want war, more money for the rich, creationism and no health care ;-) (With an emphasis on "IMO"). I'll stop talking about politics now.
13:20LauJensenmrBliss: I didn't mean to vote republican, it was Glenn Beck who told me to do it :(
13:20raek*cough* #clojure-casual
13:20robonobo"Also for when Lau Jensen slaps you for speaking out of turn in irc://irc.freenode.net/#clojure." haha
13:21jcromartieKirinDave: Constitution party?
13:21Adamantif "it should be illegal to vote Republican", why should people bother voting? (note, I'm not Republican.)
13:22KirinDavejcromartie: That couple says they "vote what god tells them to vote."
13:22LauJensenhehe, KirinDave thats funny since the Bible advises its followers to stay out of politics
13:23LauJensenGuess they weren't listening
13:23Adamantthe Bible advises a lot of things
13:23jcromartiethis is one slippery slope we're on here
13:23nachtalpwell, maybe god's answer was "don't vote" :)
13:23pdloganjeez - sorry - thought I was in the clojure channel... :-(
13:24Adamantpdlogan does have a point.
13:24jcromartieHEY GUYZ HOW ABOUT MY CODE
13:24jcromartiehttps://gist.github.com/202a9d047123fcb37f24
13:24LauJensenLook, sure this is #clojure, and if people want to talk Clojure everybody should respect that. But when the channel is mute, there's no rule that says we cant make fun of Americans.
13:25jcromartieis this a decent abstraction? should it be wrapped up in a protocol or anything?
13:25LauJensenjcromartie: I like (historic)
13:26jcromartieI basically want to build my app on it
13:27jcromartieI wonder about performance
13:27jcromartieand persistence
13:27jcromartieif we want to use a RDBMS, it seems like it might be a bad match
13:27jcromartieI don't know
13:27LauJensenjcromartie: You have looked at ClojureQL right? :)
13:27jcromartiecould memoize the current state, too
13:27jcromartieyes
13:28LauJensenshamless plug: http://www.clojureql.org
13:32mefestoHey everyone. I'm experimenting with moustache and came across this example: (app ["foo" bar] my-handler). This will match a url like /foo/baz and bind bar => "baz". How do you access this value from the handler? Is there some sort of middleware that will push those bindings into the request params or something else?
13:33LauJensen(defn the-handler [req id]) (app ["user" id] (delegate the-handler id))
13:33Raynesmefesto: He lurks no longer!
13:34mefestoRaynes: hah yes finally! :)
13:34LauJensenmefesto: the above was for you
13:35mefestoLauJensen: ah i see. thanks.
13:39mefestoLauJensen: works great thanks again.
13:40LauJensennp
13:53robonoboi'm getting a classcastexception (clojure.lang.ArraySeq cannot be cast to clojure.lang.IFn) on this function: https://gist.github.com/786623, but I can't find what i'm doing wrong.
13:56LauJensenrobonobo: Hard to say without seeing the whole thing, but somewhere you're using a sequence like a function
13:57LauJensen,((.split "h/y" "/"))
13:57clojurebotjava.lang.ClassCastException: [Ljava.lang.String; cannot be cast to clojure.lang.IFn
13:59robonoboLauJensen: unless the function is not explicetly called (ie: ((if (blah) (func1) (func2) args)) would it be always visible in the code?
13:59LauJensenI think so
14:14dnolenanybody using Clojure to generate custom JVM ASM which then gets loaded right away?
14:16LauJensendnolen: No, but I'd love to see an example
14:16joshua_Hey guys. I have a problem. I'm working with appengine-magic right now. I did a query that grabbed two items from the datastore, but I can't figure out how to look at the contents of the query. I have another query on a different :kind that I access with something like (.item (first (ds/query :kind Project))) but that isn't working in this case (I actually use map in the code, just trying to get across the point).
14:17hiredmandnolen: I've played with the ASM lib a little
14:18dnolenhiredman: any examples? I see that genclass.clj does some of that
14:18hiredmanwoa
14:18hiredmanthat was some join
14:18hiredmandnolen: no finished projects
14:19hiredmanhttps://github.com/hiredman/Archimedes has various bits
14:19hiredmanbut it isn't very nice
14:20dnolenhiredman: still, it's something thx much.
14:22hiredmanasm has a pdf reference which is pretty nice
14:23dnolena Clojure ASM DSL would be sweet.
14:25afekzanyone here have much experience setting up enclojure on OSX? I can't see any "Libraries" node on my Project Properties and I'm starting to feel like I need to ask for a smack with a clue-by-four
14:25joshua__Is there a way to package a clojure application so that you can distribute it without requiring Java?
14:25hiredmanyes, I started on this horrible macro thing on an earlier project (creating a class loader in clojure, that could be used to load clojure, so it couldn't depend on the clojure runtime)
14:26hiredmanjoshua__: no
14:26hiredmanclojure runs on the jvm
14:26joshua__hiredman: figured it would be impossible, but had to ask
14:26Scriptorjoshua__: if it's an option, you can use .net, I thnk
14:27afekzmeh
14:27Scriptorand I think someone's working on a clojure->js compiler
14:27Scriptoror translator
14:27robonoboScriptor: joshua__ : https://github.com/richhickey/clojure-clr
14:28hiredmanthose tend to translate clojure functions into js functions, but that doesn't mean you have the clojure runtime or collections available in javascript
14:28joshua__robonobo, thanks
14:29Scriptorhiredman: true, though he just said clojure application, so maybe he won't need too much
14:29joshua__Scriptor, I would need file IO.
14:29robonobodoe anyone know if clojure-clr runs on mono?
14:30Scriptorjoshua__: it's possible if you target something like node, though I'm now sure how well integrated clj-js is
14:33joshua__Anyone know if the CLR version of Clojure will have better support for recursive calls?
14:34Scriptornot sure, but I know Microsoft is funding a lot of research in functional languages, including some work on Haskell
14:37dnolenjoshua__: you have good tools to write performant recursive code *today* in Clojure. Use them. Even if VM targets got TCO, I doubt Clojure itself would move quickly to adopt it.
14:38LauJensendnolen: I agree. It wouldnt move quickly :)
14:39hiredman:/
14:39Scriptorand the jdk7 isn't going to support tail calls, so it's gonna be a looong time
14:39robonobowhen should 7 be released?
14:41Scriptorrobonobo: general availability starts july 28, 2011
14:41Scriptorhttp://openjdk.java.net/projects/jdk7/
14:44dnolenIt's nice that you can throw and catch exceptions from within lazy computations - anybody run into any trouble with that?
14:49amalloydnolen: trouble like how? i'm not sure what could go wrong
14:51dnolenamalloy: that's what I was thinking, but double-checking.
14:52ossarehmorning
14:52raek, (try (doall (lazy-seq (throw (Exception. "foo")))) (catch Exception e (.getName (class e))))
14:52clojurebotraek: excusez-moi
14:52raek&(try (doall (lazy-seq (throw (Exception. "foo")))) (catch Exception e (.getName (class e))))
14:52sexpbotjava.lang.SecurityException: You tripped the alarm! catch is bad!
14:53raekthe Exception gets Wrapped in a RuntimeException
14:53joshua__Update on that error I was having earlier, it turned out that the reason I couldn't grab things (.data_member an_instance) was that data_member was null. I was initializing it with (Class. form-data) instead of (Class (:values form-data)).
14:53raekwhich makes exception handling across a "lazyness boundary" hard to do
14:54raekdnolen: this is one trouble I have ran into
14:55amalloyRaynes: ^ reminds me, why do we make it illegal to catch things? is there some scenario in which that can cause a problem?
14:57dnolenraek: hmm, in my case I don't need to catch an exception "outside" the lazy sequence as you are there.
14:58hiredmanamalloy: you can make infinite loops of catching and throwing
14:59tonylyou can also with other forms like loop/recur but they are not denied
14:59tonyl&(loop [x 7] (recur 8))
15:00sexpbotExecution Timed Out!
15:00hiredmanyou can catch the exception that stopping the thread throws
15:00amalloyright
15:00raeksneaky
15:00tonyloh, now that is something
15:00phf`hello, is it possible to build clojure-clr on mono?
15:04amalloyhiredman: does clojurebot forbid catch as well, or did you find something cleverer?
15:04hiredmanamalloy: where do you think sexpbot got it from?
15:04amalloy*chuckle* fair enough
15:05amalloythough i thought clj-sandbox was some separate project that both you and Raynes borrowed from
15:05hiredmanthe try/catch attack was actually used (demonstrated?) on clojurebot long ago
15:05robonoboif i have a datastructure that should change when it is queried (balanced tree), what would (contains?) then return?
15:05hiredmanclojurebot: if you were a super hero, what would your origin story be?
15:06hiredmanclojurebot: ping?
15:06amalloyrobonobo: balanced trees shouldn't change when they're queried, they should change when you try to change them
15:06hiredmanhuh
15:06robonoboamalloy: what about semi-splay?
15:07robonoboamalloy: if I look up something taht should change the tree's structure as well
15:07hiredmanclojurebot: ping
15:07clojurebotPONG!
15:07hiredmanclojurebot: if you were a super hero, what would your origin story be?
15:07clojurebothttp://clojure-log.n01se.net/date/2008-11-21.html#13:04
15:08amalloyrobonobo: but it shouldn't change the tree's *contents*, should it? i apparently need to read about semi-splay trees
15:08pkinneyHey all, I'm using emacs and lein (with swank deps to run a swank server), but which is the best way to test small snippets (without starting a lein project everytime)
15:08robonoboamalloy: no, not the contents, of couse, but the structure
15:08mrBlisspkinney: I use cljr for that.
15:08robonoboamalloy: a semi-splay tree will (attempt to) surface the more queried values
15:08amalloyoh those things
15:09pkinneymrBliss: Thanks, I'll check it out on google
15:09robonoboamalloy: every value queried is at least one step closer to the root
15:09technomancypkinney: ~/.lein/bin/swank-clojure is another option
15:09amalloyrobonobo: are you trying to do it mutably or immutably?
15:09technomancyprovided your lein/swank are new enough
15:10robonoboamalloy: immutable
15:11robonoboamalloy: so the contains operation returns a boolean, but also returns the restructured tree
15:11pkinneytechnomancy: Yeah, I've used that in the past (about a year ago), but i think i read somewhere that it's best to use the swank within lein
15:11amalloyrobonobo: okay. so isn't contains basically the same as get? they both have the problem of wanting to return a value and a tree
15:11robonoboyeah
15:12amalloyin either case though you can easily enough just return [actual-result new-tree]
15:12robonoboamalloy: ok
15:13amalloythen the caller can do something like (let [[value tree] (get key tree)] ...)
15:13robonobook
15:13robonobonow for the second part of my question. how would I let this tree respond to assoc and the like?
15:14robonoboby implemention java.util.Map?
15:14amalloy&(supers (class {}))
15:14sexpbot⟹ #{clojure.lang.IPersistentCollection java.lang.Object clojure.lang.IFn java.lang.Runnable java.io.Serializable clojure.lang.AFn clojure.lang.IMeta clojure.lang.IObj clojure.lang.MapEquivalence java.lang.Iterable clojure.lang.Associative clojure.lang.IPersistentMap cl... http://gist.github.com/786777
15:15amalloyor...well, i'm not sure that works because the contract probably specifies that you just return the value
15:16tonylrobonobo: I think Associative is the interface you are looking for that https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Associative.java
15:16robonoboI could make things like (:value ss-tree) look up without restructuring, and also allow the method you mentioned earlier
15:17amalloythat's true
15:17robonobois there a specification anywhere that's more verbose than the actual code? because there are no specifications whatsoever in there.
15:18amalloyyeah, (assoc m k1 v1 k2 v2) is implemented as (assoc (assoc m k1 v1) k2 v2)
15:18amalloyso you couldn't hijack the actual assoc/get functions
15:19robonoboso i just implement IPersistenMap then?
15:20amalloyrobonobo: i think so. not my area of expertise though
15:20amalloy(hint: i don't have any actual areas of expertise)
15:20robonobodatastructures are great fun
15:22dnolenrobonobo: that's an abstract interface, that is the specification.
15:23dnolenimplement those three methods (via a protocol) and you have something that is associative in Clojure.
15:26hiredmandnolen: I think you have it reversed
15:26hiredmanyou don't implement an interface with a protocol
15:27pkinneymrBliss: Wow, cljr is working pretty well, donno how I never heard about this before
15:27robonoboI guess if an interface extends another interface, you have to implement that parent interface as well?
15:28hiredmanyes
15:29robonoboso i would not just have to implement assoc, assocEx and without but also entryAt?
15:29dnolenhiredman: sorry I meant extend a type to that interface.
15:29hiredmanrobonobo: you should look at ILookup, much simpler
15:30robonobohiredman: yes, but would assoc work then?
15:31robonoboit only has a function to query data, not the insert it.
15:31robonobos/the/to
15:31sexpbot<robonobo> it only has a function to query data, not to insert it.
15:31hiredmanah
15:32tonylAssociative extends IPersistentCollection and ILookup
15:32tonylif that helps
15:33robonobotonyl: yes, and IPersistentMap implements Associative
15:33tonyldidn't noticed that
15:57Raynespkinney: Also, check out cake. It can do a lot of the things that lein and cljr can do.
17:40lpetitrrc7cz: ok. Honestly I'm a little bit lost between the need to provide java wrapper at the same time of refining your clojure API. But you seem to have things under control, so it's probably ok if I stop bothering you with half-baked thought ;)
17:40raekdedeibel: I'm afraid I don't quite understand the question. could you give an example?
17:41rrc7czlpetit: quite honestly I'm lost a bit as well, so no worries :-) Maybe it would make sense if you saw the (very simple) lib: https://github.com/rcampbell/zenclient
17:42lpetitdedeibel: have you watched "are we there yet" from rich hickey ?
17:42rrc7czlpetit: I want to use this lib from Java. Once you see how it's typically used, however, you'll see perhaps why I'm struggling to figure out how to structure a Java wrapper
17:42dedeibelyes, but I am not yet sure how to project that into code :)
17:43lpetitdedeibel: he, no one claims the design process is simple, it's the result which is :-p
17:43dedeibelraek: yeah sure, sorry - I heard the talk from rich hickey "are we there yet" where he talks about how OOP kind of shadows what really goes on - and I am wondering if there is just a problem with the objects having methods and being mutable or if it is okay to code in objects. You pass them into pure functions it maybe logs the user in and returns a new value, representing a logged in user. Maybe containing a session key.
17:44raekthis is a presentation on the same topic, but slightly more concrete: http://www.infoq.com/presentations/Value-Identity-State-Rich-Hickey
17:44dedeibellpetit: thats what makes it interesting
17:45dedeibel(logging in a user maybe wasn't the best Idea for a pure function ^^)
17:46dedeibelraek: thanks
17:46lpetitdedeibel: there are two problems. uncontrolled mutation is one. having data and behavior at the same place is another.
17:47LauJensenlpetit: Hows the OSGi integration coming along?
17:47dedeibelokay
17:48dedeibelI fear there will be some horrible code coming up from me ;-) but funny to be reminded back to the old days starting coding at all.
17:48lpetitLauJensen: right now, using v1.2.10 of clojure.osgi. Provides a way to bootstrap namespaces with the right classloader as a context. Far from being complete, but has proved sufficient for current ccw needs
17:48LauJensencool
17:49raekdedeibel: well, clojure has its own (rather non-mainstream) way of handling things whose state that changes over time. it allows you to decouple change in state from calculating the new state.
17:49lpetitLauJensen: not personally working on clojure.osgi those days. aav does, but we've failed to get in touch recently. Maybe tomorrow, though
17:50lpetitdedeibel: we all went through this :)
17:51raekand as lpetit pointed out, code does not have to be in a method beloning to a certain type, but lives independently as functions in namespaces
17:51dnolendedeibel: getting Clojure is not a short trip. there's a lot of ground to cover, a lot of reading to do. rhickey put some seriously deep ideas into the lang.
17:52ohpauleezdnolen: inc
17:52tonyl(inc dnolen)
17:52sexpbot⟹ 1
17:56lpetitdedeibel: back to your question wrt functions with coarse grained args or shorter ones. My bet is that it's just a matter of contemplating how "close" you are from your application domain vs potential generality of more "technical" function. So you'll probably have both kind of functions. The former (generic ones) living near the top of your presumably "split by domain/big feature" namespaces, the latter probably first living near the t
17:56frank`(+ 1 1)
17:56clojurebot2
17:56dedeibelwhich comes back to the layering early mentioned
17:57raeklpetit: message got chopped for me: "(...) living near the t"
17:57david`(+ 2 3 4 5)
17:57clojurebot*suffusion of yellow*
17:57dedeibelyes
17:57lpetitraek: my bad
17:57lpetitThe former (generic ones) living near the top of your presumably "split by domain/big feature" namespaces, the latter probably first living near the top of those same namespaces, before being eventually "ejected" into their own (more technical) namespaces.
17:58lpetitraek, dedeibel: ^^
18:01dedeibelI'd say (send helpers (conj :thx)) or like that and having a nice night - more clojure learning coming up in the next days and hope to be on the channel with you.
18:05lpetit,(doc send)
18:05clojurebot"([a f & args]); Dispatch an action to an agent. Returns the agent immediately. Subsequently, in a thread from a thread pool, the state of the agent will be set to the value of: (apply action-fn stat...
18:06lpetitdedeibel: really, less parens than you would expect, in Clojure ; just (send helpers conj :thx) ;-)
18:07dedeibel*g*
18:07dedeibelI see
18:07dedeibelbye
18:08RaynesWe'll miss you.
18:12lpetityeah, bed time for me too, bye
18:38phenom_hey guys ... don't mean to start a riot but I'm new to clojure and am wondering how the ants demo can be improved to be able to perform as well as the scala/akka solution of the same parameters ?
18:38cpfrhey, what is the best way to silently ignore an exception when mapping over a sequence
18:39ohpauleezphenom_: Exciting times are happening in Clojure, so the optimization strategies for 1.2 are a little different from 1.3 (some are the same)
18:40phenom_oooo, is there a list of enhancements expected in 1.3 ?
18:40technomancyphenom_: the ants demo isn't really interesting without STM. the whole point is that each ant has a consistent synchronous snapshot of the world.
18:40ohpauleezgenerally speaking, you apply primitive math where you can, use transients when building data structures, use futures to offload work
18:40ohpauleezphenom_: there is, let me dig it up for you
18:40technomancyit was also misported to CL in a way that made it faster, you can read up on the thread about that if you're interested.
18:40phenom_schweet :D
18:41ohpauleezphenom_: http://dev.clojure.org/display/doc/Enhanced+Primitive+Support and here is the design/work being done: http://dev.clojure.org/display/design/Home
18:42phenom_in terms of books, should I meap clojure in action and the joy of clojure?
18:42ohpauleezphenom_: 1.3 has a different sense of def'ing and dynamic behavior and a whole bunch of other stuff
18:42phenom_I'm interested in both the practicall applicability to scalable and performant systems and the lisp paradigm
19:51currentBwhat's the modern replacement for incanter.chrono?
20:22tomojI will not name this project "clojurnalist". I will not name this project "clojurnalist". I will not...
20:23tonyltomoj: be strong
20:25amalloycurrentB: clj-time, i think?
20:25amalloyi don't actually know what chrono is but i think technomancy gave that answer to this question once :P
20:33ossarehclj-time has mysteriously disappeared from github
20:33ossarehall of clj-sys stuff has actually
20:34ossarehhttps://github.com/clj-sys
20:54amalloyif anyone's interested i've written another bloggy-thing at http://hubpages.com/hub/Clojure-macro-writing-macros, to answer the question i've seen repeated most often in #clojure: how to do nested macros
23:54gtechhello, I'm trying to get jswat to debug some clojure code but for some reason it won't even display line numbers when I open the .clj file
23:54gtechThe closest thing I've found to an answer is this: http://osdir.com/ml/clojure/2009-09/msg00077.html but I'm not sure where they are finding these settings