#clojure log - Oct 04 2010

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

2:03 LauJensen: Morning all

2:04 amalloy: morning LauJensen

3:00 a style question: if i'm using (defrecord) to define a class that i expect to use only from within clojure, should i name it like java (MyClass), clojure (my-class), or some mix (My-Class)?

3:03 carkh: i do it java like (pascal case)

3:25 jlaskowski: Hi

3:25 how to inspect a function?

3:25 to see its args

3:25 input params

3:26 carkh: ,(doc partition)

3:26 clojurebot: "([n coll] [n step coll] [n step pad coll]); Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap. If a pad collection is supplied, use its elements as necessary to complete last partition upto n items. In case there are not enough padding elements, return a partition with less than n items."

3:26 carkh: that's what you mean ?

3:26 jlaskowski: carkh: not necessarily

3:26 I've defined one in a script

3:27 and pass it to some other functions

3:27 I'd like to know if the one I defined somewhere

3:28 carkh: i'm not sure i understand your question

3:30 you want to know if the function you'll be using has been defined, this function being passed as a parameter ?

3:43 jlaskowski: I'm back, sorry - had a offline conversation with a co-worker

3:43 carkh: I'm learning monads

3:43 using c.c.monads

3:43 and would like to know what functions I work with

3:43 and would like to trace their innerworkings

3:44 carkh: ah sorry i know very little about monads, can't help you there

3:44 LauJensen: Is there some restriction on contrib.shell/sh so that it cannot work with sudo ?

3:44 jlaskowski: forget about monads

3:44 it's simply an example

3:44 (and I knew you'd step back when heard about them :))

3:44 carkh: =)

3:44 jlaskowski: I defined a function

3:45 in a script

3:45 and in another function uses the former

3:45 s/uses/use

3:46 how to print out the pass-in function details from within the latter?

3:46 LauJensen: (defn myfn "this fn takes an int and a double" [i d] (+ i d)), (doc myfn) ==> "[i d] this function takes an int and a double"

3:46 jlaskowski: say, I have (fn [x] x)

3:46 raek_: there's not much details stored about functions in the function itself

3:46 most is stored in the var's metadata

3:46 jlaskowski: can I query for its input params?

3:47 carkh: yep you would need to pass the var instead

3:47 raek_: in 1.2 functions can have metadata too

3:47 carkh: oh didn't know that

3:47 jlaskowski: that's the idea

3:47 raek_: ,(meta #'conj)

3:47 clojurebot: {:ns #<Namespace clojure.core>, :name conj, :file "clojure/core.clj", :line 71, :arglists ([coll x] [coll x & xs]), :doc "conj[oin]. Returns a new collection with the xs\n 'added'. (conj nil item) returns (item). The 'addition' may\n happen at different 'places' depending on the concrete type.", :added "1.0"}

3:47 raek_: ,(meta conj)

3:47 clojurebot: {:line 77}

3:47 jlaskowski: use meta

3:47 or doc

3:47 thanks

3:48 raek_: (the first one checks the metadata on the var, the second on the function)

3:48 vars can be used as functions (they call the function that they contain)

3:49 so as carkh said, you could require the caller to pass the var instead

3:49 or write a macro that adds the var-quote arount the argument

3:49 I think that is how 'doc' does it

3:50 (doc ^{:doc "Test"} (fn [x] (* x x)))

3:50 clojurebot: java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol

3:51 raek_: mm, yes... that call turns into something like (doc* (var ^{:doc "Test"} (fn [x] (* x x)))

3:51 where doc* is the underlying function doing the actual stuff

3:54 raek: ,(let [x conj] (doc x))

3:54 clojurebot: Titim gan éirí ort.

3:54 raek: ,(+ 1 29

3:54 clojurebot: EOF while reading

3:54 raek: ,(+ 1 2)

3:54 clojurebot: 3

3:55 carkh: doc really wants a var

3:55 picky doc !

3:59 raek: essentially, it calls (println (:doc (meta v)))

3:59 http://github.com/clojure/clojure/blob/b578c69d7480f621841ebcafdfa98e33fcb765f6/src/clj/clojure/core.clj#L3880

4:03 esj: morning all

4:30 konr: Any idea why this code prints nothing on Emacs/swank but does print on a terminal with `lein repl`? (dotimes [i 10] (.start (Thread. (fn [] (println i)))))

4:30 LauJensen: konr: In Emacs, look in the buffer *inferior-lisp*

4:44 esj: konr: its just shy.

4:45 konr: :)

5:01 LauJensen: konr: Did you look?

6:36 rrc7cz: how can you apply a seq of arguments to a Java method? Something like (apply (.foo bar) [1 2 3]) when what I want is (.foo bar 1 2 3)?

6:40 cemerick: apply doesn't know anything about interop forms (like ctors and methods)

6:40 The best you could do is (apply #(.foo bar % %2 %3) [1 2 3])

6:41 I seem to remember a more elegant solution, if one was willing to swallow reflection.

6:41 s/solution/solution floating around some while back

6:42 rrc7cz: cemerick: reflection for this case would be fine. I'll take a look. I'm using something like your first suggestion right now, but it doesn't handle variable arity

6:42 LauJensen: (defmacro japply [obj f args] `(. ~obj ~f ~@args)) ?

6:42 rrc7cz: LauJensen: perfect! thanks. The ~@ will splice the seq into form

6:43 cemerick: A macro buys you nothing here; why not just do (.foo bar 1 2 3) in that case?

6:43 LauJensen: cemerick: macro buys you arbitrary number of args

6:43 rrc7cz: cemerick: the [1 2 3] was just an example. In reality it's a variable length seq

6:45 cemerick: rrc7cz: mmm, I should have inferred that. My brain's still not fully online. :-)

6:45 raek: japply only works for a litteral collection as 'args', right?

6:46 cemerick: yup

6:46 rrc7cz: cemerick: :-) at least yours comes online now and then

6:46 I'll have to play with it so it doesn't require a literal seq

6:46 cemerick: if it's a runtime reference, you'll just get (. bar foo symbol-of-seq)

6:48 rrc7cz: Risking being dense again....but it seems you're asking for more than can be known at macro-expansion-time.

6:48 carkh: i think those java functions that take variable number of arguments are using an array as last parameter underneath

6:49 rrc7cz: cemerick: couldn't you first evaluate args before splicing? the literal should eval to itself, while any symbol would eval to the literal

6:49 cemerick: Yeah, I was assuming rrc7cz's method isn't variadic, just that he'd like to spread a seq as args to it.

6:49 LauJensen: carkh: correct

6:49 cemerick: rrc7cz: Sure, if you use eval.

6:49 LauJensen: eval?

6:49 clojurebot: eval is sometimes useful - but only sometimes

6:49 cemerick: indeed

6:50 reaching for it *usually* means you're not thinking about things right

6:50 rrc7cz: cemerick: so am I thinking about things right? :-D

6:50 I don't see any other way except to first eval args

6:50 before the splicing is done I mean

6:50 cemerick: rrc7cz: Not if you're hoping to evaluate runtime values of symbols at in a macro expansion.

6:51 carkh: rrc7cz : (String/format fmt (to-array args)

6:51 raek: using the reflection stuff that a method call is compiled to could be an option

6:51 rrc7cz: wow, so my brain's offline too

6:51 cemerick: raek: indeed, far preferable IMO

6:51 that, or a macro that will produce a fn from an object, method name, and argument arity

6:52 rrc7cz: okay, so two options: one is great for literals, and reflection will work fine for non literals where performance doesn't matter

6:52 carkh: well you only want to apply if the parameter list is variable in length, so that means the method has variable length arguments, so that means you can use the same pattern as the format function

6:52 LauJensen: If its an option you can hardcode japply to a specific method on a specific object, then call it using a function as a driver

6:53 rrc7cz: carkh: my case is a bit differnt: I have a fn that returns the args to apply to a Java method. It returns a seq, and I'd like to (apply (.method foo) (compute args))

6:54 carkh: can't you just (.method foo (first my-seq) (second my-seq))

6:54 rrc7cz: carkh: so variable arity was one side of it, but I have another case where the arity is static. Right now I just deconstruct the return value into x,y,z and pass those manually, but I was hoping for something less verbose if this comes up a lot

6:54 carkh: destructuring my-se beforehand might be usefull

6:54 rrc7cz: carkh: absolutely, but I was hoping to find another way, especially if I have to be doing this a lot

6:55 carkh: i see

6:55 raek: http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Method.html#invoke(java.lang.Object, java.lang.Object...)

6:56 rrc7cz: carkh: it's something like.. I know I need apply, but with Java interop. I guess it doesn't exist, but checking out the reflection idea is worthwhile

6:57 raek: so invoke takes an array, that will work

6:58 carkh: using reflection your call will be very slow, which might not be a problem... i guess your function would look like this (japply instance method-name param-seq) and might error at run time

6:58 cemerick: rrc7cz: I still think this is mostly *yuck*, but: https://gist.github.com/0b4b6b437360b3e2f2e0

6:58 raek: the problem might be to get the correct method instance...

6:59 this is probably implemented somewhere in clojure.lang

6:59 carkh: cannot be done at macro-expansion time i think

6:59 rrc7cz: cemerick: that's pretty neat. It's a shame we have to pass the arity

6:59 cemerick: clojure.lang.Reflector is very handy.

6:59 raek: as long as the classes has been loaded, I think the refelction alternative should work

7:00 cemerick: rrc7cz: use Reflector ^^ if you think so :-)

7:00 carkh: well then you need to add the call name to your macro call

7:00 which is again lots of work, while the goal is to make it easier

7:00 i mean :

7:00 well then you need to add the *class name to your macro call

7:01 the macro only sees the symbol used as a name for your instance

7:01 so japply needs to be a function

7:02 LauJensen: carkh: or have a function driver

7:02 carkh: bu why would you need a macro then ?

7:02 but*

7:04 LauJensen: for the splicing

7:05 carkh: hum, the splicing can only occur if the seq is literal

7:05 (in a macro)à

7:08 LauJensen: ah right. Then perhaps just calling applyTo from lang.RT might do the trick

7:25 carkh: (defn japply [instance method-name args] (clojure.lang.Reflector/invokeInstanceMethod instance method-name (to-array args)))

7:25 (japply (Integer. 1) "compareTo" [(Integer. 2)])

7:25 still uggly =P

7:26 there you could use a macro so that you can use a symbol instead of the string

7:27 cemerick: carkh: um, (str method-name)? :-)

7:27 carkh: you'll get errors if the symbol is not declared

7:27 cemerick: if one can stand the '

7:27 carkh: right

7:28 remember he wants it for convenience

7:28 anyways =P

7:28 cemerick: yeah…the whole objective is off the mark *shrug*

8:40 tobiasraeder: hey :)

8:41 is there a way to create an implementation of a java function without retrun value?

8:41 for example if i wanted to impletement void setMyField(String)

8:42 chouser: cemerick: your methodfn is remarkably similar to memfn

8:44 tobiasraeder: do you mean with 'reify' or something?

8:44 tobiasraeder: using deftype but i think i just got it to work

8:45 but can't really explain what i did wrong as it seems

8:50 chouser: I was realizing the other night that clojure's locals are just as much variables as algebraic variables.

8:51 that is they don't vary within the scope of one function or loop (although creating a new local with the same name but a new value looks more like mutation than algebra allows)

8:51 just like algebra variables don't vary within an equation or proof

8:52 but at different times they can have different values, which is why they're used instead of plain constants

8:53 so it's perhaps okay to call clojure locals "variables" and just make the point, at the appropriate time, that they're immutable variables.

8:53 AWizzArd: I just wanted to ask where you see the differences to constants.

8:53 chouser: (fn [a] ( + 5 a))

8:53 5 is a constant. it will always have the value 5.

8:54 AWizzArd: yes, your previous statement made it clear to me

8:54 chouser: a is an argument variable. each time the function is called, a may have a different value -- in that sense it varies.

8:54 ah, ok.

8:54 AWizzArd: one thing that I "often" do is (let [x (foo 1), x (bar x), x (+ 5 x)] ...)

8:55 chouser: yes

8:55 AWizzArd: i.e. reducing the complexity for human readers

8:57 cemerick: chouser: Yup. Though I never think of memfn, given #() *shrug*

8:57 chouser: cemerick: ditto

8:57 cemerick: Actually, can't memfn be deprecated entirely?

8:57 chouser: yes. I wish it were

8:58 it continues to trick people into thinking it provides a different feature-set than #()

8:58 AWizzArd: hmm

8:58 chouser: though someone recently mentioned that it allows one level of nesting with #()

8:58 AWizzArd: ,(doc memfn)

8:58 clojurebot: "([name & args]); Expands into code that creates a fn that expects to be passed an object and any args and calls the named instance method on the object passing the args. Use when you want to treat a Java method as a first-class fn."

8:59 cemerick: Certainly not a reason to let it live.

8:59 Especially since damn near no one thinks of it.

9:00 AWizzArd: Btw, do you know how definlines do work? To me it seems: when their name is used somewhere else than the first position in a list, it expands into a fn. If it is used as first element of a list, then it works like a macro.

9:01 chouser: AWizzArd: roughly, yes

9:01 AWizzArd: (definline mydefinline [n] `(+ n 10)) (map mydefinline (range 10)) ... works as if it were a fn. But (+ 3 (mydefinline 20)) can be done without calling mydefinline at runtime.

9:01 labatitude: Hi, I'm trying to partition a list in a funky way. Here's what I've got: http://gist.github.com/609643 but am wondering if there is a more clojurey way of doing it.

9:01 AWizzArd: Is it the compiler or reader who is doing this work?

9:02 chouser: AWizzArd: a definline is expanded into a function definition once, when it is defined. Everywhere that the name is used like a value, that one function is used.

9:02 AWizzArd: compiler

9:06 labatitude: (mapcat (fn [[[v] ks]] [v (if (next ks) ks (first ks))]) (partition 2 (partition-by vector? vmix)))

9:06 AWizzArd: chouser: k

9:07 chouser: labatitude: patition-by is an option only because you're promising at least one non-vec after each vec.

9:07 labatitude: chouser: ok, somehow I missed partition-by.

9:08 chouser: there are a lot of functions. It's hard not to miss some.

9:09 560 public vars in clojure.core

9:10 * cemerick winces a little

9:10 labatitude: chouser: i've been mostly looking at the clojure.org/data_structures and clojure.org/sequences pages

9:10 they are'nt up to date I guess

9:10 chouser: 978 in the Common Lisp hyperspec list of all symbols

9:11 labatitude: hm, that would probably be my fault. :-/

9:11 labatitude: oh dear

9:11 chouser: indeed. I should update that for 1.2

9:11 AWizzArd: cemerick: some of those could be hidden you mean? It would be great if core would have a def-, and both def and def- should get the patch of bsteuber that allows to attach doc-strings to def's.

9:12 chouser: AWizzArd: clojure.core has plenty of hidden vars already

9:12 77 private vars

9:12 cemerick: AWizzArd: No, that's just a very large footprint for a single namespace.

9:12 The convenience of it is undeniable, but...

9:12 It definitely impacts discoverability.

9:13 chouser: cemerick: I agree. I noticed when I pulled up the hyperspec the other day and for the first time *ever* thought: well, that's not *that* many functions...

9:13 cemerick: yeah

9:13 AWizzArd: (:

9:13 cemerick: I think it'd make sense to segment core up in a reasonable way, and immigrate vars into core.

9:14 Though various redefinitions may make that painful/impossible.

9:14 Maybe especially given static

9:14 labatitude: anyhow, thanks chouser. I'm still trying to grok the destructuring in the anon function, but I will get there :)

9:14 chouser: labatitude: yeah, that's dense, as most usful destructuring is.

9:15 (second (partition 2 (partition-by vector? vmix))) ;=> ((["b"]) (:b1 "b2" :b3))

9:16 so that's what the one argument for one call to the anon fn looks like

9:16 labatitude: right. I totally see how useful that is. in other languages you spend about 10 lines digging out your arguments.

9:16 chouser: [[v] ks] so that v = ["b"] and ks = (:b1 ...)

9:17 labatitude: yeah, I don't think it's be any more clear without destructuring

9:18 labatitude: so in [[v] ks], the brackets around the v are basically doing (first ...)?

9:18 chouser: labatitude: exactly

9:18 (fn [x] [(ffirst x) (if (next (second x)) (second x) (first (second x)))])

9:19 ^^^ not clearer

9:19 labatitude: agreed!

9:20 * fogus_ can't live without destructuring anymore

9:21 labatitude: i just need to go play with that at the repl so that it sinks into my brain. destructuring-bind was something I just avoided in Common Lisp.

9:21 AWizzArd: fogus_: would you sometimes like to destructure from the end?

9:21 (let [[* x y z] my-vector] (println "last three elements:" x y z))

9:21 fogus_: AWizzard: Yes. The need came up for me recently

9:22 chouser: and just in case destructuring isn't quite powerful enough yet, perhaps we can look forward to http://www.assembla.com/spaces/clojure/tickets/211

9:22 fogus_: chouser: I can't wait!

9:23 AWizzArd: yes, that sounds good

9:25 chouser: oh no. every single link to a function doc on clojure.org is pointing to the old github url, not the new one. :-(

9:28 fogus_: It would be great if destructuring leveraged unification also. :-)

9:29 chouser: Apparently I need to read a book to understand what unification means.

9:30 fogus_: That makes two of us. :p

9:30 cemerick: fogus_: "Why does the destructuring in this snippet of Clojure take 40 minutes to unify on my Core i7?" ;-)

9:31 * cemerick was damaged by prolog in a past life

9:31 fogus_: cemerick: Weren't we all?

9:32 cemerick: sadly, I blew professional time on it. I wish I had served my time in college, as most sane people seem to have.

9:32 fogus_: The funny thing about Prolog is that the cut operator has a tendancy to *actually* cut you. It's the strangest thing

9:33 * fogus_ Has the scars to prove it

9:36 fogus_: cemerick: Sounds like you do too

9:36 cemerick: It seems that a plurality of clojure coders have Programming PTSD of some form or another.

9:37 chouser: that may be true of professional coders in general.

9:37 clojure coders are perhaps more likely to have recognized it as such

9:37 cemerick: fogus_: I got into rehab very quickly compared to some, thankfully.

9:38 chouser: hard to see trauma sometimes when you're still in it.

9:39 cemerick: Hrm. Being able to talk about one's tools as if they were significant others is a helluva pathology.

9:39 chouser: hehe

9:40 fogus_: BTW, have you gentlemen started/completed your Conj slides?

9:40 * chouser is still laughing

9:40 cemerick: s/significant others/(war|addiction|etc)

9:40 chouser: fogus_: neither. :-]

9:40 fogus_: whew... so it's not just me then

9:40 chouser: mine for strange loop are getting close to done

9:40 cemerick: fogus_: My talk at Clojure NYC last month was a preview.

9:40 chouser: fogus_: sounds like your last talk was well-received

9:41 cemerick: I need to work on my demo flow, but a tweak or two to the slides are all that are required.

9:41 fogus_: I was freaking out about the CUFP slides and couldn't find the evenrgy...

9:42 chouser: I hope so. I walked to the front of the room all full of confidence, looked in the front row and saw Simon Peyton-Jones staring at me. I don't think I've ever had a confidence crash quite like it

9:42 chouser: I find my feelings, correct or not, is that StL is enemy territory and I need to "sell" Clojure (which I don't much enjoy). The conj will just be talking to old friends. :-)

9:43 fogus_: heh. I can imagine.

9:43 cemerick: chouser: What, all haskell and F# there?

9:43 fogus_: chouser: Although it would be worse if Guy Steele were sitting there. :p

9:43 * cemerick doesn't get out on the conference circuit much

9:44 cemerick: fogus_: very approachable fellow.

9:44 chouser: cemerick: strange loop? I think it's mostly more mainstream than that. Java, C#, maybe ruby.

9:44 cemerick: Oh, I thought you meant St. Louis :-x

9:44 chouser: cemerick: yep, strange loop is in st louis

9:44 fogus_: cemerick: I have heard that about Steele (and Peyton-Jones also)... the psychosis is purely within me

9:51 chouser: labatitude: http://clojure.org/sequences now has all the new 1.2 fns

9:51 mixed in with the old ones. If you just want a list of the new ones, see http://github.com/clojure/clojure/blob/1.2.x/changes.txt

9:52 cemerick: I wonder if hard-partitioning of core would be able to make much sense

9:52 labatitude: chouser: cool! this will actually help a lot.

9:52 chouser: so many functions fall into more than one "category", or none at all

9:53 cemerick: chouser: Well those actually are "core". Insofar as fns can be dropped into one of the documentation categories on clojure.org, they're namespaceable.

9:54 chouser: many fns in the doc categories on clojure.org appear in more than one category

9:54 set-validator

9:54 deref

10:04 jjido: ,(trampoline (letfn [(continue [n s brk] #(forloop (inc n) s brk)) (forloop [n s break] (if (< n 100) (if (zero? (rem n 4)) (continue n s break) (if (= n 13) #(break (str s n)) (continue n (str s n ", ") break))) #(break s)))] (forloop 1 "" identity)))

10:04 clojurebot: "1, 2, 3, 5, 6, 7, 9, 10, 11, 13"

10:05 chouser: wow

10:05 jjido: experimenting with break and continue... this stuff is simple after all :)

10:09 chouser: it somehow never occured to me to use trampoline to explicitly manipulate returns the was call/cc does.

10:10 you know something is brilliant when, having seen it, it suddenly seems obvious even though you'd never thought of it before.

10:11 esj: chouser: exactly - I had that flash reading about monads this morning. Ooooh, why did this take me so long to wrap my head around :)

10:11 jjido: I will be doing plenty of that. after this all I'll need is syntactic transformation from my pet language to clojure

10:12 chouser: esj: ah, congrats. I have yet to reach that point with monads.

10:12 esj: well, i'm not claiming mastery, merely understanding what the fuss is about.

10:14 leafw: jjido: this paste of yours ... like a contest of obfuscated code

10:16 jjido: leafw: lol. for me it is clear enough because I am used to writing continuation-passing style, which is different from clojure's functional style.

10:22 did you read Philip Wadler paper about monads? Not that I find monads that interesting personally.

10:24 tobiasraeder: is there a way to define a second constructor for deftyped classes? (one that takes 0 arguments preferably)

10:24 chouser: tobiasraeder: no. just create a regular function.

10:25 tobiasraeder: @chouse it's beeing called by java code which expects a no parameter constructor

10:25 esj: jjido: no I'm not haskell literate which obviously limits how far I could take that subject. So I worked through Jim Duey and Konrad Hinsen's tutorials.

10:27 chouser: tobiasraeder: ah, for that kind of interop case you may have to use gen-class

10:28 tobiasraeder: @chouser is gen-class able to have mutable fields, like deftype [^{:volatile-mutable true} myparam] ?

10:28 chouser: tobiasraeder: no, you get a single immutable (final) instance membet, but you can put an atom or ref in there so that it can be mutated.

10:29 member

10:29 which is more likely correct anyway, than a volatile-mutable

10:29 jjido: you will have trouble with mutable defrecord and java interop

10:30 tobiasraeder: tbh it worked pretty nice so far

10:30 chouser: tobiasraeder: what kind of high-performance thing do you have going where you are using :volatile-mutable anyway?

10:30 jjido: I think (what does atom translate into?)

10:30 tobiasraeder: @chouser i just need to implement an interface in clojure (which is generated in clojure aswell) and said implementation needs mutable fields

10:30 @chouser so the volatile-mutable deftype way is completely wrong for that purpose in your eyes?

10:31 cemerick: For my money, gen-class'ing a class providing static factory fns returning records is the best path at the moment if one has Java callers.

10:31 chouser: tobiasraeder: if it's not high-performance, don't touch volatile-mutable. Use one of clojure's controlled mutable reference types: atom, ref, agent, var, etc.

10:31 even if it is high-performance you should use one of those first

10:32 tobiasraeder: well i got n numbers of parameters which all need to be mutable and are generated inside a macro

10:32 chouser: tobiasraeder: not a problem. put them all in a vector or map and store then in a ref

10:33 or possibly a vector or map of refs, depending on your exact situation.

10:33 tobiasraeder: @chouser alright, guess ill try that out later today. ill look into gen-class then i guess

10:41 chouser: tobiasraeder: yeah, I think that's the only way to get a no-arg constructor, which is unfortunate because gen-class is rather hairy to use

10:42 tobiasraeder: @chouser well im using gen-interface alright, i guess its pretty much "the same"?

10:43 chouser: well, that does mean you're doing AOT already, which is at least half the battle

10:45 tobiasraeder: yeah

10:45 its kinda scary interop really lol

10:45 the javaside is alot of reflection driven analysis of the supplied class/interface

10:48 LauJensen: tobiasraeder: When you get tired of Java you should try doing some Clojure :)

10:50 tobiasraeder: @LauJensen lol i am tired but need to finish that interop stuff first i guess :/

11:04 chouser: replaca_: will there be an api page for clojure.string?

11:05 astoddard: I have started working with defrecord. It appears the generated constructor uses strictly positional arguments; this is for efficiency?

11:06 I have seen others write "factory" functions for constructing records with named parameters. Is this recommended?

11:06 chouser: astoddard: sure, for any kind of customized construction

11:07 named parameters, defaults for unset fields, pre-computed fields, etc.

11:07 also helps ease use in other namespaces.

11:08 astoddard: Thank you, makes sense. I'll have to think a bit to grok that last one.

11:09 All those functions will ultimately call the positional constructor to actually get a record?

11:09 chouser: yep

11:11 astoddard: Got it. One last question. Positional only because it goes as close as possible to the bare JVM and the JVM only does positional arguments?

11:12 konr: Is there a better way to do this? http://4f6e998fe0ca9c6f.paste.se/ Basically I'm logging function call results and running before-running and after-running functions

11:13 jjido: astodard: it is short too. I don't like it when there are many args though.

11:13 chouser: astoddard: probably. there's been talk of a named-arg constructor function as well, and I wouldn't be suprised if one shows up eventually. There's been some differences of opinion on specific semantics and naming.

11:15 konr: I don't think you need any of those atoms

11:16 astoddard: Fair enough, thanks. I'm imagine there are some macros out there wrapping fancier constructor semantics around defrecord. Does anyone have a favorite one?

11:16 chouser: konr: just initialize your job map with the actual values you need

11:17 astoddard: this one has been out there. I haven't found any single macro to be useful in general in my own work yet. http://cemerick.com/2010/08/02/defrecord-slot-defaults/

11:18 konr: chouser: hmm, inside the Thread object?

11:18 astoddard: chouser: Thanks.

11:18 chouser: konr: ah, I was misreading, sorry.

11:19 you're collecting return values.

11:20 konr: do you actually look at those return values later?

11:20 konr: chouser: sure! They'll contain web crawling data

11:20 drewr: http://ubuntuone.com/p/IZI/

11:21 chouser: drewr: hm. yeah. maybe (conj others me)

11:22 fogus_: astoddard: I have a modified version of cemerick's defrecord+ that also allows kwargs and invariants (with some extra support needed http://github.com/fogus/trammel/blob/master/src/fogus/me/trammel.clj#L239 )

11:23 scottj: fogus_: have you tried do get your defrecord+ in c.c?

11:23 chouser: konr: hm, ok. will you be looking at intermediate values of a job before it's complete?

11:23 jjido: esj: this is how I got the "obfuscated" code: http://gist.github.com/609842

11:23 fogus_: scottj: no. I'm not sure if its wider appeal

11:23 s/if/of/

11:23 sexpbot: <fogus_> scottj: no. I'm not sure of its wider appeal

11:24 scottj: every time I look in this channel someone is asking about it

11:24 (little exaggeration)

11:24 chouser: jjido: I think using clojure as a target lang for various syntaxy languages has a lot of promise

11:24 fogus_: scottj: Oh? I think that such a macro, while useful, is controversial.

11:24 konr: chouser: not at all... it would be nice to have some sort of progress counter, but I'm not worrying about that for a first version

11:26 esj: jjido: interesting. Although I don't think I busted out the obfuscated code comment :) I'm still at a point that most good code looks obfuscated to me, so I'm a little cautious.

11:26 scottj: fogus_: apply macro is controversial and in c.c.

11:26 chouser: konr: then I'd still recommend building and returning an immutable map, instead of a map full of atoms

11:27 konr: like (assoc {} :time (get-time) :pre (when pre (pre)) ...)

11:27 scottj: or maybe not, looks deprecated now

11:27 cemerick: scottj: I wrote defrecord+, and even *I* dislike it. :-P

11:27 drewr: chouser: that's exactly where pjstadig's and my conversation went

11:28 scottj: cemerick: why?

11:28 freakazoid: speaking of maps full of atoms, how would one do an MVCC database where insertions don't always conflict with other insertions?

11:28 chouser: drewr: heh, sorry, what are you referring to?

11:28 cemerick: scottj: It defines multiple with a single def* form. That's almost always bad IMO.

11:28 konr: chouser: thanks! btw, nice book you are writing!

11:29 chouser: konr: thanks! mostly done now, thank goodness.

11:29 freakazoid: right now I'm using a vector that I don't delete from

11:29 * cemerick can't type

11:29 freakazoid: full of refs

11:29 drewr: chouser: the t-shirt snafu

11:29 cemerick: scottj: It defines many things with a single def* form.

11:29 jjido: esj: no problem. To add to what chouser said, I am happy my code converts so straightforwardly in Clojure

11:29 chouser: konr: also, you might look at 'future' instead of start-Thread-fn...

11:29 freakazoid: and a separate map from key to index in the vector

11:29 chouser: drewr: ah

11:30 drewr: probably too late, eh?

11:30 cemerick: Given a type Foo, what's the factory fn called? new-Foo? new-foo? make-Foo? Bleh.

11:30 freakazoid: why not Foo?

11:30 cemerick: Foo is the class itself

11:31 scottj: cemerick: if there were one defrecord+ in c.c then that would be clearly defined and consistent

11:31 * cemerick hopes for factory fns bound into the generated class that call back to a fn provided to the defrecord form.

11:31 freakazoid: Couldn't a class implement the IFn interface?

11:31 chouser: Class is final

11:31 freakazoid: Maps and vectors do

11:31 cemerick: freakazoid: no, Class is final

11:31 freakazoid: hmm

11:31 I suppose learning Clojure would be easier for me if I knew Java

11:32 chouser: freakazoid: I know Java better now than I ever did before learning Clojure.

11:32 cemerick: scottj: A just-so standard is stupid and unhelpful to newcomers. Esp. when simpler options are available.

11:32 freakazoid: I'm learning bits of it in the rpocess.

11:32 chouser: I still get completely tripped up with Java syntax though

11:33 cemerick: I'm sure we've been on this merry-go-round before, but how would a 'make' macro (with a better name) sit with you? (make Foo :a 1, :b 2)

11:34 macro, though -- requiring a literal class name there.

11:35 AWizzArd: How can one do Enums in Clojure? As in: public class Bar { public enum Foos {SMALL, MEDIUM, LARGE} ... }

11:35 jjido: chouser: I use something like that called new*

11:35 chouser: AWizzArd: define or use?

11:36 jjido: with my own class structure though, I don't have java interop as a goal

11:36 AWizzArd: chouser: define

11:36 cemerick: chouser: IIRC, that was fine by me.

11:36 AWizzArd: Use would probably be something such as Bar$Foos/LARGE

11:36 cemerick: There's a lot of intersecting concerns re: the factory fn thing.

11:36 freakazoid: AWizzArd: the normal lisp thing to do is to use symbols for that

11:36 AWizzArd: freakazoid: yes, I know. Keywords even.

11:36 freakazoid: or keywords, whatever they're called

11:37 chouser: cemerick: because that could of course generate a call to either (-maker-for-Foo :a 1 :b 2) or even just (Foo. 1 2 :default-for-c)

11:37 freakazoid: they're atoms in erlang, but clojure uses atom to mean something else

11:37 cemerick: chouser: That doesn't help apply cases, and doesn't help with require-before-import problem though.

11:37 AWizzArd: Though the Enums may have hotspot advantages, and they are easier to use from Java.

11:37 cemerick: chouser: dear lord, the latter please :-|

11:37 freakazoid: AWizzArd: he said he didn't have interop as a goal ;-)

11:38 cemerick: chouser: you understand, CLOS poisoned me w.r.t. defining multiple "things" with a single def* form.

11:38 freakazoid: In general it's best to only depart from doing things idiomatically if you really need ultimate performance

11:39 chouser: AWizzArd: that's a good question -- are you sure you need enums and not just keywords

11:39 I'm not sure if there's a way to generate enums from clojure short of ASM

11:40 jjido: AWizzArd: enums in java use some kind of inheritance maybe you could go back to that

11:40 freakazoid: AWizzArd: whoops for some reason I got it into my head jjido asked the original question

11:40 the java interop thing was a red herring with respect to enums

11:40 AWizzArd: I can imagine that I would like to offer easy to use classes for a Java API. Those guys are more used to Enums and have (java) language support for those.

11:41 chouser: AWizzArd: so this is about interop

11:41 AWizzArd: I would start off writing my code using keywords, if it were I who should use the code. So yes, mostly interop.

11:41 The enums have some advantages, such as compile time checking, easy use from Java, etc.

11:42 (defenum MyEnum [X Y Z]) ... MyEnum/Y don't know if such a thing would be possible, and get the same advantages.

11:42 jjido: and integer values?

11:42 AWizzArd: My example from above used an inner Enum as I see it.

11:43 freakazoid: AWizzArd: did you look at http://markmail.org/message/zatkdrrunyp4mhpv already?

11:43 google has lots of hits for "java enum clojure"

11:44 chouser: ah, when genclass was new

11:44 might be able to use deftype now?

11:45 AWizzArd: hmm

11:45 freakazoid: anyone using clojure on .net on azure yet?

11:47 Hmm, for all I know the JVM works on azure

11:47 oh look at that

11:47 google says yes

11:47 cemerick: freakazoid: it apparently does -- I was being pitched on running tomcat-hosted apps in azure by a MS rep a few months ago

11:48 freakazoid: I need to get Membase onto Azure.

11:48 And looks like making it dependent on the JVM for running server-side user code would not be an impediment to that

11:51 arohner: what affects when tab completion works in slime?

11:52 it works 100% of the time for me in repl mode, but seems to work 50% of the time in clojure source files

11:52 defn: arohner: among other things I believe you need to have TAB bound to some swank command

11:52 but that should be done for you?

11:53 arohner: defn: interestingly, it's not, in my clojure file. But I'm certain it has worked before in clojure files...

11:53 defn: arohner: just for kicks try to do Shift + TAB

11:53 and let me know if that fixes it...

11:53 arohner: defn: shift + tab is bound to yank for me

11:54 should it be slime-indent-and-complete-symbol?

11:54 defn: arohner: yeah that sounds familiar

11:54 arohner: also try meta-tab

11:55 arohner: defn: that's what my repl TAB is bound to

11:55 meta-tab is alt-tab, that OSX eats

11:55 defn: not for me?

11:55 maybe you're thinking of Cmd + TAB

11:56 arohner: defn: I have meta and option switched

11:56 defn: sorry im not of much help here, i just seem to remember in SLIME TAB has always worked

11:56 but in clojure-mode, in the file itself

11:56 i needed to use some modification of that

11:56 arohner: defn: just getting me to check what tab was bound to helped a lot. I'm surprised though that it's transient

11:57 defn: *nod* -- weird behavior

11:57 latest version of clojure-mode?

11:57 arohner: defn: my clojure file is not bound to slime-indent, but I'm 100% sure it's worked recently

11:58 chouser: AWizzArd: java.util.Calendar seems to use static fields instead of enums

12:00 rplevy: is there any way to control or configure memoization in newer versions of Clojure? For example, if it is using too much memory.

12:02 arohner: rplevy: not in the built in memoize

12:02 rplevy: http://kotka.de/blog/2010/03/memoize_done_right.html

12:04 defn: arohner: technomancy might be a good guy to ask

12:04 he's intimately familiar with all of those details

12:04 me...not so much

12:04 my setup works, beyond that I'm sort of a clueless :\

12:05 rplevy: arohner: thanks, this looks useful

12:06 chouser: AWizzArd: looks like we used to have clojure.contrib.enum for this, but not anymore?

12:15 AWizzArd: chouser: I did not even know about contribs enums :)

12:55 cemerick: chouser: why the dashes in your colored repl?

12:57 chouser: cemerick: I really wanted the prompt to be in a different color, to make it stand out

12:58 but that messes with rlwrap's concept of horizontal cursor position.

12:58 so the dashes are just to help the prompt stand out from the rest of the output

12:58 cemerick: ah

12:58 I don't think I'll include those :-)

12:58 Though I never see red, only green and blue.

12:59 I wonder if I'm just terminally hopeless with the console, etc.

13:01 chouser: exceptions aren't red?

13:02 freakazoid: terminally hopeless… I like that

13:02 (with the console)

13:02 chouser: heh

13:02 cemerick: freakazoid: I was wondering if anyone would catch that.

13:02 chouser: I completely missed it

13:02 freakazoid: bash has a way to use escape characters in the prompt without screwing up position

13:03 \[\e]2;\h:\W\a\]\!,$? \u@\h:\w$

13:03 chouser: yeah, but this isn't bash

13:03 freakazoid: Just hack it to do something analogous

13:03 chouser: maybe rlwrap has some options -- I didn't look into it too deeply

13:05 freakazoid: or just add a separate option to explicitly specify a character position

13:05 bash just doesn't count characters between \[ and \]

13:06 cemerick: chouser: bleh, I was printing exceptions in nrepl to *out* :-P

13:06 chouser: ah. I'm not actually sure if *err* is correct

13:06 I think I was just mimicking the built-in repl

13:07 s/correct/best/

13:07 cemerick: no, I mean nREPL was printing exceptions to *out*, server side, so that content wasn't coming over in messages with an :err slot, etc.

13:07 nm, it was my bad :-)

13:09 chouser: oh, I see. ok

13:09 cemerick: chouser: you said that colored output was usually optional...is there a standard option enabling it?

13:10 20s of googling turned up nothing obvious.

13:10 chouser: --color on the command line is probably most common, is that what you're asking?

13:11 cemerick: yup, that'll work

13:29 chouser: FWIW: http://github.com/cemerick/nREPL/blob/master/src/main/clojure/cemerick/nrepl/cmdline.clj

13:29 I poked around at trying to get :err println boldly, but had no luck

13:31 abedra: fogus_: How did your talk go on Saturday?

13:33 fogus_: abedra: Better than I expected. It was fun.

13:34 abedra: And your tutorial?

13:35 abedra: fogus_ went well. Glad yours did too. Really enjoyed the audience

13:35 fogus_: I'll catch you finally in raleigh in a few weeks!

13:37 fogus_: abedra: People seemed genuinely interested in Clojure, and had very insightful questions. I guess that's to be expected given the auidence mix

13:42 lazy1: cemerick: (println "\033[31mfoo\033[m") printed in red for me

13:42 cemerick: Ubuntu via rlwrap

13:44 cemerick: lazy1: Yeah, the problem was unrelated to what was being printed :-)

13:45 (see prior commit)

13:57 chouser: cemerick: ah, cool.

14:18 defn: If you don't have this: You want it.

14:18 http://sr3d.github.com/GithubFinder/

14:20 cemerick: defn: damn

14:20 mrBliss: defn: it doesn't have syntax highlighting for clojure though ;-)

14:48 aav: if i have a protocol - what is the portable way to find the name of java interface behind it?

14:49 is this a good option: (.getName (:on-interface protocol))

14:50 chouser: portable?

14:51 Dawgmatix: how do i specify clojure contrib 1.3 alpha as a dependency in leiningen ?

14:52 aav: chouser: means it will not be affected, in case some internals of protocol implementation will change

14:52 chouser: aav: I don't think :on or :on-interface is documented or guaranteed to not change)

14:53 but it looks like as good an option as any right now. :-)

14:53 aav: chouser: than you. that was my question. :)

14:53 kotarak: Dawgmatix: [org.clojure "1.3.0-alpha1"] should come close

14:54 Dawgmatix: thanks

14:54 kotarak: [org.clojure/clojure ...] that is

15:02 AWizzArd: ~seen rhickey

15:02 clojurebot: rhickey was last seen quiting IRC, 5293 minutes ago

15:02 AWizzArd: Rich is having vacation :-)

15:02 LauJensen: AWizzArd: He's in Denmark

15:02 AWizzArd: LauJensen: oho?!

15:02 jfkw: Trying to get started with swing windows. Platform is Gentoo Linux ~amd64, sun-jdk-, window manager: awesome (tiling, it might be pertinent). First question: (. javax.swing.JOptionPane (showMessageDialog nil "Hello World")) works, but when the window is closed, lein repl doesn't return to prompt until new input processed. Is this normal, and is the swing window loop still running awaiting some terminate method?

15:03 AWizzArd: very nice, touring through Europe

15:03 LauJensen: AWizzArd: JAOO

15:15 hugod: LauJensen: you solve your tomcat woes?

15:15 carkh: jfkw: i had the same problem in emacs/windows it soemhow disapeared

15:16 LauJensen: hugod: The Tomcat is now purring like a kitten, yea everything is great

15:17 carkh: jfkw: i think it's a matter of using swing as it should be, and call swing methods with invokeLater

15:17 jfkw: as swank is in its own thread

15:31 jfkw: carkh: #awesome is pointing me to sun-jdk-1.6 problems with non-reparenting window managers. I'm trying their workarounds.

15:32 carkh: Workaround using utility wmname, trick jdk into thinking I'm using LG3D, fixes it completely.

15:33 chouser: jfkw: link? I bet I've seen problems from a similar cause.

15:35 carkh: ahwell i guess my problem was a different one

15:36 LauJensen: jfkw: I had the same, and yes LG3D and restarting the JVM solves it

15:40 jfkw: chouser: See http://awesome.naquadah.org/wiki/Problems_with_Java#Impersonate_Another_Window_Manager , Arch's bug would seem to be a good start to port the fix to other distros: https://bugs.archlinux.org/task/15674 My own Gentoo doesn't have a sun-jdk-1.6 fix yet.

15:55 * kotarak sneakily released VimClojure 2.2.0 while everyone was looking the other way.

15:55 AWizzArd: kotarak: grats to VimClojure 2.2.0!

15:56 chouser: jfkw: thanks

16:04 freakazoid: Anyone have a suggestion for an embeddable lisp interpreter for a C++ program? There are so many to choose from.

16:05 Ease of embedding and apache2 compatible license are what i'm looking for

16:05 doesn't have to be common lisp or any standard

16:05 chouser: umm... maybe clojure?

16:05 embedding a jvm can't be *that* hard, right?

16:06 freakazoid: haha

16:06 this is a pretty small C++ program :)

16:06 Embedding a JVM into it would be kind of comical.

16:06 I just don't want to implement a confguration & command language.

16:07 technomancy: guile is designed for that kind of thing

16:07 chouser: I've had fair success using C and C++ libs from clojure, but haven't tried the other way 'round.

16:09 freakazoid: guile was one of the many I was looking at.

16:10 Somehow guile's installation manages to be larger than spidermonkey's

16:10 probably because of all the examples

16:10 whereas spidermonkey is *just* the header files and library. Ah.

16:11 turbofail: tinyscheme maybe

16:12 freakazoid: Anything not in homebrew makes me suspicious ;-)

16:13 unless it has a native package

16:16 turbofail: tinyscheme is small enough that you can audit the source yourself if you're suspicious

16:17 freakazoid: I'll check it out

16:17 s450r1: how about gambit, chicken, or bigloo then? They are supposedly pretty easy to embed, since they all can compile scheme to C.

16:17 freakazoid: the current binary for this program is 1.2 megs, guile is 1.7 megs, lua is 328k, but I'd like to avoid lua

16:17 turbofail: though ironically one thing it was infamous for was that a malware developer mentioned that he used it in his work

16:18 freakazoid: this is for runtime config

16:18 tinyscheme?

16:18 turbofail: yeah

16:18 freakazoid: well, that is a testament to its ease of embeddability

16:18 s450r1: turbofail: I remember reading that interview too :-)

16:19 carkh: ah funny guile allows linking without infecting with the gpl

16:20 freakazoid: oh, I forgot to mention crossplatform… this thing will build and run on windows, but doesn't use autoconf so will need some work

16:20 turbofail: i've built tinyscheme using mingw

16:20 it required very few tweaks

16:20 freakazoid: building it on OS X is proving to be a bit of a challenge.

16:21 turbofail: eh... can't help you there, that's one platform i've had zero time on

16:22 freakazoid: using the linux section is helping

16:23 hmm, it has a call to something called "ccommand" which I can't find any information on

16:24 turbofail: odd... my copy of the makefile doesn't have anything like that

16:24 freakazoid: Oh, it thinks I'm on apple and not osx

16:25 woo! it built!

16:27 turbofail: cool

16:29 fhd: Hi. I'm using the Clojure Maven plugin and I have to manually load my .clj files when calling mvn clojure:repl. Any hints what I can do about that?

16:30 kumarshantanu: fhd: what is "manually load"?

16:30 fhd: (load "foo/bar")

16:32 Steps to reproduce: 1. Create a file "bar.clj" in a directory "foo" with the following contents: (ns bla) (defn main [] (println "Hello, World!"))

16:32 2. Invoke mvn clojure:repl and try to execute "(foo.bar/main)" <-- doesn't work.

16:33 chouser: fhd: I think you need your .clj files in a different directory tree.

16:33 fhd: 3. Invoke mvn clojure:repl and execute '(load "foo/bar") (foo.bar/main)' <-- works

16:33 chouser: which one?

16:33 kumarshantanu: is foo/bar in classpath?

16:34 chouser: fhd: I haven't used maven much. just a sec...

16:34 fhd: kumarshantanu: I think clojure:repl adds it. It does at least compile it.

16:35 I'm not exactly sure if clojure:repl is supposed to load my .clj files, I'm just expecting that.

16:35 abrenk: fhd: your .clj files are supposed to be in src/main/clojure

16:35 cemerick: fhd: it doesn't -- you have to use/require them per usual

16:35 fhd: abrenk: They are. If they weren't they wouldn't be compiled.

16:35 cemerick: and what abrenk said

16:36 kumarshantanu: fhd: hmm, repl doesn't load files by default

16:36 fhd: cemerick: I'm new to clojure, is use/require an alterantive to load?

16:36 cemerick: fhd: load is essentially never used in app-level clojure code

16:37 see use and require, as well as their associated forms in ns

16:37 AWizzArd: cemerick: I am using load at a few places

16:37 hiredman: we use load for somethings too

16:37 technomancy: "use" is old-school; I'm porting my code over to "uses"

16:37 cemerick: AWizzArd: Indeed. See "essentially" :-)

16:37 AWizzArd: It allows me to move some code parts into different files, and they share the NS.

16:37 technomancy: (not really)

16:37 abrenk: fhd: you could specify replScript in the configuration and require your namespaces there

16:37 AWizzArd: cemerick: yes okay, not typical, I agree

16:37 chouser: lein source code trees aren't laid out the same as maven source code trees?

16:38 cemerick: nope

16:38 abrenk: chouser: not by default

16:38 AWizzArd: I use it very rarely, and 98% goes into require

16:38 like technomancy said

16:38 technomancy: one could use with a :only specifier

16:38 technomancy: AWizzArd: actually I was joking; "uses" hasn't been implemented yet

16:38 AWizzArd: ...use 'use' with...

16:38 freakazoid: tinyscheme looks like exactly what we need. Thanks, turbofail!

16:38 technomancy: it's a mythical replacement to unify use/require/refer

16:39 AWizzArd: ah, I only got that first part, before the semicolon

16:39 * cemerick bets that use/require stands as it is for years

16:39 kumarshantanu: fhd: just curious - are you trying to do interactive development using the REPL?

16:39 fhd: I see, it works with both require and use. Does that mean I have to require all the namespaces I want to use? Is there a combination of require/use and ns so I can switch namespace directly?

16:39 hiredman: I was looking at some example code for a database project some guy just posted to the mailing list, and he seems to think use is uses

16:39 fhd: kumarshantanu: I'm actually just trying to do some random experiments with Clojure

16:39 clojurebot: clojure bot is not immune to ,(iterate inc 0)

16:39 AWizzArd: strange that I didn't see the other part.. it is like the situation when a lisp newbie tells me that there are too many parens. Only when I get this explicit remark I even notice them.

16:39 hiredman: the code does (:use some.name.space :as space :only ())

16:40 cemerick: fhd: not in a bare repl -- require + in-ns is typical

16:40 Good tools will provide you with a load-and-switch-ns command, tied to the current buffer, etc.

16:40 fhd: cemerick: :( Pretty ugly with long package names

16:40 hiredman: you can provide short cuts in a user.clj

16:40 cemerick: fhd: almost no one uses bare repls for development AFAIK

16:41 except for chouser ;-)

16:41 abrenk: fhd: add <configuration><replScript>src/main/scripts/repl.clj</replScript></configuration> to the plugin and use "require" and "in-ns" in that file.

16:41 chouser: it builds character

16:41 cemerick: and RSI, I presume

16:41 kumarshantanu: fhd: it seems you can specify an initialization script for clojure:repl in pom.xml -- http://github.com/talios/clojure-maven-plugin

16:41 chouser: nope, vi-bindings destroy RSI

16:42 fhd: abrenk, kumarshantanu: Thanks, looks useful.

16:42 kumarshantanu: fhd: search for "clojure:repl" on the page

16:42 fhd: I could also define my own require-and-ns in that file :)

16:42 hiredman: *ahem*

16:42 user.clj

16:42 no xml required

16:43 abrenk: hiredman: but then user.clj is packaged into the jar...

16:43 hiredman: depends on what your classpath is vs. what you are packaging

16:43 kotarak: In (let [x (int 1234)] (< x 4321))... Do I have to hint 4321 with (int)?

16:44 chouser: kotarak: which version of Clojure?

16:44 kotarak: 1.2 for now, but later on 1.3 of course.

16:45 chouser: well, you never have to hint. but for unboxed math in 1.2, yes you need (int 4321)

16:45 abrenk: hiredman: the script config could get some sensible defaults... perhaps I'll put together a patch for that.

16:45 kotarak: chouser: yeah. unboxed was the question.

16:45 LauJensen: hugod: bestinclass.dk is now Tomcat driven

16:45 kotarak: chouser: should I also go with long instead of int?

16:45 chouser: for future proofness

16:46 chouser: hm.

16:46 (clojure.contrib.repl-utils/expression-info '(let [x (int 1234)] (< x 4321)))

16:46 alexyk: ninjudd: is there a way to blink closing/open parens as rlwrap does? I really miss that in cake

16:46 chouser: that should tell you the truth -- but I'm getting :primitive? true on 1.2, which surprises me.

16:46 ninjudd: alexyk: i wasn't aware rlwrap did that

16:47 alexyk: ninjudd: beautifully

16:47 kotarak: Ah. Expression-info....

16:47 chouser: oh, nm

16:47 fhd: Is there a way to require multiple namespaces with a wildcard? e.g. (require foo.*)?

16:47 chouser: boolean primitive. duh.

16:47 kumarshantanu: fhd: no wildcards available

16:47 kotarak: hahaha :) Yeah. expected from <.

16:47 ninjudd: alexyk: sounds like a great first cake contribution for you ;-)

16:48 alexyk: ninjudd: I need to write up my PhD first, by then will run on assembly if need be :)

16:48 but I'll investigate how rlwrap does the blinkin'

16:48 chouser: kotarak: hang on -- testing 1.3.x

16:49 fhd: cemerick: What are the tools you mentioned other Clojure devs use?

16:49 chouser: cemerick: If I'm a maven-clojure user and want to just start up a quick repl in some specific version of clojure, what would be my best route?

16:49 hugod: LauJensen: :) if you let me know the issues you had, I can embed the solutions in the #pallet tomcat crate

16:50 chouser: technomancy: If I'm a lein user and want to just start up a quick repl in some specific version of clojure, what would be my best route?

16:50 cemerick: chouser: assuming you're on the command line: set your clojure dependency version, `mvn clojure:repl`

16:50 chouser: ninjudd: If I'm a cake user and want to just start up a quick repl in some specific version of clojure, what would be my best route?

16:50 cemerick: how do I set my clojure dependency version?

16:50 do I have a project dir sitting around just for such occasions?

16:51 technomancy: chouser: lein new scratch-project; edit project.clj, then lein repl should do it

16:51 KirinDave: So guys.

16:51 technomancy: lein repl got a significant fix in 1.4.0-snapshot

16:51 KirinDave: I gots more advice to consider.

16:51 cemerick: fhd: you sound like a lisp user; I'd point you in that direction if that's the case. Otherwise, counterclockwise for eclipse, enclojure for netbeans.

16:51 technomancy: chouser: actually if you don't have a project, cljr might be better

16:51 KirinDave: Anyone want to let me sound off them?

16:51 fhd: cemerick: Ah, I thought you meant commandline alternatives to REPL.

16:52 chouser: technomancy: ok, scratch project

16:52 kotarak: chouser: you didn't ask for gradle, but I have to market things. Apply the clojure plugin in build.gradle, add clojure dependency of choice, start your favorite editor backend via a custom task. The last step is kind of not implemented right now, but eg. a VimClojure task will be there in the future.

16:52 cemerick: chouser: yeah, that's assuming you've got a pom.

16:52 ninjudd: chouser: if you want to do it without creating a project, just run 'cake' from your home directory. then you can edit the global project (~/.cake/project.clj) to specify the version of clojure you want

16:52 KirinDave: As Webmachine moves down the state graph

16:53 ninjudd: the default is 1.2.0

16:53 KirinDave: In the erlang impl it sets up temporary variables

16:53 chouser: kotarak: sorry, no offense intended!

16:53 KirinDave: I'm wondering how I should mirror that.

16:53 ninjudd: chouser: to start a repl after changing your clojure version, just do 'cake repl'

16:53 KirinDave: With bindings?

16:53 kotarak: chouser: non taken. Just to keep it on the radar. ;) (shameless promotion)

16:54 fhd: cemerick: Still, how does Counterclockwise prevent me from having to require/ns?

16:54 KirinDave: https://gist.github.com/e1b9d6920877fa5ed3bc

16:54 fhd: cemerick: I've tried it and it seems to bascially run a REPL inside Eclipse.

16:54 KirinDave: The erlang code puts the chosen response handler in a temp variable.

16:54 lancepantz: chouser: in short, just 'cake repl' will give you a repl with 1.2

16:54 cemerick: fhd: There's a load-and-switch-ns command that loads the current file and switches you to the corresponding ns.

16:54 KirinDave: Should I do that?

16:54 With like, um, bindings?

16:54 chouser: hm, so the basic pattern is: scratch project, set dependency version. Do any of these work with a custom clojure.jar?

16:54 fhd: cemerick: Oh, I see.

16:55 lancepantz: chouser: if you want a different version, you can edit ~/.cake/project.clj to change the global project

16:55 cemerick: chouser: that you built locally?

16:55 kotarak: fhd: VimClojure provides an option to start a repl with the initial namespace set to the one of the current file. Maybe ccw provides something similar.

16:55 kumarshantanu: fhd: in Eclipse/CCW, you just right-click a .clj file and say "Run in REPL"

16:55 kotarak: chouser: yep.

16:55 chouser: cemerick: right. I just changed Compiler.java, ran ant, I want to try it out.

16:56 KirinDave: almost certainly not bindings

16:56 kumarshantanu: fhd: CCW loads the namespace automatically and switches ns for you

16:56 KirinDave: chouser: Why?

16:56 hugod: KirinDave: I just moved pallet from bindings to passing an explicit map argument, and I haven't regretted it - haven't looked at your use case though...

16:56 jjido: Dave: bindings is for vars that you want to attach to a specific thread isn't it

16:56 cemerick: chouser: if you run ant using the target that is used in hudson (ci-build?) that will install a clojure.jar snapshot locally, which should get picked up immediately by your next mvn invocation (assuming your dep is set for the corresponding snapshot version).

16:57 KirinDave: jjido: Bindings are for dynamic scope. It can be used for thread bindings.

16:57 fhd: Hm, I see, it works. Problem is that I'd prefer working on the commandline with mvn clojure:repl. I think I'll just live with the duplication for now...

16:57 KirinDave: hugod: It just.. gets kinda tedious to move all that around.

16:57 chouser: cemerick: interesting.

16:57 cemerick: chouser: it's exactly the same process that build.clojure.org uses, which I have to presume will work in a single-user setting.

16:58 kotarak: fhd: maybe you can start up the backend via maven and tell ccw to connect to it?

16:58 cemerick: Which is why I've never quite understood you and Rich having such trouble with the workflow.

16:58 hugod: KirinDave: I use a single map argument - which can then be used to pass different keys as required - tedious to set up, maybe

16:58 fhd: kotarak: wouldn't that still require Eclipse?

16:58 KirinDave: I just need to keep in mind scala compatibility in the future.

16:58 Maps of maps of maps will make them angry.

16:59 chouser: KirinDave: if you use bindings you have basically zero options when it comes to delays, closures, multiple threads, saving state machine state anywhere, etc.

16:59 kotarak: fhd: Oh sorry. I though you were using eclipse.

16:59 fhd: kotarak: I do, sometimes, but I'd rather not for clojure :)

16:59 kumarshantanu: kotarak: the unified REPL-over-network interface is in works I guess (for CCW, in this case)

16:59 fhd: Okay I think I've got it. What I want is to create a number of examples and execute them explicitly.

17:00 So I think I'll just create a Java main class that accepts a sample as an argument.

17:00 I think that's how clojure.main works, isn't it?

17:00 kotarak: kumarshantanu: I know. Working in VimClojure

17:07 AWizzArd: Hey aav, und ihr anderen deutschsprachigen, es gibt auch einen deutschen Clojure-Kanal. Einfach mal ein .de anhängen und joinen :-)

17:13 chouser: cemerick: looks like I want my own thing (target?) to launch a customized repl

17:13 I guess I should look at creating my own maven plugin?

17:20 cemerick: chouser: you mean for your highlighting, etc?

17:20 chouser: yeah, but more importantly rlwrap

17:21 hm, maybe that's backwards.

17:21 abrenk: why's there no "ant repl" target?

17:25 LauJensen: tomoj: I almost... cant...hold my breath... any longer...

17:36 AWizzArd: Anyone here who knows the gzipIOstreams "well"?

17:37 Their constructor offers a size argument, for a buffer. Does this mean that a BufferedIOStream is not required, as the gzipstream implicitly creates one?

17:47 cemerick: chouser: I don't use rlwrap myself, but I have to assume it'd be rlwrap mvn ...

17:49 jjido: is there a "letrecord" like there is a "letfn"?

17:50 I want to change the way it implements a protocol without adding a new type at the top level

17:50 raek: jjido: no, but you might be intetested in reify

17:51 jjido: raek: yesI think so

17:52 chouser: cemerick: yeah, had just realized that

17:52 cemerick: how do you quit out of said repl? EOF such as ^D doesn't seem to work.

17:52 really, I'm just whining. why doesn't ^D work. :-)

17:53 KirinDave: Is there a version of if-let that allows for more bindings?

17:54 chouser: not standard, that I know of.

17:55 KirinDave: chouser: https://gist.github.com/4a808194d428697eeb9f makes me feel dirty.

17:59 chouser: that's not really too bad. could use a second if-let inside

18:00 better than http://gist.github.com/560765 for example

18:00 jjido: raek: if I want to add fields to my reify'ed record, can I merge it with an existing record?

18:01 chouser: jjido: yep, but that won't bring in any implemented methods

18:01 ok, gotta run. ciao all

18:01 jjido: chouser: that's fine thanks

18:01 raek: ,(merge (reify) {:a 1, :b 2})

18:02 clojurebot: java.lang.ClassCastException: sandbox$eval8647$reify__8648 cannot be cast to clojure.lang.IPersistentCollection

18:02 raek: hrm, right.

18:03 reify is more like an anonymnous deftype rather than a defrecord

18:03 Munksgaard: Hi. I'm really lost here, how do i use the clojure-contrib functions? I'm on a completely fresh install, i've downloaded leiningen created a new project and downloaded the deps, but when i start a repl i cant use the contrib libs... Isnt it (:require clojure.contrib.math) ?

18:04 raek: that makes sure that it is loaded, but yoy can't use the vars in that namespace without qualifying the symbol

18:04 (clojure.contrib.math/some-math-fn 1 2 3)

18:04 AWizzArd: Munksgaard: do you have this (:require ...) inside a (ns ...) declaration?

18:04 Or do you try this in the repl?

18:05 raek: the corresponding function is used like this: (require 'clojure.contrib.math) ;notice the quote

18:05 Munksgaard: AWizzArd, i'm trying it in a repl, and i get classnotfoundexecption)

18:06 raek, (clojure.contrib.math/expt 2 4) gives me a classnotfoundexception

18:06 raek: Munksgaard: the :require variant is for inside ns only

18:06 AWizzArd: try it without the :

18:06 Munksgaard: raek, if i do (ns munksgaard (:require clojure.contrib.math)) i get nil and it just hangs

18:06 raek: hangs?

18:06 Munksgaard: i dont get a new promt (=>)

18:06 raek: there was a bug that made the output no flush sometimes

18:06 AWizzArd: in emacs?

18:06 cemerick: chouser: ^C ?

18:07 raek: try evaling 1 or something

18:07 Munksgaard: no, im in the terminal now, with lein repl

18:07 1 evals to 1 fine

18:07 raek: after the ns thingy too?

18:07 AWizzArd: Munksgaard: and what does happen when you say (require 'clojure.contrib.math)

18:07 Munksgaard: raek, oh, when it hangs? no

18:07 AWizzArd: i.e. not :require

18:08 Munksgaard: hmm

18:08 sec

18:08 raek: it shouldn't hang.

18:08 AWizzArd: and it should probably reply with nil

18:08 apgwoz: so, i'm trying to compile a simple clojure file using ant and failing miserably. i'd use leiningen and not have any problem, except i'm trying to integrate this with a bigger ant build...

18:08 Munksgaard: raek, hmm, it doesnt give me a new prompt, but when i typed in 1 it returned to functioning normally

18:08 AWizzArd: apgwoz: you already have a target for compilation?

18:08 clojurebot: compilation is see compile

18:08 apgwoz: i've gotten my build file down to the bare minimum, but it still fails. anyone able to take a look if i paste the error, and source?

18:08 Munksgaard: so i get a new prompt after evaling 1

18:08 raek: Munksgaard: then it was the output flush bug...

18:09 it has been fixed, but maybe not in the most recent jar

18:09 apgwoz: AWizzArd: yeah, i've created a second build file to figure out the problem

18:09 Munksgaard: raek, okay. So every time i want to use, say expt, i need to do (clojure.contrib.math/expt base expt)?

18:09 raek: Munksgaard: use ns declaration in source file, and the underlying functions at the repl

18:09 lazy1: Can we have http://richhickey.github.com/clojure* redirect to http://clojure.github.com/clojure* ?

18:10 raek: Munksgaard: replace require with use, and you don't have to do that

18:10 or do a (require '[clojure.contrib.math :as m])

18:10 AWizzArd: apgwoz: inside your target you should have something like <java classname="clojure.lang.Compile" fork="true"><sysproperty key="clojure.compile.path" value="${build.dir}"/><classpath refid="classpath"/><arg value="your.namespace"/></java>

18:10 raek: then you can use m/expt

18:11 apgwoz: AWizzArd: yup, I know

18:11 Munksgaard: raek, okay, cool. Thanks a lot both of you, i'll try to play around with it

18:11 AWizzArd: apgwoz: so, then it should work :)

18:11 apgwoz: https://gist.github.com/06cc3d292d10047ed5ee

18:11 it doesn't. i get this error

18:11 jjido: wow if what I just wrote works, I deserve an award

18:13 freakazoid: I've found that generally with clojure actually, jjido… I write something and it just works

18:13 and I'm surprised.

18:13 SLIME helps a lot with that

18:13 jjido: freakazoid: don't you get scared?

18:13 AWizzArd: apgwoz: on a first glimpse it does indeed look correctish

18:13 freakazoid: a little

18:13 but clojure's like my 27th programming language

18:14 apgwoz: AWizzArd: that's why I'm asking... :)

18:14 thanks for looking

18:14 freakazoid: though it's my first jvm language

18:14 lazy1: freakazoid: What was #1?

18:14 freakazoid: BASIC on an IBM PC in 1982

18:14 jjido: freakazoid: really? would you mind having a look at http://dodo.sourceforge.net and criticise?

18:15 lazy1: I guess everybody started with basic then (I d●●●●●●●●●●●●●●●●●●●●●●●)id

18:15 Ooops

18:15 AWizzArd: apgwoz: one thing that I would try is <arg value="com.thingy.feed-queue.core" /> (the underscore replaced by a minus)

18:16 apgwoz: AH! i bet that's it

18:16 AWizzArd: indeed. that did it

18:16 thanks for catching that!

18:16 AWizzArd: great

18:16 yes yes, this underscore-minus-thingy can be a tricky beast

18:17 freakazoid: jjido: I have not seen the terms "prototype" and "class" used together in that way before.

18:18 jjido: freakazoid: the class is quite standard though

18:18 freakazoid: only it is implemented using prototypes

18:19 AWizzArd: apgwoz: it seems you are doing Python. Do you use (or did you try) Jython?

18:19 apgwoz: AWizzArd: we're using it at work for some things, so yes

18:19 freakazoid: jjido: it looks like you have both

18:19 jjido: freakazoid: yep

18:21 anonymouse89: anyone have a problem with lein where "lein uberjar" hangs on "Copying .. files to .."?

18:21 jjido: freakazoid: the whole thing (save for parallelism) is constructed on top of prototypes and continuations

18:24 freakazoid: jjido: does dodo have call/cc?

18:24 jjido: freakazoid: nope I am against it

18:25 freakazoid: does it have TCO?

18:26 jjido: In general I am not a fan of the need to thread callbacks/continuations through the code; I'd much rather have some kind of lightweight thread, coroutine, or even generator that can just block, yield, etc.

18:28 though your syntax for it isn't bad

18:29 haskell's do syntax is a little cleaner.

18:32 having states built directly into the syntax reminds me of LSL

18:32 though in LSL they're script states

18:32 jjido: freakazoid: what is LSL?

18:33 freakazoid: jjido: that's Second Life's scripting language

18:33 jjido: an object can have an arbitrary number of scripts that each execute concurrently and independently. The scripts have multiple states and each state has a set of event handlers defined

18:34 the set of events is fixed and there are (very) primitive messaging facilities.

18:34 jjido: freakazoid: that resembles the scheme I defined for services

18:38 freakazoid: jjido: What I'd really like to see for dodo is an expansion of the top section where you talk about your design goals, particularly how each of your design choices drives you toward that goal

18:39 jjido: good idea freakazoid

18:40 freakazoid: I'm quite interested in finding out what new and rare ideas you're interested in

18:40 jjido: I have blog posts but they are in French

18:40 freakazoid: I follow ltu for fresh ideas ;)

18:41 freakazoid: Me too, though I can't understand half the papers on there

18:41 My understanding of type theory is still limited

18:41 I can derive it from first principles, but the language around it confuses me

18:42 hmm, that's true of a lot of math, cs, and physics papers, actually. I can understand the concepts involved, just not the language

18:42 jjido: same for me

18:43 freakazoid: I need to actually sit down and learn Haskell. I feel like it would be a big mind-expander

18:43 I only vaguely know OCaml or Haskell at this point

18:43 so all my languages are either old, crappy type systems like pascal or c++ or dynamically typed

18:44 turbofail: formal math notation vs. Haskell: http://www-formal.stanford.edu/jmc/puzzles/node3.html vs. http://okmij.org/ftp/Haskell/Mr-S-P.lhs

18:45 jjido: OCaml is not old? ;0

18:46 freakazoid: Its type system is pretty much Standard ML's

18:46 Yes, it's old

18:46 Sorry, I misread.

18:47 I don't know what you call Pascal and C++'s type systems

18:47 in a way they're weak, though most people consider them strongly typed

18:52 amalloy: freakazoid: i've heard C++ described as weak, static typing

18:52 freakazoid: then what's C?

18:52 C is weaker than C++

18:52 and than Pascal

18:52 Pascal and C++ seem about the same in terms of their strongness

18:52 amalloy: so? it's weak too, and also static

18:52 you don't need another word for every slight difference

18:52 freakazoid: I suppose that's true.

18:52 amalloy: C++ lets you cast anything to anything

18:53 that is pretty weak

18:53 freakazoid: it makes you jump through more hoops to do it though :)

18:53 and provides nice features like dynamic_cast

18:53 amalloy: yep. and that's what makes it static, mainly: the hoops

18:54 freakazoid: of course, you don't have to jump through any hoops to segfault though

18:54 amalloy: clojure is an interesting example of strong, dynamic typing: you don't need to know what type things are, but if you treat them as something else, the program fails

18:54 freakazoid: since there's no bounds checking and nothing at all to help you write safe multithreaded code

18:54 seems like most dynamically typed languages are strongly typed

18:54 amalloy: php

18:55 maybe python too, but i don't do any python so i may be misunderstanding

18:55 freakazoid: well, that's not true; automatic type coercion can lead to pretty hilarious errors.

18:55 amalloy: anyway i find it helpful to think of two axes: strong/weak, and dynamic/static

18:55 freakazoid: (that most of them are strongly typed)

18:55 that makes sense

18:55 I'd been thinking along those lines as well

18:55 python won't let you add an int to a string like perl and tcl will

18:56 so python's a bit stronger

18:56 I'm not a fan of any sort of operator overloading, myself

18:56 + should always mean "add"

18:58 technomancy: well you can add to a set.

18:58 in English

18:59 freakazoid: you really only run into trouble when operator overloading is combined with automatic coercion, I guess.

18:59 jjido: freakazoid: then I sinned ;) Dodo lets you redefine the operators, provided your type has the appropriate qualifier (+ is special, on its own in the Augmentable qualifier)

18:59 freakazoid: jjido: the real question is "what mistakes are programmers likely to make?"

19:00 jjido: freakazoid: use the wrong interface for their type?

19:00 freakazoid: and "how does your language help programmers avoid mistakes without using the expedient of making them repeat themselves?"

19:01 jjido: Also, too much state is not good.

19:01 freakazoid: yeah, the way Rust handles state seems pretty cool

19:01 and clojure

19:01 jjido: There are some parts that make the programmers repeat themselves

19:02 like, if you want private members then you need to define a public interface separately

19:03 For a library you also need to specify what to export

19:05 freakazoid: in my opinion Clojure is a bit inconvenient when you want state

19:05 but I don't know it that well yet

19:05 defn: freakazoid: i disagree -- i think it makes state easier to manage

19:06 when you're working on a clojure app -- you can point to specific functions and say: "look, this has state."

19:06 it just feels like you have more command over it

19:07 freakazoid: defn: I think you meant to respond to jjido. I agree with you :)

19:07 defn: oh sorry -- yeah

19:07 freakazoid: most languages don't really think at all about state

19:07 it's pretty much up to the programmer to either touch something or not touch it

19:08 and it's very syntactically convenient to mutate arbitrary data

19:08 the most convenient way should be the way least likely to have bugs.

19:09 defn: it felt weird at first, but i feel like it's "sloppy" to handle state in other ways now

19:10 abrenk: chouser: you're interested in how to easily build clojure-contrib with a customized clojure jar, right? what do you think about http://github.com/abrenk/clojure-contrib/commit/21a8ba7a3bed01008388f842c47054539f83e76a ?

19:11 jjido: freakazoid: my approach is: local mutations only in functions, do-whatever-you-want in constructors (which cannot be called from functions)

19:12 abrenk: chouser: I think I got rid of the hoops especially rhickey was complaining about

19:15 cemerick: perhaps you could also take a quick look at my latest change proposal to the clojure-contrib build (see url above)

19:16 cemerick: abrenk: Seems fine to me.

19:17 though, as I was saying to chouser earlier, using the ci-oriented build target implemented in clojure's build.xml should make building contrib against the last-built snapshot easy and automatic.

19:18 abrenk: cemerick: yeah, but only if you set maven to offline - otherwise it might overwrite your local snapshot with a more recent one from the snapshot repo

19:19 cemerick: abrenk: very true -- but that's very unlikely within the course of a 24-hour period.

19:19 defn: cemerick: re:githubfinder -- thanks for the credit on twitter :)

19:19 my coworker showed me that today and i freaked

19:20 cemerick: abrenk: I've been trying to get him and Rich away from a simple `ant; mvn` process for a bit :-/

19:20 defn: best way to view a github project without pulling source

19:20 cemerick: defn: credit?

19:20 Oh, right, I heard about it from you :-)

19:20 (too many handles in my life)

19:20 defn: yeah i was just saying thanks cause i saw it go across twitter but you gave me credit :)

19:20 cemerick: of course

19:21 defn: i forget about twitter

19:21 cemerick: Yes, it's a little absurd that every directory descent requires a full refresh.

19:21 defn: yeah, it's painfully hard to navigate a source tree

19:23 abrenk: cemerick: I'm just trying to soften the hard edges in the maven build so that the "talent" can focus on their areas of expertise

19:23 cemerick: abrenk: definitely appreciated :-)

19:23 do you have a CA in?

19:24 abrenk: it's on its way

19:24 cemerick: excellent

19:24 I wonder just how much time I'm going to end up talking about maven/build stuff at the conj...

19:27 abrenk: do you plan to record the talks? would be a nice addition to the blip.tv channel!

19:29 KirinDave: Oh man, I love clojure.

19:29 All my lisp instincts are coming back.

19:30 jjido_: ,(cons 2 9)

19:30 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer

19:31 KirinDave: jjido_: Does that surprise you? :)

19:31 It'd work in common lisp tho.

19:31 jjido_: KirinDave: exactly

19:31 KirinDave: There isn't much of a reason do have cons be a generic data structure in clojure.

19:32 The #1 reason was structure sharing (do you see my pun! this is a visual pun!) and the #2 reason was to make micro hashtables

20:12 gstamp: Question... if I (read) at the REPL I can read in an expression no problem however if I try (def my-val (read)) at the REPL I get a ClassCastException. Why the difference?

20:16 troussan: gstam: it works for me on 1.2

20:16 gstamp: hrrm. ok. i am still on the 1.2 beta. I'll upgrade and try again

20:17 KirinDave: gstamp: Let me guess

20:17 you're trying to do something like (def my-val (read))

20:17 And then type in an fn expression?

20:19 gstamp: Looks like it's working now. Sorry for the noise.

20:30 ataggart: is anyone here working on the master branch out of git?

20:47 rickmode: does defrecord support a docstring?

20:50 dnolen: ataggart: do you just mean using it?

20:51 ataggart: dnolen: yes. I submitted a patch that makes some changes to the way methods/contructors are resolved, and was hoping someone using 1.3. could try it out

20:51 rickmode: I don't think so

20:52 dnolen: ataggart: I can't test it out at the moment, but if you send me a link to the ticket/patch I can try it out later.

20:52 rickmode: ataggart: thanks. I don't see it in the docs, source or examples either. Odd inconsistency. oh well.

20:53 ataggart: dnolen: that'd be great. https://www.assembla.com/spaces/clojure/tickets/445

20:55 jjido_: does reify create a type, not a record?

20:55 ataggart: it creates a new anonymous clas that implements the interfaces/protocols

20:55 and then returns an instance of that class

20:57 so in that regard it's more like type than the mapiness of record.

20:57 jjido: ataggart: and if I want it to implement clojure.lang.IPersistentCollection?

20:59 ataggart: jjido: then you'd need to implement the methods. The particular approach depends a lot on what you're trying to accomplish.

21:00 jjido: What I am trying to do is to take a record implementing a protocol, and override one of the methods without creating a new top-level type.

21:02 I tried: (merge (reify myprotocol (mymethod [self] ...)) self)

21:09 suggestions?

21:11 ataggart: this is just a one-off instance?

21:11 Trying to understand the restrictions

21:13 jjido: ataggart: yes, just a one-off instance

21:15 created depending on arguments

21:15 ataggart: k lemme past something into gist

21:17 maybe like this: http://gist.github.com/610783

21:18 basically composition instead of extension

21:26 whoops, updated to include the missing protocol definition

21:27 jjido: ataggart: that is equivalent to my solution isn't it? What if you want to access a field of r2?

21:29 ataggart: depends on who's doing the accessing

21:29 if it's the reified instance, then you can reach the field

21:29 but not externally

21:29 since that field isn't part of the protocol

21:29 jjido: (defrecord R [gah] ...) ... (:gah r2)

21:29 ataggart: so, I infer the use of the refiied instance is not limited to the protocol definition

21:30 jjido: mmh no it is not. I could add an accessor but it would not be part of this protocol.

21:31 I will just do a new protocol for the accessor and be done with it :)

21:40 ataggart: eh, maybe the error I got was because of trying (merge) on a (reify). I need that to work (the record I use is not known in advance)...

21:41 I will have another look at (extend)

22:14 I give up... Looks like that is not possible in Clojure

22:17 Nate75Sanders: who's up for a drunken Visual Basic sprint?

22:17 sorry wrong window

22:18 lancepantz: hah

22:27 amalloy1: Nate75Sanders: does that mean we're not invited?

22:29 ataggart: jjido: if you just need to have the lookup behavior, then implement clojure.lang.ILookup

22:29 e.g., clojure.lang.ILookup (valAt [_ key] (get r key))(valAt [_ key nf] (get r key nf))

22:30 it's ugly, but it's possible

22:30 jjido: ataggart: ok... I need to check if that works for me.

22:32 ataggart: hmm, didn't realize until just now that records can't be used as fns like maps can

22:32 hsuh: leiningen question: suppose i want to use ring, don't know the last version, how would you do it ? clojars displays more than one match for ring

22:35 ataggart: iirc maven supports wildcarded versions

22:35 thus lein should

22:37 Nate75Sanders: amalloy1: no mouse allowed -- this is an all-keyboard drunken VB sprint

22:37 ataggart: luddites ;)

22:38 Nate75Sanders: I remember in my day we didn't have wildcards and we liked it

22:38 amalloy1: Nate75Sanders: it's cool, i use emacs on the terminal. i'll just have to learn vb :P

22:40 Nate75Sanders: There should be more "Rosetta Stones" in tech. Cookbooks are certainly a step in the right direction but Rosetta Stones would be good, too. I've tried to pick up emacs several times and it just didn't take. Maybe a rosetta stone isn't the right thing for this particular situation as vim and emacs are so different.

22:40 Rosetta stones seem right for languages, though.

22:42 I'm drunk and off-topic, though, so kick me out of the channel if need be.

22:46 amalloy1: haha. well, i'm only ignoring you cause you're not giving me name highlights, Nate75Sanders :P

22:47 Nate75Sanders: amalloy1: sorry man

22:48 amalloy1: i think emacs took for me (like three months ago) mainly because vi never took. so i'm not really the best source

22:48 ataggart: http://rosettacode.org/

22:50 Nate75Sanders: ataggart: thanks -- not bad

23:15 ldhanson2: I have a set which i'm trying to add into a sorted set. like (sorted-set-by comparator other-set). that gives a set with one element (the other set). what i want is each element of other-set to be added to the created set. i could do that with apply: (apply sorted-set other-set), but i can't pass the comparator in using apply. any thoughts?

23:31 amalloy: ,(let [myset (sorted-set-by <)] (into myset #{4 7 1 6}))

23:31 clojurebot: #{1 4 6 7}

23:31 amalloy: ldhanson2: ^^

23:33 of course, this still works if myset already has elements

23:33 ossareh: 'lo. Anyone run any jython stuff from their clj?

Logging service provided by n01se.net