#clojure log - Jan 19 2011

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

3:51 _na_ka_na_: hey guys can I get a reference to the thread-pools that Clojure creates?

3:51 for the futures & agents

4:15 amalloy: _na_ka_na_: it's probably using java.util.concurrent.xxx classes

4:30 Licenser: dun dun dun

6:29 bartj: what does ::blah mean in Clojure?

6:30 unforunately, Google cleans up the query clojure "::"

6:30 raek: if you are in the namespace "user", it means :user/blah

6:31 if you have required foo.bar.x with the alias x, ::x/blah means :foo.bar.x/blah

6:34 bsteuber: any ideas on why this might give a VerifyError on some machines? https://gist.github.com/786039

6:35 bartj: raek, can you please point me to some documentation on that?

6:36 raek: bartj:

6:36 http://clojure.org/reader

6:37 the doc is not very detailed for this feature

7:03 clgv: For 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.

7:03 Furthermore I need the special deftype to map datatypes to the appropriate tree nodes

7:05 I 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

7:05 There 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

7:07 a constructor method for a deftype would also solve the problem, if I could implement it so that it creates the constant tree nodes ...

7:17 fbru02_: hey guys i have this (def datas (atom {:a #{ "a"}}) .. how do i swap! a new value (using conj?) in the set ?

7:17 been playing with that but couldn't make it

7:20 hoeck: fbru02_: (swap! datas update-in :a conj "b")

7:20 Chousuke: (swap! datas update-in [:a] conj "foo")

7:20 hoeck: ah right, forgot the [ ] around :a

7:20 clgv: ,(let [data (atom {:a #{"a"}})] (swap! data update-in [:a] conj "b"))

7:20 fbru02_: hoeck: Chousuke : nice ! didn't have that idiom !! sweet

7:21 clojurebot: Execution Timed Out

7:21 Chousuke: chaining the update functions is fun

7:21 clgv: $(let [data (atom {:a #{"a"}})] (swap! data update-in [:a] conj "b"))

7:21 the bots dont like me... ;(

7:22 Chousuke: weird.

7:23 clgv: ##(let [data (atom {:a #{"a"}})] (swap! data update-in [:a] conj "b"))

7:23 sexpbot: ⟹ {:a #{"a" "b"}}

7:23 clgv: ah now ;)

7:28 raek: clgv: &, not $ (I often forget that too)

7:28 clgv: thx, raek :)

7:31 ok, I am using factory-methods and reify now, for the problem I mentioned before

8:21 LauJensen: Any low-level brutes in here ?

8:25 nvm

8:25 the brutes may rest

8:29 clgv: low-level brutes?

8:33 LauJensen: clgv: I need some education on low-level communication with usb devices, but Ive found it elsewhere

8:34 clgv: ok, I didnt know who to make sense of that "nickname" before ;)

8:35 s/who/how/

8:35 sexpbot: <clgv> ok, I didnt know how to make sense of that "nickname" before ;)

8:44 ordnungswidrig: (let [a (agent 3)] (send a (fn [a s] (* s 2))) (await a) (prn a))

8:44 why does this block?

8:45 clgv: &(let [a (agent 3)] (send a (fn [a s] (* s 2))) (await a) (prn a))

8:45 sexpbot: java.lang.IllegalArgumentException: Wrong number of args (1) passed to: sandbox6318$eval8426$fn

8:46 ordnungswidrig: I see, must be (fn [s] (* s 2)...

8:46 clgv: &(let [a (agent 3)] (send a (fn [s] (* s 2))) (await a) (prn a))

8:46 guessed so ;)

8:46 sexpbot: ⟹ #<Agent@bab945: 6> nil

8:46 ordnungswidrig: thanks

9:17 I 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

9:18 chouser: ordnungswidrig: 'for' is lazy ... are you asking for something eager, with side effects, *and* unroll it at compile time?

9:20 ordnungswidrig: chouser:I don't care about lazyness. I need the list to be expanded at compile time.

9:21 chouser: having the result of the expression as a sequence (lazy or not) gives bonus points

9:21 chouser: I'm still curious as to why, but realize that you need to have the value of xs at compile time to even consider this.

9:22 tonyl: for is already a form, name it differently

9:24 ordnungswidrig: chouser: 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.

9:25 I.e. there is a macro to evaluate and record an expression. I use it like this

9:26 (logged (let [i (rand-int 100)] (alter foo + i) (alter bar -i)))

9:27 I want to execute a bunch of them in parallel, so I thought of sending a bunch of those expressions to some agents for execution.

9:32 clgv: ordnungswidrig: then you have to write a macro

9:35 ordnungswidrig: hm, 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".

9:36 clgv: I have an example for your first description

9:36 ordnungswidrig: Is there a clojure lib for expression rewriting?

9:36 clgv: (defmacro rand-ct [max] (rand max))

9:37 using it gives random values on compile time

9:37 ordnungswidrig: clgv: exactly.

9:37 clgv: user=> (macroexpand-1 '(rand-ct 100))

9:37 86.17588352116391

9:37 user=> (macroexpand-1 '(rand-ct 100))

9:37 27.471785126598846

9:37 user=> (macroexpand-1 '(rand-ct 100))

9:37 62.612066942592605

9:38 there is the clojure.walk library that is also used from macroexpand-all

9:38 ordnungswidrig: clgv: but even this fails in my case because the expression (prn (rand-ct 100)) would be recorded, not (prn 5.8972348907)

9:38 clgv: but I guess it's more general than expression rewriting

9:39 ordnungswidrig: that is due to the definition of the surrounding expression

9:39 did you define it yourself?

9:39 ordnungswidrig: yes

9:39 I could go with the definition (logged [form & args]) where form would be recorded literally and args would be recorded evaluated

9:39 clgv: it's most likely a macro

9:39 ordnungswidrig: yes, it is a macro

9:40 clgv: whats it's definition? you can rewrite it to do compiletime evaluation, most likely.

9:40 ordnungswidrig: https://gist.github.com/534499f402463b935d62

9:41 the macro "logged" records the form to a vector ref and evaluates the form

9:42 so 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)

9:44 clgv: ok the change would definitely involve some kind of expression rewriting

9:44 you would have to search for the macro expressions you want to have evaluated at compiletime

9:46 ordnungswidrig: the simplest solution would be to record only a function name and the arguments where the arguments would be evaluated at time of recording (runtime)

9:46 clgv: you could try to take the definition of macroexpand-all and change it so it evaluates only specified macros

9:47 ordnungswidrig: I think that makes all this too complicated.

9:47 clgv: https://github.com/clojure/clojure/blob/c1c39162608551d50cfb18998d015974b11cfecc/src/clj/clojure/walk.clj#L127

9:48 it's definition is pretty simple

9:48 ordnungswidrig: I'll look into this

9:48 clgv: you will have to replace the call to macroexpand

9:49 ordnungswidrig: On 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"

9:49 clgv: just to convince you: (prewalk (fn [x] (if (seq? x) (macroexpand x) x)) form))

9:49 ;)

9:50 ordnungswidrig: *g*

9:51 I' d have to invent some syntax to declare which form should be evaluated at recoding time: (logged (prn (at-recording (foo)) (bar) (baz))

9:51 Like quote/unquote

9:52 clgv: nope you dont have to

9:52 you could just provide a list of symbols

9:53 either to your macro or via thread-local binding

9:53 ordnungswidrig: the same symbol might required to be expanded at runtime and at recording time

9:54 I don't know if that would really be an issue.

9:54 so far. thank you very much for your suggestions.

9:54 * ordnungswidrig must leave

9:54 clgv: np

9:55 ordnungswidrig: cu all

10:07 phenom_: 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:10 dnolen: phenom_: I don't think the Scala version even does the same thing - it doesn't use STM right?

10:17 no_mind: what is the prefered way to develop a plugin based software using clojure ?

10:18 clgv: no_mind: good question. If you get no other answer, then you probably have to fall back to use java solutions

10:19 no_mind: clgv: kind of confused, should I use protocols ?

10:21 clgv: oh 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:22 Raynes: no_mind: Clojure's dynamic nature makes it relatively easy to develop plugin systems.

10:22 Being able to load and reload code on the fly and such.

10:22 http://github.com/Raynes/sexpbot is entirely plugin based.

10:23 It'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:23 no_mind: clgv: the problem is not about dynamic loading, that is easy in clojure using s-expressions

10:26 Raynes: I am looking for some sort of generic plugin/module based system. Something like hook based design of drupal

10:26 Raynes: $google technomancy Robert Hooke

10:26 sexpbot: First out of 25 results is: technomancy/robert-hooke - GitHub

10:26 https://github.com/technomancy/robert-hooke

10:26 Raynes: no_mind: ^ Check that out. Could be what you're looking for. :)

10:26 clgv: no_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:27 but you dont need to use protocols

10:27 *in general

10:27 no_mind: clgv: Raynes actually i am exploring if ti is possible to allow plugin in any JVM language

10:28 Raynes: Yes, it most certainly is. I've done it.

10:28 Cake and Leiningen both do it.

10:28 no_mind: Raynes: how ?

10:29 Raynes: If I can write core in clojure and let my devs build plugins in PHP, it will a blessing ;)

10:29 clgv: PHP is a JVM language???

10:30 Raynes: Projects 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:30 Oh.

10:30 You want to be able to do plugins in languages that aren't on the JVM?

10:31 That's a different level of difficulty. Never done anything like that, so I can't really help you there.

10:32 jcromartie: Would protocols/deftype be a good fit for building an associative data structure that tracks history over time?

10:32 Basically a sequence of "update" maps

10:32 with timestamps

10:32 and maybe authors?

10:32 no_mind: Raynes: PHP is on JVm, though partially

10:41 harishtella: kinda off topic, but I'm wondering what other IRC channels you clojurians like to visit.

10:42 robonobo: clojurians? is that an official term?

10:42 because it sounds completely amazing

10:43 harishtella: robonobo: haha, I think I saw it on one of the clojure meetup.com groups.

10:45 octe: is 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:45 jcromartie: anybody want to comment on the design here? https://gist.github.com/202a9d047123fcb37f24

10:45 chouser: octe: there are a couple. zipmap and into are the favorites

10:46 oh, and (apply hash-map ...)

10:46 octe: i thought zimap as used for lists of both keys and values only?

10:46 pdk: quick q

10:46 will clojure let me define mutually recursive functions with defn in a file

10:46 chouser: octe: maybe I don't understand what you're asking.

10:46 pdk: letfn

10:46 pdk: or is it reserved for letfn or some deal

10:47 chouser: pdk: defn's can call each other too

10:47 AWizzArd: pdk: you can (declare your-fn) ahead.

10:47 pdk: oh cool beans

10:47 (doc declare)

10:47 clojurebot: "([& names]); defs the supplied var names with no bindings, useful for making forward declarations."

10:47 jcromartie: hmm, need to sort by time

10:47 octe: chouser, 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:47 hard to explain..

10:48 chouser: (let [ks '(a b c)] (zipmap ks (map #(str % "val") ks))

10:48 ,(let [ks '(a b c)] (zipmap ks (map #(str % "val") ks))

10:48 clojurebot: EOF while reading

10:48 chouser: ,(let [ks '(a b c)] (zipmap ks (map #(str % "val") ks)))

10:48 clojurebot: {c "cval", b "bval", a "aval"}

10:49 AWizzArd: ,(reduce #(assoc %1 (keyword %2) %2) {} '("a" "b" "c"))

10:49 clojurebot: Execution Timed Out

10:50 chouser: ,(into {} (for [k '[a b c]] [k (str k "val")]))

10:50 clojurebot: {a "aval", b "bval", c "cval"}

10:51 octe: ah, thanks

11:24 bhenry: is the only advantage of using defalias over def understandability?

11:25 clgv: &(doc defalias)

11:25 sexpbot: java.lang.Exception: Unable to resolve var: defalias in this context

11:25 bhenry: &(doc clojure.contrib.def/defalias)

11:25 sexpbot: ⟹ "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:26 bhenry: i take it def doesn't keep metadata from the original?

11:27 clgv: &(doc def)

11:27 sexpbot: java.lang.SecurityException: You tripped the alarm! def is bad!

11:27 clgv: lol

11:28 I dont really know, but I think everything declared with def has its own metadata

11:29 Quote: " If init is supplied, it is evaluated, and the root binding of the var is set to the resulting value."

11:30 refering to: (def symbol init?)

11:30 so def always creates a new rootbinding which has its own meta data

11:43 devn: ,(doc def)

11:43 clojurebot: DENIED

11:56 clgv: &(doc #'def)

11:56 sexpbot: java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.Symbol

11:56 clgv: &(doc 'def)

11:56 sexpbot: java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Symbol

11:57 clgv: not much there anyway ;)

11:57 tonyl: def is denied all together it seems

11:57 clgv: user=> (doc def)

11:57 -------------------------

11:57 def

11:57 Special Form

11:57 Please see http://clojure.org/special_forms#def

11:57 nil

12:08 arohner: &(set? (.keySet {:a 1 :b 2 :c 3}))

12:08 sexpbot: ⟹ false

12:08 lpetit: ,(doc set?)

12:08 clojurebot: "([x]); Returns true if x implements IPersistentSet"

12:08 arohner: &(ancestors (.keySet {:a 1 :b 2 :c 3}))

12:08 sexpbot: ⟹ nil

12:09 arohner: &(contains? (.keySet {:a 1 :b 2 :c 3}) :a)

12:09 lpetit: &(set? (keys {:a 1 :b 2 :c 3}))

12:09 sexpbot: ⟹ false

12:09 ⟹ false

12:09 dnolen: &(class (.keySet {:a 1}))

12:09 sexpbot: ⟹ clojure.lang.APersistentMap$2

12:10 lpetit: &(keys {:a 1 :b 2 :c 3})

12:10 sexpbot: ⟹ (:a :b :c)

12:10 lpetit: (.keySet {:a 1 :b 2 :c 3})

12:10 &(.keySet {:a 1 :b 2 :c 3})

12:10 sexpbot: ⟹ #< [:a, :b, :c]>

12:12 arohner: http://dev.clojure.org/jira/browse/CLJ-69

12:13 devn: ,

12:13 clojurebot: EOF while reading

12:13 S11001001: arohner: the code highlighting is humorous

12:13 devn: &(doc ancestors)

12:13 sexpbot: ⟹ "([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:14 devn: (meta #'ancestors)

12:14 &(meta #'ancestors)

12:14 sexpbot: ⟹ {: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:14 robonobo: devn: you can PM the bot

12:20 when i use an anonymous function, is that function then evaluated every time I call it?

12:20 devn: robonobo: you could quote it

12:21 robonobo: what would that do?

12:21 devn: &'(fn [x] (+ 1 x))

12:21 sexpbot: ⟹ (fn [x] (+ 1 x))

12:21 devn: leave it unevaluated

12:21 hiredman: robonobo: no

12:21 devn: &(fn [x] (+ 1 x))

12:21 Raynes: I'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:21 sexpbot: ⟹ #<sandbox6318$eval8457$fn__8458 sandbox6318$eval8457$fn__8458@188665b>

12:21 ⟹ #<sandbox6318$eval8466$fn__8467 sandbox6318$eval8466$fn__8467@1a66ed5>

12:22 Raynes: devn: o/

12:22 robonobo: Raynes: that's what I meant

12:22 hiredman: robonobo: 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:22 devn: \o Raynes

12:22 robonobo: thanks

12:22 hiredman: i mean well

12:22 Raynes: Talk about the village asshole.

12:24 devn: hiredman: I'm defn.

12:25 robonobo: is there any way I could cancel the current command in slime?

12:25 mrBliss: robonobo: C-c C-c

12:25 devn: C-c C-c

12:25 Raynes: And, he merely misinterpreted an easy to misinterpret question.

12:25 hiredman: devn: well, then I don't see why you would suggest using quote

12:26 robonobo: hiredman: there are nicer ways of putting that

12:26 hiredman: he is talking about calling a function, and you don't even have a function if you quote the form

12:27 lpetit: robonobo: 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:28 robonobo: lpetit: i think i get it, thanks

12:29 lpetit: robonobo: 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:29 robonobo: np

12:30 devn: hiredman: misunderstanding

12:44 LauJensen: http://www.ifitweremyhome.com/compare/US/DK

12:44 Just sayin' :)

12:44 robonobo: LauJensen: reddit eh

13:00 Adamant: LauJensen: 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:02 LauJensen: Adamant: That sounds like a myth

13:02 jcromartie: LauJensen: no, it's true

13:02 LauJensen: Documentation?

13:03 jcromartie: especially related to school performance,

13:03 gtrak: probably b/c the US isn't using clojure enough

13:04 Raynes: *rimshot*

13:04 jcromartie: we like our Visual Basic, thank you very much

13:06 LauJensen: I think my general perception of American Intelligence can be summed up on two words: Fox News

13:07 S11001001: Fox News is allied with the CIA?

13:07 Raynes: I think my general perception of American Intelligence can be summed up in two words: John Stewart.

13:07 robonobo: Raynes: right on the money

13:07 gtrak: he's a powerful guy

13:07 S11001001: Jon Stewart is also allied with the CIA?

13:07 robonobo: S11001001: i want to believe

13:10 jcromartie: The US is just so polarized.

13:10 robonobo: is there any way an error from the repl can be made to point to the actual point (line) of failure?

13:10 jcromartie: The congressional Republicans want to defund our public radio and TV.

13:11 they literally don't want their constituents to be too smart

13:11 LauJensen: jcromartie: 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:11 chouser: jcromartie: I'm sure that's exactly why.

13:11 jcromartie: I understand the revenge motives too

13:11 Juan Williams and all

13:12 mrBliss: Great article: http://articles.sfgate.com/2010-09-12/opinion/23999768_1_major-parties-household-income-deficit

13:13 pdk: (doc every)

13:13 S11001001: The real question is how does all this affect Clojure adoption?

13:13 clojurebot: Execution Timed Out

13:13 pdk: (doc some)

13:13 clojurebot: "([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:13 pdk: beautiful

13:13 ok so refresh me

13:13 robonobo: ,(doce every?)

13:13 clojurebot: java.lang.Exception: Unable to resolve symbol: doce in this context

13:14 pdk: (doc every?)

13:14 clojurebot: "([pred coll]); Returns true if (pred x) is logical true for every x in coll, else false."

13:14 robonobo: ,(doc every?)

13:14 clojurebot: "([pred coll]); Returns true if (pred x) is logical true for every x in coll, else false."

13:14 pdk: why tf does it have a ? on it

13:14 gtrak: we need to poll political preference of clojure users vs a control group

13:14 robonobo: pdk: i don't know, it'sconfusing to me as well

13:16 LauJensen: mrBliss: Is that article for real1?

13:16 !?

13:16 raek: predicates (functions returning booleans) in clojure have names ending in question marks

13:17 mrBliss: LauJensen: I believe it ;-) Another shocking revelation: http://www.huffingtonpost.com/2009/07/10/only-six-percent-of-scien_n_229382.html

13:17 LauJensen: mrBliss: If those numbers can be verified, it should be illegal to vote republican

13:18 KirinDave: Of course

13:18 "Republican" is not a terribly descriptive term. :)

13:18 I know staunch conservatives who believe the bible should be the only textbook allowed in schools and they'd NEVER identify themselves as "republican."

13:19 mrBliss: LauJensen: 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:20 LauJensen: mrBliss: I didn't mean to vote republican, it was Glenn Beck who told me to do it :(

13:20 raek: *cough* #clojure-casual

13:20 robonobo: "Also for when Lau Jensen slaps you for speaking out of turn in irc://irc.freenode.net/#clojure." haha

13:21 jcromartie: KirinDave: Constitution party?

13:21 Adamant: if "it should be illegal to vote Republican", why should people bother voting? (note, I'm not Republican.)

13:22 KirinDave: jcromartie: That couple says they "vote what god tells them to vote."

13:22 LauJensen: hehe, KirinDave thats funny since the Bible advises its followers to stay out of politics

13:23 Guess they weren't listening

13:23 Adamant: the Bible advises a lot of things

13:23 jcromartie: this is one slippery slope we're on here

13:23 nachtalp: well, maybe god's answer was "don't vote" :)

13:23 pdlogan: jeez - sorry - thought I was in the clojure channel... :-(

13:24 Adamant: pdlogan does have a point.

13:24 * Adamant ceases and desists

13:24 jcromartie: HEY GUYZ HOW ABOUT MY CODE

13:24 https://gist.github.com/202a9d047123fcb37f24

13:24 LauJensen: Look, 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:25 jcromartie: is this a decent abstraction? should it be wrapped up in a protocol or anything?

13:25 LauJensen: jcromartie: I like (historic)

13:26 jcromartie: I basically want to build my app on it

13:27 I wonder about performance

13:27 and persistence

13:27 if we want to use a RDBMS, it seems like it might be a bad match

13:27 I don't know

13:27 LauJensen: jcromartie: You have looked at ClojureQL right? :)

13:27 jcromartie: could memoize the current state, too

13:27 yes

13:28 LauJensen: shamless plug: http://www.clojureql.org

13:32 mefesto: Hey 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:33 LauJensen: (defn the-handler [req id]) (app ["user" id] (delegate the-handler id))

13:33 Raynes: mefesto: He lurks no longer!

13:34 mefesto: Raynes: hah yes finally! :)

13:34 LauJensen: mefesto: the above was for you

13:35 mefesto: LauJensen: ah i see. thanks.

13:39 LauJensen: works great thanks again.

13:40 LauJensen: np

13:53 robonobo: i'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:56 LauJensen: robonobo: Hard to say without seeing the whole thing, but somewhere you're using a sequence like a function

13:57 ,((.split "h/y" "/"))

13:57 clojurebot: java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to clojure.lang.IFn

13:59 robonobo: LauJensen: unless the function is not explicetly called (ie: ((if (blah) (func1) (func2) args)) would it be always visible in the code?

13:59 LauJensen: I think so

14:14 dnolen: anybody using Clojure to generate custom JVM ASM which then gets loaded right away?

14:16 LauJensen: dnolen: No, but I'd love to see an example

14:16 joshua_: 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:17 hiredman: dnolen: I've played with the ASM lib a little

14:18 dnolen: hiredman: any examples? I see that genclass.clj does some of that

14:18 hiredman: woa

14:18 that was some join

14:18 dnolen: no finished projects

14:19 https://github.com/hiredman/Archimedes has various bits

14:19 but it isn't very nice

14:20 dnolen: hiredman: still, it's something thx much.

14:22 hiredman: asm has a pdf reference which is pretty nice

14:23 dnolen: a Clojure ASM DSL would be sweet.

14:25 afekz: anyone 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:25 joshua__: Is there a way to package a clojure application so that you can distribute it without requiring Java?

14:25 hiredman: yes, 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:26 joshua__: no

14:26 clojure runs on the jvm

14:26 joshua__: hiredman: figured it would be impossible, but had to ask

14:26 Scriptor: joshua__: if it's an option, you can use .net, I thnk

14:27 afekz: meh

14:27 Scriptor: and I think someone's working on a clojure->js compiler

14:27 or translator

14:27 robonobo: Scriptor: joshua__ : https://github.com/richhickey/clojure-clr

14:28 hiredman: those tend to translate clojure functions into js functions, but that doesn't mean you have the clojure runtime or collections available in javascript

14:28 joshua__: robonobo, thanks

14:29 Scriptor: hiredman: true, though he just said clojure application, so maybe he won't need too much

14:29 joshua__: Scriptor, I would need file IO.

14:29 robonobo: doe anyone know if clojure-clr runs on mono?

14:30 Scriptor: joshua__: it's possible if you target something like node, though I'm now sure how well integrated clj-js is

14:33 joshua__: Anyone know if the CLR version of Clojure will have better support for recursive calls?

14:34 Scriptor: not sure, but I know Microsoft is funding a lot of research in functional languages, including some work on Haskell

14:37 dnolen: joshua__: 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:38 LauJensen: dnolen: I agree. It wouldnt move quickly :)

14:39 hiredman: :/

14:39 Scriptor: and the jdk7 isn't going to support tail calls, so it's gonna be a looong time

14:39 robonobo: when should 7 be released?

14:41 Scriptor: robonobo: general availability starts july 28, 2011

14:41 http://openjdk.java.net/projects/jdk7/

14:44 dnolen: It's nice that you can throw and catch exceptions from within lazy computations - anybody run into any trouble with that?

14:49 amalloy: dnolen: trouble like how? i'm not sure what could go wrong

14:51 dnolen: amalloy: that's what I was thinking, but double-checking.

14:52 ossareh: morning

14:52 raek: , (try (doall (lazy-seq (throw (Exception. "foo")))) (catch Exception e (.getName (class e))))

14:52 clojurebot: raek: excusez-moi

14:52 raek: &(try (doall (lazy-seq (throw (Exception. "foo")))) (catch Exception e (.getName (class e))))

14:52 sexpbot: java.lang.SecurityException: You tripped the alarm! catch is bad!

14:53 raek: the Exception gets Wrapped in a RuntimeException

14:53 joshua__: 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:53 raek: which makes exception handling across a "lazyness boundary" hard to do

14:54 dnolen: this is one trouble I have ran into

14:55 amalloy: Raynes: ^ reminds me, why do we make it illegal to catch things? is there some scenario in which that can cause a problem?

14:57 dnolen: raek: hmm, in my case I don't need to catch an exception "outside" the lazy sequence as you are there.

14:58 hiredman: amalloy: you can make infinite loops of catching and throwing

14:59 tonyl: you can also with other forms like loop/recur but they are not denied

14:59 &(loop [x 7] (recur 8))

15:00 sexpbot: Execution Timed Out!

15:00 hiredman: you can catch the exception that stopping the thread throws

15:00 amalloy: right

15:00 raek: sneaky

15:00 tonyl: oh, now that is something

15:00 phf`: hello, is it possible to build clojure-clr on mono?

15:04 amalloy: hiredman: does clojurebot forbid catch as well, or did you find something cleverer?

15:04 hiredman: amalloy: where do you think sexpbot got it from?

15:04 amalloy: *chuckle* fair enough

15:05 though i thought clj-sandbox was some separate project that both you and Raynes borrowed from

15:05 hiredman: the try/catch attack was actually used (demonstrated?) on clojurebot long ago

15:05 robonobo: if i have a datastructure that should change when it is queried (balanced tree), what would (contains?) then return?

15:05 hiredman: clojurebot: if you were a super hero, what would your origin story be?

15:06 clojurebot: ping?

15:06 amalloy: robonobo: balanced trees shouldn't change when they're queried, they should change when you try to change them

15:06 hiredman: huh

15:06 robonobo: amalloy: what about semi-splay?

15:07 amalloy: if I look up something taht should change the tree's structure as well

15:07 hiredman: clojurebot: ping

15:07 clojurebot: PONG!

15:07 hiredman: clojurebot: if you were a super hero, what would your origin story be?

15:07 clojurebot: http://clojure-log.n01se.net/date/2008-11-21.html#13:04

15:08 amalloy: robonobo: but it shouldn't change the tree's *contents*, should it? i apparently need to read about semi-splay trees

15:08 pkinney: Hey 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:08 robonobo: amalloy: no, not the contents, of couse, but the structure

15:08 mrBliss: pkinney: I use cljr for that.

15:08 robonobo: amalloy: a semi-splay tree will (attempt to) surface the more queried values

15:08 amalloy: oh those things

15:09 pkinney: mrBliss: Thanks, I'll check it out on google

15:09 robonobo: amalloy: every value queried is at least one step closer to the root

15:09 technomancy: pkinney: ~/.lein/bin/swank-clojure is another option

15:09 amalloy: robonobo: are you trying to do it mutably or immutably?

15:09 technomancy: provided your lein/swank are new enough

15:10 robonobo: amalloy: immutable

15:11 amalloy: so the contains operation returns a boolean, but also returns the restructured tree

15:11 pkinney: technomancy: 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:11 amalloy: robonobo: 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:11 robonobo: yeah

15:12 amalloy: in either case though you can easily enough just return [actual-result new-tree]

15:12 robonobo: amalloy: ok

15:13 amalloy: then the caller can do something like (let [[value tree] (get key tree)] ...)

15:13 robonobo: ok

15:13 now for the second part of my question. how would I let this tree respond to assoc and the like?

15:14 by implemention java.util.Map?

15:14 amalloy: &(supers (class {}))

15:14 sexpbot: ⟹ #{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:15 amalloy: or...well, i'm not sure that works because the contract probably specifies that you just return the value

15:16 tonyl: robonobo: 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:16 robonobo: I could make things like (:value ss-tree) look up without restructuring, and also allow the method you mentioned earlier

15:17 amalloy: that's true

15:17 robonobo: is there a specification anywhere that's more verbose than the actual code? because there are no specifications whatsoever in there.

15:18 amalloy: yeah, (assoc m k1 v1 k2 v2) is implemented as (assoc (assoc m k1 v1) k2 v2)

15:18 so you couldn't hijack the actual assoc/get functions

15:19 robonobo: so i just implement IPersistenMap then?

15:20 amalloy: robonobo: i think so. not my area of expertise though

15:20 (hint: i don't have any actual areas of expertise)

15:20 robonobo: datastructures are great fun

15:22 dnolen: robonobo: that's an abstract interface, that is the specification.

15:23 implement those three methods (via a protocol) and you have something that is associative in Clojure.

15:26 hiredman: dnolen: I think you have it reversed

15:26 you don't implement an interface with a protocol

15:27 pkinney: mrBliss: Wow, cljr is working pretty well, donno how I never heard about this before

15:27 robonobo: I guess if an interface extends another interface, you have to implement that parent interface as well?

15:28 hiredman: yes

15:29 robonobo: so i would not just have to implement assoc, assocEx and without but also entryAt?

15:29 dnolen: hiredman: sorry I meant extend a type to that interface.

15:29 hiredman: robonobo: you should look at ILookup, much simpler

15:30 robonobo: hiredman: yes, but would assoc work then?

15:31 it only has a function to query data, not the insert it.

15:31 s/the/to

15:31 sexpbot: <robonobo> it only has a function to query data, not to insert it.

15:31 hiredman: ah

15:32 tonyl: Associative extends IPersistentCollection and ILookup

15:32 if that helps

15:33 robonobo: tonyl: yes, and IPersistentMap implements Associative

15:33 tonyl: didn't noticed that

15:57 Raynes: pkinney: Also, check out cake. It can do a lot of the things that lein and cljr can do.

17:40 lpetit: rrc7cz: 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:40 raek: dedeibel: I'm afraid I don't quite understand the question. could you give an example?

17:41 rrc7cz: lpetit: 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:42 lpetit: dedeibel: have you watched "are we there yet" from rich hickey ?

17:42 rrc7cz: lpetit: 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:42 dedeibel: yes, but I am not yet sure how to project that into code :)

17:43 lpetit: dedeibel: he, no one claims the design process is simple, it's the result which is :-p

17:43 dedeibel: raek: 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:44 raek: this is a presentation on the same topic, but slightly more concrete: http://www.infoq.com/presentations/Value-Identity-State-Rich-Hickey

17:44 dedeibel: lpetit: thats what makes it interesting

17:45 (logging in a user maybe wasn't the best Idea for a pure function ^^)

17:46 raek: thanks

17:46 lpetit: dedeibel: there are two problems. uncontrolled mutation is one. having data and behavior at the same place is another.

17:47 LauJensen: lpetit: Hows the OSGi integration coming along?

17:47 dedeibel: okay

17:48 I 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:48 lpetit: LauJensen: 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:48 LauJensen: cool

17:49 raek: dedeibel: 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:49 lpetit: LauJensen: not personally working on clojure.osgi those days. aav does, but we've failed to get in touch recently. Maybe tomorrow, though

17:50 dedeibel: we all went through this :)

17:51 raek: and 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:51 dnolen: dedeibel: 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:52 ohpauleez: dnolen: inc

17:52 tonyl: (inc dnolen)

17:52 sexpbot: ⟹ 1

17:56 lpetit: dedeibel: 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:56 frank`: (+ 1 1)

17:56 clojurebot: 2

17:56 dedeibel: which comes back to the layering early mentioned

17:57 raek: lpetit: message got chopped for me: "(...) living near the t"

17:57 david`: (+ 2 3 4 5)

17:57 clojurebot: *suffusion of yellow*

17:57 dedeibel: yes

17:57 lpetit: raek: my bad

17:57 The 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:58 raek, dedeibel: ^^

18:01 dedeibel: I'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:05 lpetit: ,(doc send)

18:05 clojurebot: "([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:06 lpetit: dedeibel: really, less parens than you would expect, in Clojure ; just (send helpers conj :thx) ;-)

18:07 dedeibel: *g*

18:07 I see

18:07 bye

18:08 Raynes: We'll miss you.

18:12 lpetit: yeah, bed time for me too, bye

18:38 phenom_: 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:38 cpfr: hey, what is the best way to silently ignore an exception when mapping over a sequence

18:39 ohpauleez: phenom_: 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:40 phenom_: oooo, is there a list of enhancements expected in 1.3 ?

18:40 technomancy: phenom_: 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:40 ohpauleez: generally speaking, you apply primitive math where you can, use transients when building data structures, use futures to offload work

18:40 phenom_: there is, let me dig it up for you

18:40 technomancy: it 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:40 phenom_: schweet :D

18:41 ohpauleez: phenom_: 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:42 phenom_: in terms of books, should I meap clojure in action and the joy of clojure?

18:42 ohpauleez: phenom_: 1.3 has a different sense of def'ing and dynamic behavior and a whole bunch of other stuff

18:42 phenom_: I'm interested in both the practicall applicability to scalable and performant systems and the lisp paradigm

19:51 currentB: what's the modern replacement for incanter.chrono?

20:22 tomoj: I will not name this project "clojurnalist". I will not name this project "clojurnalist". I will not...

20:23 tonyl: tomoj: be strong

20:25 amalloy: currentB: clj-time, i think?

20:25 i don't actually know what chrono is but i think technomancy gave that answer to this question once :P

20:33 ossareh: clj-time has mysteriously disappeared from github

20:33 all of clj-sys stuff has actually

20:34 https://github.com/clj-sys

20:54 amalloy: if 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:54 gtech: hello, 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:54 The 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

Logging service provided by n01se.net