#clojure log - Nov 12 2009

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

0:00 tomoj: I guess i can just do nested tests and put a binding around the main caller

0:51 durka42: does add-break-thread! still exist?

0:52 chouser: I think so, in repl-utils

0:52 is it not working?

0:52 durka42: oh, there it is

0:52 still useful :)

0:53 chouser: still violating Java deprecation warnings :-)

2:07 stephenj: clojurebot: latex \sum_{now}^\{eternity} all knowledge

2:08 clojurebot: latex \sum_{now}^{eternity} all knowledge

2:08 clojurebot: latex \sum_{now}^{eternity} {all knowledge}

2:09 clojurebot: latex \sum_{now}^{future} knowledge

2:09 clojurebot: latex \sum_{past}^{future} knowledge

2:13 clojurebot: latex \size=5/5 \sum_{past}^{future} knowledge

2:13 _ato: ~latex \sum_{t=0}^{\infty} \rm{knowledge}

2:14 stephenj: _ato: any idea how to make a bigger image?

2:14 clojurebot: a is b

2:15 _ato: \Large \LARGE

2:15 \huge

2:15 \Huge

2:16 stephenj: clojurebot: latex \large \sum_{past}^{future} knowledge

2:16 clojurebot: latex \LARGE\sum_{past}^{future} knowledge

2:16 clojurebot: latex \HUGE\sum_{past}^{future} knowledge

2:17 _ato: LARGE and HUGE seem to work

2:17 ~latex \LARGE\sum_{t=0}^{\infty} \rm{knowledge}

2:18 ~latex \HUGE\sum_{t=0}^{\infty} \rm{knowledge}

2:19 ~latex \Red\HUGE\sum_{t=0}^{\infty} \rm{knowledge}

2:20 _ato: Thanks

2:23 ~latex \HUGE\sum_{past}^future \rm{knowledge}

2:23 ~latex \HUGE\sum_{past}^{future} \rm{knowledge}

2:30 hiredman: fyi you can use chs=250x100

3:39 ,(doc close)

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

3:45 hiredman: (-> url URL. .openConnection .getInputStream ((juxt clojure.xml/parse #(.close %))) first)

3:47 ordnungswidrig: hi

6:01 stephenj: ~latex \chs=250x100\sum_{t=0}^{\infty} \rm{knowledge}

6:18 ~latex \Huge\sum_{t=0}^{\infty} \rm{knowledge}

6:21 ~latex {\chs=250x100\sum_{t=0}^{\infty} \rm{knowledge}}

6:21 ~def slurp

6:35 ~latex \Huge\sum_{t=0}^{\infty} \textcolor{red}\rm{knowledge}

6:36 ~latex \Huge\sum_{t=0}^{\infty} \rm\textcolor{red}{knowledge}

6:37 rhickey: cemerick: proper deftype field name support was a one-liner - the rest of the code was using munged names already

6:37 http://github.com/richhickey/clojure/commit/c58a6cfaf5788a104f4a1dcb488f731ad94a2da0

6:37 stephenj: ~latex \textcolor{red}{knowledge}

6:37 cemerick: rhickey: very nice :-)

6:37 stephenj: ~clojurebot

6:37 clojurebot: clojurebot is not a benchmarking platform

6:38 stephenj: ~def clojurebot

6:38 clojurebot: Titim gan éirí ort.

6:38 stephenj: clojurebot: location?

6:38 clojurebot: excusez-moi

6:38 stephenj: clojurebot: where are you

6:38 clojurebot: http://github.com/hiredman/clojurebot/tree/master

6:45 AWizzArd: Is there a way to do find-doc limited on a specific namespace?

6:45 maybe find-doc can take an optional arg which may be a string, symbol or namespace object, denoting a namespace, or a vector containing such?

6:48 penthief: I'm struggling to get this working in emacs -- what should I set the infereior-lisp-program to?

6:49 stephenj: ~latex \Huge\sum_{t=0}^{\infty} \forall\rm{knowledge}

6:52 ~latex \Huge\sum_{t=0}^{\infty} \exists \rm{knowledge}

6:57 ~latex \Huge\sum_{t=0}^{\infty} \rm\forall\Bigg\{{knowledge}\Bigg\}

7:00 ~latex \Huge\sum_{t=0}^{\infty} \rm\forall\Bigg\{{\color{red}{knowledge}}\Bigg\}

7:02 ~latex \Huge\sum_{t=0}^{\infty} \rm\forall\Bigg\{{\color{red}knowledge}\Bigg\}

7:02 ~latex \Huge\sum_{t=0}^{\infty} \rm\forall\Bigg\{{knowledge+learning}\Bigg\}

7:17 rhickey: for the next time someone mentions ERlang, SMP and share-nothing in the same sentence:

7:17 http://www.erlang.org/pipermail/erlang-questions/2008-September/038231.html

7:19 stephenj: ~latex \Huge\sum_{t=0}^{\infty} \rm\forsome\Bigg\{{knowledge+learning}\Bigg\}

7:20 ~latex \Huge\sum_{t=0}^{\infty} \rm\exists\Bigg\{{knowledge+learning}\Bigg\}

7:21 rys: Is there any way to interact with clojurebot privately? :p

7:21 rhickey: yes, please

7:21 AWizzArd: rhickey: interesting link, thx

7:22 stephenj: sorry - i am stopping now

7:23 AWizzArd: Kenneth Lundin is convinced that Erlang is the best in class, regarding utilizing multicore machines :)

7:24 rys: Smells somewhat like the Python GIL in terms of problems it'd have

7:30 gerry_: (defprotocol display (show []))

7:30 java.lang.IndexOutOfBoundsException (NO_SOURCE_FILE:0)

7:30 penthief: Hi, I had clojure working with SLIME just after I ran clojure-install, but when I try to (require 'slime) I get (void-variable package-activated-list)

7:34 gbt: penthief: so the clojure repl ran straight after you installed, but not when you restart emacs?

7:35 penthief: gbt: Yes exactly

7:36 _ato: penthief: did you add (clojure-slime-config) to .emacs as the install process states?

7:36 gbt: thats what I was thinking, I missed it when I first installed clojure-mode

7:38 _ato: maven's source code is bizaire, it has all this weird magical dependency injection stuff

7:39 makes it take like 10 times as much effort to do anything

7:40 penthief: No I've can't find that suggestion in any of the READMEs. Which (require ) should that go after?

7:41 gbt: penthief: no need for a require. The clojure-mode source code has a message telling you what to do

7:41 _ato: penthief: after you do the insall it pops it up in a buffer, saying something like "slime will break when you restart emacs unless you add this to .emacs" :P

7:42 penthief: just put it after you load package.el

7:42 penthief: or at the end of the file

7:42 gbt: mine broke, I was in such a rush to try clojure I never read the install instructions hehe

7:42 _ato: yeah, it should add it automatically like package.el does

7:43 penthief: Symbol's function definition is void: clojure-slime-config. I think I'll start again again.

7:43 gbt: penthief: do you use elpa? or the emacs starter kit?

7:43 penthief: I have installed elpa, yes

7:44 It works!

7:44 gbt: cool, happy hacking :)

7:44 penthief: Yes, I reread where you said AFTER you load package.el

7:45 _ato: :)

7:45 penthief: There is some clojure event in London I am going to tonight, and I didn't want to be sorting out my environment when I should be learning. Thanks very much!

7:46 gbt: nice, a clojure event. I didn't know they had started doing them over here

7:47 _ato: oh noes.. clojurebot died

7:48 penthief: Yeah, it's organised by LJC - London Java Community. I signed up the other week.

7:52 _ato: yay! I've got all the core pieces for clojars.org done now (basic web UI, database, repo deploy, jarspec/pom parsing, ssh+nailgun magic) just got to glue it all together, test, deploy and write some docs :)

7:53 gbt: I imagine the docs are the hardest bit :)

7:53 jgracin: Hi! Why is this throwing ClassCastException: Condition cannot be cast to IObj: (new clojure.contrib.condition.Condition {:type :t})

7:54 in clojure-contrib 1.0-compatible

7:56 in REPL, while trying to display it.

7:59 gbt: jgracin: I've never used the condition stuff. Are you working from an example?

8:02 jgracin: No specific example. I think it might have something to do with print-method, print-dup and Condition. The problem is not the Condition per se, but trying to print it.

8:03 gbt: don't know if this helps? but in the clojure/contrib/condition/example.clj code they use print-stack-trace *condition*

8:04 rhickey: gerry_: (defprotocol display (show [] "some doc"))

8:05 gerry_: doc is, er, required right now

8:06 gerry_: ok

8:09 chouser: ah, that was my first comment for this morning. need a nil in the nth

8:09 :-)

8:09 rhickey: that code needs some new code

8:09 chouser: oh

8:12 gerry_: rhickey: can defprotocol directly use field name of type in functions?

8:13 rhickey: gerry_: no, those are stand-alone functions, use (:field x)

8:14 I guess that nil is enough, still ugly

8:16 ok, fixed

8:16 gerry_: nice

8:22 (extend person display {:show (fn [] (println (:name person)))})

8:22 (show me)

8:22 java.lang.IllegalArgumentException: Wrong number of args passed to: user$eval--30$fn--32$fn (NO_SOURCE_FILE:0)

8:22 rhickey: (extend person display {:show (fn [a-person] (println (:name a-person)))})

8:23 all protocol fns should take at least one arg

8:23 chouser: and so it begins. :-)

8:23 rhickey: I can add a check and error for that

8:24 chouser: are you hinting at the disparity between this and deftype methods?

8:25 chouser: well, really just harking back to our earlier conversation about deftype methods, but now that you mention it ...

8:25 rhickey: I have thought about it, and there are just so many ways in which these things _are_ very diffferent

8:25 methods have field scope

8:26 methods are not first-class functions or values

8:26 chouser: that is true -- deftype methods are rather less like functions than any function-like thing we've had yet.

8:26 rhickey: protocol functions have no private access to class

8:27 methods connect directly to interface methods, protocol fns indirectly mapped

8:27 so, calling them different things and distinguishing is going to be important

8:27 chouser: the leading . acts as a little reminder to a lot of this.

8:28 rhickey: but there simply is no 'implicit this' option for protocol fns if you want extend to be ordinary fn, and mixin maps

8:28 chouser: yes

8:29 chouser: are - allowed in protocol method names now?

8:30 rhickey: were they not?

8:31 they are newly allowed for deftype fields

8:31 gerry_: (extend person display {:show (fn [a] (println (:name a)))})

8:32 (show me)

8:32 chouser: oh, ok -- I was avoiding them in an excess of caution

8:32 rhickey: chouser: obviously they won't map to an interface method without an :on

8:32 chouser: ah, sure.

8:33 gerry_: java.lang.IllegalArgumentException: No implementation of method: :show of protocol: #'user/display found for class: user.person__1 (NO_SOU

8:34 rhickey: gerry_: (defprotocol display (show [x]))

8:34 gerry_: yes ,have done that

8:34 rhickey: paste please

8:34 gerry_: i tried it on repl

8:35 lisppaste8: Chouser pasted "deftype is dominating me" at http://paste.lisp.org/display/90232

8:35 gerry_: ok

8:35 chouser: oh, hey, look at that

8:35 rhickey: (extend ::person display {:show (fn [a-person] (println (:name a-person)))})

8:36 ::person is the way to refer to a deftype type

8:37 extend ::D

8:37 chouser: ah, thanks.

8:37 rhickey: (consl (D 5) 6)

8:37 :consl #:D{:a 5} 6

8:38 gerry_: rhickey: change person to ::person, it works

8:39 rhickey: (doc extend) has that, will change wiki

8:40 gerry_: but i dislike the idea of "at least one arg"

8:40 rhickey: deftypes are named by keyword tags

8:40 gerry_: how could it choose the right fn to call without one arg?

8:41 gerry_: directly use fieldname of type

8:42 rhickey: ?

8:43 gerry_: defprotocol should have java "this" alike implicit arg

8:44 (.show me)

8:45 rhickey: gerry_: protocol fns are ordinary fns

8:45 defprotocol doesn't define any fns

8:45 are you suggesting defprotocol shoud say (show []) and extend should say (show [me] ...)?

8:46 er, :show (fn [me] ...)

8:46 because it can be - :show some-existing-fn

8:47 where some-existing-fn has nothing to do with protocols

8:47 i.e. extend is not a macro

8:48 cemerick: I'm mostly uninvolved here, but FWIW, I think protocols (like deftype) should be disconnected from the constraints/expectations of any particular host.

8:49 rhickey: cemerick: yes, but to what are you alluding?

8:49 cemerick: rhickey: mostly a tangential reference to gerry_'s invocation of a java-like 'this' arg

8:49 rhickey: ah

8:50 kjellski: Hi there =)

8:51 cemerick: I depend on Java interop constantly, but on *this* side of the fence, the more X-isms can be avoided, the better (unless they are actually positive design decisions in their own right)

8:51 gerry_: yes, (defprotocol display (show [x])) what is x ? abit weird,i think

8:52 rhickey: cemerick: yes, that's a huge design point of reify/deftype/protocols

8:52 chouser: it'll be very interesting to see how well it fits into various hosts

8:52 rhickey: gerry_: but confusing no, when defining the fn, that it take one more arg than the spec?

8:53 Bart001: hey everyone, need some help concerning to interop with java. i just started with clojure, so sorry for dumb qeustion. Is it possible to create a java object in clojure, to name the object and to reuse it, maybe as a parameter in a funciton in clojure?

8:53 rhickey: chouser: with no :on in protocols or interfaces in deftypes, should be pretty simple

8:54 chouser: Having tried Javascript, I don't expect that or other "normal" OO hosts to be a problem: clr, parrot, python, ruby

8:54 cemerick: to chouser's point, I think the biggest open risk right now is the unintentional slippage of java-isms into these independent entities. It would be great if someone were to pick up the task of building a backend in something decidedly not like java, just to ensure that independence.

8:55 chouser: Bart001: yes. are you wanting to create your subclass of a Java class, or just create an instance of an existing class?

8:55 rhickey: cemerick: yes, with cinc that should be very doable

8:55 leafw: rhickey: "A pubic constructor" in http://www.assembla.com/wiki/show/clojure/Datatypes -- funny typo

8:56 chouser: more interesting will the ObjectiveC, C++, google go, llvm hosts

8:56 gerry_: rhickey: only when fn need one arg except "this", will use (show [x])

8:56 rhickey: leafw: fixed -thanks

8:56 leafw: IIUC, a deftype/defclass will be java classes without java files, i.e. without the pain.

8:56 Bart001: i think only from existing classes

8:56 leafw: looking forward to using them.

8:57 kjellski: How can I do this in clojure? " a = b.foo(c); a.d(e); a = b.foo(f) ; a.d(e); // so that I´ll get my a out of that?

8:57 cemerick: leafw: they manifest themselves as Java classes, but are far from full interop. The tradeoff is a higher-fidelity construct for use in clojure code.

8:58 chouser: Bart001: (def my-number (Integer. 5)) ; create an instance of Integer, passing 5 to the constructor. Store the created instance in a new Var named my-number.

8:58 gerry_: (let [a (.foo b c)] (.d a e))

8:58 leafw: cemerick: I see deftype/defclass in the context of clojure-on-clojure: to become independent of the JVM. At the same time, they provide an efficient susbtitute to defstruct, even if more constrained.

8:59 kjellski: gerry_: Thanks!

9:00 rhickey: gerry_: I get the defprotocol side, but what of the extend side, (extend ... :show (fn [what?]...))

9:02 gerry_: rhickey: just :show (fn [] ..))

9:02 rhickey: gerry_: but the fn *will* be passed one argument

9:02 gerry_: and directly use fields of type

9:02 Bart001: chouser: ok, i think my question was wrong. i am working on a projec tot use a existing java programm via console. this consle is a clojure repl. so i need a function to create a java object in repl an reuse it in repl

9:02 rhickey: (show something)

9:04 dmiles_afk: has someone makde a clojure to jstatic/jcall/jfield .. system?

9:05 chouser: Bart001: I may still be misunderstanding you, but if not my example still stands. Replace Integer with the name of your own class you're wanting to instantiate, replace 5 with any other ctor args. But that whole 'def' line in the repl and now, in the repl, you can refer to that object by the name my-number

9:05 dmiles_afk: hrrm .. i need to rephgrase my Q a little

9:05 froog: I keep mixing up {} and #{}, thinking that a hash map should start with a hash

9:06 rhickey: Bart001: you want to create an object in Java and make it accessible to the Clojure REPL?

9:07 dmiles_afk: clojure by defualt imports allt eh methods of plan old java objects right?

9:08 rhickey: gerry_: that can't happen - the call (show something) needs to pass something to the protocol fn, and do so in an arg

9:08 dmiles_afk: clojure by defualt imports all the methods of plan old java objects right? - well the syntax allows you to call the method.. "import" is the wrong word

9:08 gerry_: rhickey: i'm confused with java and clojure, (show something) in clojure really has one arg,

9:09 rhickey: gerry_: well, I've got the code to catch the no-arg mistake, will push in a minute

9:09 chouser: I bet case is going to help finger-tree quite a bit

9:10 rhickey: chouser: could do

9:10 chouser: I've got (condp == x 1 (...) 2 (...) 3 (...)) in a few key places

9:11 Bart001: chouser, rhickey: i want to write a function which create java objects. this function is called in the clojure repl and the created objects may used as parameters for other functions, sorry for bad english..:)

9:13 rhickey: gerry_: ok, defprotocol will now throw if no arg in sig

9:14 sh10151: What's the best way to get a clojure-1.0 compatible version of the clojure-contrib JAR into a Maven repository?

9:14 gerry_: rhickey: good

9:14 chouser: I have a friend looking at google's go. from the little he's telling me they have constructs incredibly similar to deftype, defprotocol, and extends

9:15 Maddas: You mean the interfaces?

9:15 chouser: yeah

9:16 kjellski: gerry_: your answer to my question had nothing to do with e and f... that was what was outside my

9:16 srader: for java interop, how do you override, for example, paint method of a JFrame in Swing? Still use proxy?

9:16 kjellski: gerry_: err forget the text after ...

9:16 rhickey: chouser: I'm not sure they have any dynamic polymorphic nature at all though

9:16 sh10151: Will I just need to build a clojure-1.0 compatible version of clojure-contrib locally and install it?

9:17 chouser: the three independant declarations: define a data collection with no methods or interfaces. define an interface with method sigs but no impl or data. finally, tie those two together with some method bodies.

9:17 rhickey: probably not, nor immutable anything

9:18 rhickey: i.e. they address the expression problem similarly - independent, late implementations of interface methods, but I haven't seen how that works when the explicit type of the argument is not known at compile-time. Could be I just haven't seen it

9:20 chouser: I'm under the impression no value has unknown type at compile time.

9:20 oh, "explicit type" I see what you mean.

9:23 Bart001: is it possible to write a function which creates an java object, to call this function in the Repl and having a refrence to this created object to use it as parameter for other function called in the repl. maybe this is the right question

9:23 rhickey: ok, so here's the differences

9:23 go interfaces are method sets

9:23 any type implementing the methods impements the interface

9:24 chouser: yeah, I thought I saw that somewhere, but didn't understand

9:24 any *subset* of the methods, right?

9:24 rhickey: The base type must ... be declared in the same package as the method

9:24 ^^ that's the key difference

9:24 not independently extensible

9:24 chouser: ah

9:24 rhickey: they do have variables of (dynamic) interface type

9:25 so, really, subject to the same limitation as interfaces - definer of class has unique capability implement interfaces

9:25 does not solve the expression problem

9:28 Bart001: is there anyone who could help me?^^

9:29 rhickey: ugh, and because interface implementation is latent (i.e. have same method names and sigs, implement interface), then single name scope, another big problem of objects not in protocols

9:30 i.e. no problem in implementing multiple protocols that each have a 'foo' fn, because true foo functions are in namespaces and extend connects into specific protocols

9:31 so, no go for go

9:31 chouser: Bart001: I don't think we understand yet. can you explain the way that my earlier example is insufficient?

9:33 Bart001: because i want to write a function which creates this object via the repl

9:33 chouser: I gave you code that creates an object at the repl. You just want that inside a function?

9:35 Bart001: yes, but there is a problem with recalling the created object

9:36 i think i cant explain my problem ^^

9:36 chouser: We could write a function "make-thing" that you could call like this at the repl: (def my-thing (make-thing))

9:37 then you can recall the created object by using the name my-thing, like: (println my-thing)

9:37 I suspect you already know that, and it's still insufficient. Can you tell me in what way it is insufficient?

9:39 rhickey: go interfaces can mix in whole method sets from other interfaces -- you think this is not useful for protocols?

9:41 Bart001: i will give you an example... there is a class called Model and i want to write the function (new model [modelname]) that creats a new model referenced to modelname. so the user can create a new model and use it by calling the modelname

9:41 rhickey: chouser: well, they must have a compilation stage that looks at the whole package and determines what is going on. The interfaces themselves are not reified in the way that protocols are. Making a composite of specs is different from making a composite of concrete protocol objects

9:41 Bart001: everything via the Repl

9:41 rhickey: that's really the problem, plus the name combining and namespaces issues

9:42 chouser: Bart001: ah, you want to keep a whole collection of Model objects so that you can look them up by name?

9:42 Bart001: yeees..:)

9:42 chouser: Bart001: ok!

9:43 rhickey: I don't disagree there is some ease-of-ise to saying this protocol implies these others, but as we've discussed, no real change in the work of actually implement A, B, and C whether a la carte or ABCComboProtocol

9:44 chouser: rhickey: yes. I guess it feels like a difference to say at defprotocol time that ABCCombo is a named thing in its own right, even if its defintion is just the set of methods defined by A B and C

9:45 rhickey: vs. not connecting them at all with defprotocol and waiting until each extend to name the three together.

9:46 rhickey: chouser: because the implementation detection is a runtime thing, the biggest benefit of combining/inheriting interfaces is not present - it is a big deal to be able, in a statically type lang, to say you take an ABCCombo as an argument, unless your lang has generics or some way to say, my function takes x, where x isa A *and* x isa B *and* x isa C. Few do (Haskell does), maybe Java/Scala generics

9:46 chouser: Bart001: there are two ways to go -- store each model object in its own Var in your namespace, or store each model as a value in a hash-map. The first is a bit easier to use, the second a bit easier to implement.

9:47 rhickey: chouser: my experience has been that you do this because of the limitation of having to take an arg of a single type, and then later regret it when an interface brings in more than you need, not as composable

9:47 chouser: rhickey: ok, I think I follow that.

9:48 rhickey: i.e. I originally though every collection should have count, but it ends up being bad for some seqs. Now there's Counted

9:48 and I wish IPersistenCollection didn't have count

9:49 chouser: hmmmm

9:49 rhickey: over time many of the Clojure abstractions have been broken up into smaller bits so only those bits could be used a la carte

9:49 Bart001: chouser: okay.. thank you very much! i'll try

9:49 rhickey: so, protocols default to a la carte

9:50 because there's no static typing there isn't the pressure to produce a unifying type to serve as an arg type

9:50 but there is value in being able to say, A and B and C, if only as documentation

9:51 (satisfies? [A B C] x) ?

9:51 chouser: hm, seems reasonable. But you're out past any deep experience of mine, so my instincts aren't to be trusted. :-)

9:52 rhickey: the namespace issue is an important, unheralded feature of protocols

9:52 A and B can both have foo

9:53 chouser: rhickey: yes, the complete independance of method namespace from type namespace and now from protocol namespace is quite interesting.

9:53 rhickey: (extend atype A {:foo ...} B {:foo ...}), no problem

9:54 it is a critical flaw of using classes as namespaces, and the problem with monkey-patching even in dynamic langs with open classes

9:54 x.foo can only ever mean one thing

9:54 lisppaste8: Chouser pasted "models for Bart001" at http://paste.lisp.org/display/90236

9:55 rhickey: (your-ns/foo x) (my-ns/foo x), no problem

9:55 chouser: and is also why we

9:55 Bart001: thank you chouser

9:56 chouser: and is also why a protocol can be on an interface, and we'll be extending Java classes with new protocol methods.

9:57 rhickey: the first time you say (extend String ...) it's a lot of fun

9:58 Groovy supports a lot of that, but retains the interface model

9:58 Chousuke: so what will you do if two protocols define identically named functions?

9:58 chouser: so ... it feels like translating the persistent data structures and related interfaces will be extremely straightforward and now possible. Any reason to hold back still?

9:59 Chousuke: (Protocolname:foo ...)?

9:59 rhickey: Chousuke: there's absolutely no problem with that, protocols yield functions in namespaces, normal ns stuff applies

9:59 Chousuke: ah, right.

10:00 chouser: if two protocols in the same namespace define the same method name, only one survives?

10:00 or do they combine?

10:00 rhickey: chouser: no holding back, other than impl changes - I think that trying out some of the core abstractions as protocols is the next step

10:00 sh10151: anyone an enclojure user? trying to get a project REPL to start but I get a timeout

10:01 rhickey: chouser: in the same ns they collide, last one in wins

10:01 chouser: ok

10:02 Chousuke: chouser: How's your finger tree effort going?

10:02 rhickey: chouser: one way to think about it is that your ns used to be a bunch of independent fns a b c d e, now you are going to make them extensible, placing a b in protocol X and c d in protocol Y

10:02 chouser: Chousuke: loads through line 206 of 447. :-)

10:03 rhickey: I'd like to get rid of defclass, maybe today

10:03 chouser: but won't that break everyone's code!?

10:03 you know, all the people use defclass.

10:03 cemerick: rhickey: say again? :-P

10:03 Chousuke: :)

10:04 rhickey: cemerick: we spoke about this and you agreed

10:04 chouser: heh

10:04 Chousuke: is deftype going to be able to handle all the use cases of defclass then?

10:04 cemerick: oh, right, right, right

10:04 sheesh

10:04 rhickey: AOT compiled deftype === defclass

10:04 * cemerick limps back to his corner

10:05 rhickey: the only sticking point is the conflict between factory fn and type name

10:05 cemerick: been going in 14 directions today. Shift_JIS is not fun.

10:06 rhickey: Chousuke: will do, yes, subject to understanding that some of those features are static and require recompile/reload to see changes

10:21 fogus: cemerick: Well it originates with Microsoft, so that should have given you a clue to start. ;)

10:25 chouser: protocol and deftype names should be CapsCase? Caps-Case? caps-case-type?

10:27 Chousuke: not Caps-Case :(

10:28 chouser: I'm converting from Java interface types, so CapsCase looks pleasant so far.

10:40 rhickey: so if I want to get at a deftype field when the deftype implements its own IPersistentCollection, I either need to use .foo (which is reflective?) or provide an accessor function? But wouldn't using the accessor also use reflection?

10:41 kunley: Hi.

10:42 Anyone noticed if ztellman, author of penumbra (OpenGL bindings) is hanging around here?

10:43 rhickey: chouser: no, IPersistentCollection doesn't imply ILookup. Unless you are trying to implement map/associative, then (:field x) will still be available

10:44 chouser: oh!

10:45 rhickey: the power of non-derived interfaces :)

10:47 but we will need to expose the facilities of IDynamicType (soon to be IDeftype) .getDynamicField for cases where people are using ILookup for something else

11:02 chouser: so, you are shooting for no gen-interface right?

11:02 chouser: right

11:02 rhickey: cool

11:02 chouser: I'm there now, just working through the consequences.

11:02 rhickey: oh, those :)

11:02 chouser: "digit" works. :-)

11:04 rhickey: one consequence should be a more dynamic dev cycle

11:04 chouser: yes, though it was surprisingly descent before.

11:05 fogus: rhickey: That's a "consequence" that I'm all for

11:05 chouser: mostly re-loading was my file was sufficient. occasional re-start of the repl followed by (compile ...)

11:06 I don't even have it properly namespaced -- the compile would do it's gen and then fail to load, but then loading the .clj manually and I was off and running again.

11:06 that was because of newnew's already lovely behavior

11:07 rhickey: yeah, one thing I've been thinking about is - what is to protocols as reify is to interfaces?

11:07 and if there need be such a thing

11:28 chouser: right now my code for each deftype is split in about half between deftype methods and extend methods. as the collection interfaces move to protocols, I expect my deftypes to shrink to nothing but fields.

11:28 rhickey: that's the idea

11:30 chouser: none of these is sitting as cleanly in "interop" vs "native" as I was expecting.

11:30 none of deftype, reify, defprotocol I mean

11:41 replaca_: kunley: ztellman is in here sometimes, but not so often

11:45 Kjellski: chouser: What´s that about?

11:46 chouser: Kjellski: what's what about?

11:46 Kjellski: chouser : What you just wrote, what´s the context?

11:47 chouser : Or where can I find a channel log? ^^

11:47 chouser: ~log

11:48 hmph. http://clojure-log.n01se.net/

11:48 Kjellski: chouser : thanks

11:49 chouser: oh, I see where you came in. I'm talking about moving my finger-tree implementation from def-interface+reify over to deftype+defprotocol+extend

11:50 http://github.com/Chouser/finger-tree/blob/master/finger_tree.clj

11:55 Kjellski: chouser : uff... I think that´s not my league...

11:56 chouser: not really mine either

11:56 one thing that I can do in clojure better than any other language I've yet tried: solve problems beyond my understanding.

11:57 Kjellski: chouser : interesting... someday I hope, that´s the case for me too

11:57 fogus: chouser: That should be our subtitle!! Idiomatic Clojure: Solving Problems Beyond Your Understanding

11:58 chouser: hm!

11:58 pretty attractive...

11:58 who wouldn't want to do that?

11:58 fogus: really

12:00 Kjellski: I have a problem with overriding a variable, trying to translate the following java code, where this is a proxy, could someone have a short look? http://pastebin.com/m3863f96e

12:00 gbt: as a noob who's relied on clojure-mode to install clojure what do I need to do to get a version with the protocol's?

12:00 Kjellski: I would need the sipProvider at the end...

12:01 ~wiki

12:02 the-kenny: Kjellski: You can nest lets inside... But in clojure, using variables should be avoided

12:02 chouser: (doto (.createSipProvider sipStack tcp) (.addSipListener (proxy [] ...)))

12:02 let would be fine too

12:02 liwp: gbt: find your clojure git checkout on disk and checkout the new (?) branch

12:02 rhickey: gbt: you can try clojure.jar from here: http://build.clojure.org/job/clojure%20(new)/10/

12:04 Kjellski: I figured out how to call the first two methods, but how could I call the second, Or should I only use a tmp name and return the last, when the first is overriden from line 3?

12:04 gbt: thanks, I'm getting it now :)

12:06 Kjellski: rhickey : I´ve got a presentation in university in about two weeks, where I wanted to talk about clojure, may I borrow the logo for my presentation title page?

12:06 chouser: Kjellski: your java code is overwriting the sipProvider -- do you mean to be doing that?

12:06 rhickey: Kjellski: if it's about Clojure, sure

12:07 Kjellski: rhickey : Thanks, and yes, its name will be: "Clojure - concurrency revisited"

12:09 chouser : Actually it´s not my code, its from an example, but I think it could mean that... before that, sipProvider is never defined, like that is just a workarround for setting things for a factory above...

12:30 hamza: hey guys, i want to represent a tree structure (file folder in a directory) in a clojure application, i was thinking of doing it like the xml stuff and wrap every level in vectors? would you approach it like this or any other recommendation?

12:32 the-kenny: hamza: I think I would do it so. You should also have a look at: http://clojure.org/other_libraries#toc5

12:38 hamza: thx ill check this out.

12:56 chouser: if a deftype wants some pre-computed fields (based on ctor args) the only way to do that is to provide a separate factory fn that is used by convention rather than the generated factory fn?

12:59 rhickey: chouser: yes

12:59 chouser: would it be evil to redef the generated var?

12:59 rhickey: the general idea is that the 'raw' interface is for implementors, not necessarily end-user clients

13:00 yes, evi;

13:00 evil

13:00 chouser: ok

13:00 rhickey: defclass is ... gone

13:11 alinp: hi guys

13:11 does anyone using vimclojure ?

13:13 Kjellski: I did, why?

13:14 alinp : What´s your question, mybe I can help...

13:14 alinp: I can't start the REPL no matter what I do

13:15 to be honest, I don't know how to use "\sr"

13:15 I mean, I can't start it

13:15 I started the nailgun server ... and all the stuff

13:15 did the ant install ... etc

13:16 everything went fine

13:16 I did everything that is written in the README

13:18 Kjellski: Hmmm... you are sure the repl is life?

13:19 alinp: what do you mean ?

13:19 Kjellski: You´ve started the nailgun server through the vimclojure command?

13:20 alinp: Just a sec, booting up my linux machine...

13:20 alinp: I started the nailgun from a separate console

13:21 java -cp ... bla bla

13:21 :)

13:21 and started

13:22 Kjellski: alinp : *booting* ... sorry, that machine is a bit older then...

13:22 alinp: ok ok ... np

13:25 chouser: cons dispatches on the wrong arg

13:26 Kjellski: alinp : ... just a few seconds then...

13:26 alinp: :) ok

13:27 duncanm: rhickey: have you read the 'categories' system that mike evins wrote about a while back? http://mikelevins.livejournal.com/5060.html

13:28 rhickey: also, what you said about having namespaces in protocol method names this morning reminded me of the 'explicit interface implementation' feature in C#

13:29 Kjellski: alinp : *figuring out how that went...

13:29 rhickey: duncanm: yes, read that

13:29 duncanm: rhickey: mikel evins also wrote a OO system for Clojure, and he's written that he's thinking about porting his current code (in Gambit Scheme) back to Clojure

13:29 rhickey: duncanm: and yes, C# did this better than Java

13:29 duncanm: rhickey: i haven't been able to follow all these different threads of discussion, but it seems like they're all somewhat related

13:29 rhickey: duncanm: he and I had extended discussions on the list about hierarchies etc

13:30 duncanm: oh, that's great

13:30 rhickey: we ended up disagreeing

13:30 duncanm: ahh ;-)

13:30 rhickey: which is ok

13:30 duncanm: sure thing

13:30 rhickey: he more CLOS-influenced

13:30 I want to get away from hierarchy

13:30 duncanm: rhickey: his new post said something similar too, that he's preferring the 'flat' domain more than the c3 domain

13:31 http://mikelevins.livejournal.com/5851.html

13:31 so maybe your opinions are converging

13:35 Kjellski: alinp : depressing... actually I can´t figure it out. It was really simple...

13:36 alinp: yeah, that is how it looks like .. but ...

13:36 Kjellski: alinp : Sure you´ve read this right? http://kotka.de/projects/clojure/vimclojure.html

13:36 alinp: oh

13:36 managed to started it :o

13:37 Kjellski: alinp : congrats! how?

13:37 alinp: I had in the vimrc file :set nocp

13:37 and it seems that affects the plugin ...

13:37 wlr: Wow! What lightweight analysis by Information Week: http://tinyurl.com/ygv2uy3

13:37 alinp: when pressing "\"

13:38 Kjellski: alinp : okay, that´s weird... should be suggested in the docs...

13:38 alinp: not very sure how/why this affect it

13:38 sorry Kjellski and thanks for your time ;)

13:39 Kjellski: alinp : no problem, nevermind... reminded me on the graphics failure of my linux pc... *urgs* ATI card...

13:40 alinp: :)

13:40 duncanm: hmm

13:40 chouser: is there a defprotocol/deftype implementation of fingertree?

13:41 chouser: not yet

13:41 Kjellski: wlr: outch, that hurts hanging arround in this channel...

13:41 duncanm: chouser: what's the reason for using a letfn? is that kinda like a letrec in Scheme?

13:42 chouser: duncanm: I measured a slight performance boost using letfn over vars.

13:43 duncanm: but that doesn't fit with defprotocol/deftype, so I'll be walking that back.

13:43 duncanm: ahh

13:45 patrkris: does anyone here know if it is possible to just get indenting and syntax highlighting from VimClojure, i.e. without the REPL-in-Vim and so on?

13:46 chouser: patrkris: yes, that's how I use it

13:46 patrkris: Ok, so what do you do? Just copy clojure.vim from indent and syntax into ~/.vim?

13:46 the-kenny: I want clojure-support in lejos

13:46 patrkris: chouser: and of course file plugin indent on and syntax on

13:47 chouser: patrkris: I think I ran the ant install thing, but then just didn't set want-gorilla thing

13:47 patrkris: chouser: ok, thanks, i'll give it a try

13:47 chouser: which version of VimClojure are you using, a recent version or an old version?

13:48 chouser: fairly recent, I think.

14:08 leafw: how come sorted-set-by requires at least one element after the comparator? Can't one create a sorted-set with a comparator initializing it without elements?

14:12 lisppaste8: leafw pasted "untitled" at http://paste.lisp.org/display/90245

14:12 leafw: comments on the sorted-set-by problem pasted above appreciated.

14:13 chouser: Clojure fns implement Comparator

14:14 leafw: chouser: you mean the comparator could just be a simple fn ?

14:14 with two args

14:14 ?

14:16 chouser: ,(reduce conj (sorted-set-by #(int (- (%1 :med) (%2 :med))) {:med Double/MAX_VALUE}) [{:med 1} {:med 6} {:med 10}])

14:16 clojurebot: java.lang.Exception: Unable to resolve symbol: sorted-set-by in this context

14:16 chouser: that's a comment, though, not a solution to your problem. :-)

14:17 leafw: chouser: indeed. Thanks though.

14:20 AWizzArd: was so busy with work, i did not really see all updates.. so, defclass is gone now right?

14:21 rhickey: AWizzArd: yes, deftype can do everything defclass did

14:21 AWizzArd: Fine, I was using deftype exclusively anyway :)

14:21 and i saw a mention about java naming conventions.. is it now possible to do again (:my-field my-deftype)?

14:21 rhickey: yes

14:21 AWizzArd: This is running into an error in my version as my-field is not a valid var name in Java

14:22 but my checkout is several days old

14:22 chouser: leafw: looks like a bug to me

14:22 AWizzArd: oki, sounds good, so I will checkout a fresh new branch

14:22 thank you :-)

14:22 oh, and protocolls are also ready

14:23 hmm, can i use this somehow to create some kind of hierachies?

14:23 headius: what exactly are protocols?

14:23 I looked at rich's patch but I didn't understand what it was for

14:23 rhickey: headius: they are like interfaces but...

14:23 chouser: leafw: sorted-set-by allows for an empty list of initial values, but passes that on to PersistentTreeSet/create as null, but create doesn't check for null it just blindly calls .length on it.

14:23 rhickey: don't create a hierarchy

14:23 AWizzArd: i have tokens, very general objects, but i have word-tokens, digit-tokens, date-tokens, zip-code-tokens, etc

14:24 jonase_: How do I implement an interface with extends? (extend ::AType clojure.lang.Counted {:counted (fn [o] ...)}) doesn't seem to work?

14:24 rhickey: can be independently implemented, not just by the type's original author

14:24 headius: so it's for enforcing/ensuring that a set of operations are available?

14:24 rhickey: headius: so, they are a polymorphism mechanism

14:25 because deftypes don't have operations other than for interop purposes

14:25 chouser: (sorted-set-by <) ; fails, but shouldn't

14:25 rhickey: operations are always stand-alone functions

14:25 protocols are polymorphic on their first argument

14:25 headius: ok, I think I follow

14:26 rhickey: so they might feel like methods, but differ in that they aren't 'in' the class

14:26 AWizzArd: can i use protocols to create a function that will work for all tokens, even if i pass in an instance of (deftype zip-code-token ..)?

14:26 rhickey: and from that follows that they are not in a class name scope

14:27 so unlike monkey patching, independent protocols can define operations with the same name without conflict

14:27 headius: because you call through the protocol, I assume?

14:27 AWizzArd: hmm

14:27 best thing i will try it out tomorrow

14:27 rhickey: headius: right, the protocol ends up defining regular namespaced functions

14:28 so there's no protocol object in the call, but my-ns/foo and your-ns/foo are different functions, only one of which can be used without qualifier in another ns

14:29 headius: how does this differ from just defining namespaced functions

14:29 that you call through

14:29 rhickey: the protocol generates these functions and embeds the dispatch logic

14:30 so the function is extensible

14:30 ordinary functions are not, just redefine/replace

14:30 duncanm: so there's something like 'super'?

14:31 headius: ok...so it handles defining the protocol via namespaced functions, allowing calls in a given scope to look like regular function calls but actually be namespaced by the protocol

14:31 or something :)

14:32 twbray: what's the latest on wide finder stuff?

14:32 rhickey: the function is in a namespace as usual, the protocol defines it so that inside there is dispatch on first arg

14:32 leafw: chouser: ok, thanks. Are you submitting a bug report?

14:32 rhickey: and when it is extended, the protocol redefines the function

14:33 Kjellski: ,(doc ->

14:33 clojurebot: EOF while reading

14:33 twbray: headius: I'm at the cottage hooked up via dial-up. Will be working on it again starting on Friday. At the moment, haven't figured out how to workaround the gc thrashing

14:33 Kjellski: hiredman : I´ve done my homeworks...

14:33 ,(doc apply

14:33 clojurebot: EOF while reading

14:33 AWizzArd: rhickey: and the first argument is dispatched on what? The (class of-the-object)?

14:33 rhickey: AWizzArd: type, then class

14:34 AWizzArd: ,(doc type)

14:34 clojurebot: "([x]); Returns the :type metadata of x, or its Class if none"

14:34 chouser: leafw: I'm not -- I think such things are supposed to be posted to the google group first.

14:35 headius: twbray: you might try a shorter run with -Xrunhprof to see what sort of object counts you're getting

14:35 twbray: headius: OK; any and all input welcome.

14:35 headius: ^C it any time you're satisfied it's hit the bulk of its work and it will dump out a java.hprof.txt file with object allocation counts

14:36 other than tweaking your code or trying G1, however, I'm running out of ideas

14:36 leafw: chouser: ok

14:36 twbray: headius: it dumps when it finishes running?

14:36 headius: if it's a lot of garbage, it's just a lot of garbage

14:36 twbray: yes

14:36 lisppaste8: rhickey pasted "protocol twiddling" at http://paste.lisp.org/display/90249

14:36 twbray: Haven't got G1 going yet, got a query into jrose as to why my JRE doesn't seem to have it

14:37 headius: rhickey: so this seems similar to what I want to do with duby for reopening classes; they'll work basically like extension methods in C# and just pass an implicit "this" argument to a static body

14:37 only the extensions in scope when you compile will be available to callers

14:38 rhickey: headius: except these are not scoped things

14:38 extend is a global extension

14:38 cemerick: rhickey: your keynote is up: http://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey

14:39 rhickey: cemerick: that was relatively soon

14:40 headius: rhickey: yes, this would just apply to the code compiled with a given extension enabled...but of course Duby can't actually modify Java classes already defined

14:41 I assume this all only applies to clojure types too

14:41 i.e. I can't add a protocol to java.lang.String?

14:41 leafw: chouser: can I quote you directly?

14:41 chouser: headius: ah, but you can!

14:41 leafw: sure

14:41 rhickey: headius: sure

14:42 headius: because protocols are not about methods inside classes - they are polymorphic functions outside of classes

14:42 headius: ok, so it's not far off from extension methods

14:42 leafw: chouser: it's done.

14:43 rhickey: in the paste I just did, Number is java.lang.Number

14:43 headius: but mostly done at runtime

14:43 chouser: leafw: thanks

14:43 headius: foo gets defined as a normal function that ensures the target supports a given protocol and then dispatches through it

14:43 protocols can be added to known types after the fact

14:43 ztellman: does anyone have experience analyzing SIGSEGV crashes?

14:44 headius: I assume there's some mapping somewhere to maintain the list of protocols a given type has had glommed onto it

14:44 rhickey: the things about methods is that a class/object constitutes a namespace, not so with protocols

14:44 ztellman: I'm getting one in linux, with code that works perfectly fine on os x

14:44 chouser: ztellman: the JVM is segfaulting?

14:44 ztellman: chouser: yes

14:45 there's JNI in the mix

14:45 rhickey: the set of implementations is in the functions, not the objects/classes, and the functions are in namespaces

14:45 chouser: oh

14:45 ztellman: it says the error is in libjvm.so, rather than any of the .so I'm using, though

14:45 I don't know if that's a red herring

14:45 headius: rhickey: so does the protocol maintain the mapping between types and "foo" functions then?

14:46 rhickey: headius: yes

14:46 headius: and it locates them based on the actual type of the first argument

14:46 rhickey: there is a lookup, but caches based on class of arg

14:47 there are tagged types, then classes/interfaces of Java

14:47 headius: so it's still basically namespaced

14:48 since it has to be associated with a type in order to locate it

14:48 cemerick: it just dawned on me that protocols get type reification in the jvm's backdoor, without any significant penalty

14:48 headius: cemerick: how's that

14:48 it's just a call through with a table of type => function mappings

14:49 rhickey: headius: I don't see that, since 2 protocols can both have different foo for String

14:49 headius: and how does it differentiate between the two?

14:51 rhickey: a protocol is in a namespace, and generates foo in that namespace. The true name of foo is that-ns/foo. A second protocol is in another namespace, that foo is another-ns/foo

14:51 you can say (extend String AProtocol {:foo ...} BProtocol {:foo ...})

14:51 headius: ok, I guess I'm confused by you saying it's namespaced but then saying it's not namespaced

14:52 the "magic" foo is tied to a specific namespaced foo within a given namespace

14:52 rhickey: headius: I'm not sure what to presume you know about Clojure's namespaces

14:52 headius: each foo protocol in separate namespaces keeps its own mappings of type => foo function

14:52 is that about right?

14:53 rhickey: the protocol is a mapping of types to maps of names to functions

14:53 headius: I know practically nothing of clojure's namespaces, so feel free to punt if I'm just not getting it

14:53 I feel like I understand though

14:53 Kjellski: cya =) good evening...

14:53 rhickey: it places the dispatch into a function of the same name in a namespace

14:53 bitbckt: RubyConf should be entertaining, with all of this Clojure injection...

14:54 headius: right, so foo is that-ns/foo which has a set of type => function mappings for the ultimate "foo" targets

14:54 rhickey: for users, calling protocols looks like calling ordinary function, and deciding which to use, like ordinary require/use stuff

14:54 headius: sure

14:55 rhickey: but unlike trying to place methods in classes, there is not the limitation of one foo per type

14:55 x.foo

14:55 is not x.my-ns/foo

14:56 in most langs

14:56 c# does the right thing

14:56 java merges

14:57 headius: right, I see this as what C# does

14:57 twbray: Wrote a short piece on using refs in Wide Finder: http://www.tbray.org/ongoing/When/200x/2009/11/11/Clojure-References

14:57 G0SUB_: someone needs to write a doc explaining the protocols and types feature. with nice examples and comparisons.

14:58 danlarkin: G0SUB_: it's not done

14:58 G0SUB_: danlarkin: I know, but whatever is coming, or even the basic premise.

14:59 technomancy: twbray: you author your posts in Emacs, right? may I recommend the excellent htmlize package for syntax-highlighting code snippets?

14:59 headius: rhickey: this basically seems like what I want to do, thanks...Duby will work like C#

14:59 technomancy: when I try to read monochrome code my brain just refuses to function.

14:59 headius: but all static, of course

14:59 bitbckt: technomancy: +1

15:00 twbray: technomancy: yeah, but the CSS it generates interacts toxically with mine, I have to do some horrible CSS spelunking to figure out what's happening. :(

15:00 technomancy: twbray: ah, bummer. there's an alternate package you might have better luck with called html-fontify, but I haven't used it myself.

15:00 rhickey: headius: but if you are talking about C# extension methods, I am not

15:01 drewr: I'm trying to get my head around how this is useful http://gist.github.com/233223

15:01 if you extend String, how would one baz get dispatched over another?

15:01 bitbckt: naively, it looks last-in

15:02 rhickey: I am talking about C# inheritance - if you get foo from 2 interfaces they are not merged - you can refer to A::foo and A::foo, and have different implementations. When used polymorphically as an A - you get your A::foo impl

15:02 somnium: has anyone gotten the new branch working with swank?

15:02 rhickey: A::foo and B::foo above

15:02 chouser: drewr: you don't want to have two protocols with the same methond name in the same namespace

15:02 rhickey: in Java if you inherit foo from 2 interfaces you get a single implementation

15:03 headius: yeah, I don't know if I'd agree that c# does it "right" there, but I understand

15:03 C# does it the C++ way

15:03 rhickey: merging is definitely wrong, as the semantics might be completely different, even if the signatures are the same

15:04 drewr: chouser: yeah, that makes sense, but even if they were in different nses the dispatching doesn't make sense

15:04 headius: then you don't use those interfaces together because they have conflicting contracts

15:04 rhickey: this was a point Ola Bini and I raised re: the interface injection proposal

15:05 headius: but you can't necessarily choose the interfaces you implement since often they are requirements of APIs with which you need to interoperate

15:05 chouser: drewr: if they were in different namespaces, there would be two different baz functions, you'd pick which you mean by saying (upper/baz ...) for example.

15:05 rhickey: the bottom line is that classes make crummy namespaces

15:05 headius: sure, no argument there

15:06 I can see the problem of conflicting interfaces, but I don't see that one answer is better than another

15:06 rhickey: but using the C# stuff, you realize that, as an implementor of C derived from A and B, there is no conflict in supporting both semantics

15:06 and as a consumer of A interfaced passed as C, you will get yhe semantics you want, ditto B

15:07 so any problems here are strictly for people that want a global view of C, not consumers of the abstractions

15:07 drewr: chouser: ok, I wasn't see the demarcation line between protocols and their impls

15:08 chouser: rhickey: should there be a warning in drewr's case? Two differently-named protocols in the same namespace defining the same method name?

15:08 rhickey: chouser: how to detect?

15:08 drewr: the idea is that you can have a namespace that defines and operates on a proto, and another client ns where the impl is tailored to fit

15:08 headius: gotta run, bbl

15:09 chouser: can't Bar see that baz exists already for Foo?

15:09 I haven't looked at the defprotocol implementation at all yet.

15:09 rhickey: chouser: baz is just a fn

15:10 we could use var metadata for this

15:10 chouser: rhickey: stick the ... just going to say that

15:11 put the protocol name in the var's metadata -- if it matches, presume this is an intentional overwrite. name does not match, print a warning (not an error because maybe they're renaming the protocol or something)

15:11 rhickey: patch welcome

15:11 chouser: woo! Can't get to it until tonight, but I'll look then.

15:12 cemerick: twbray: I don't see a source link, but why use refs? If you're asynchronously processing N lines at a time from the log file, agents would be the way to go.

15:13 twbray: cemerick: I'm using some agents for part of the pull-lines-out-of-the-file-in-multiple-threads

15:14 I suppose it could be done with agents; not obvious why that would be better. All I'm doing is calling inc on a number, hardly seems worth its own thread

15:14 cemerick: twbray: I'm not super-familiar with the widefinder problem, but I'd say set up some number of agents, have your primary caller chunk through each line, dispatching (sending) each line off to an agent, and then await on all agents to collect results.

15:15 twbray: Once I've killed the gc problems, I'll have a try with agents and see if that makes a difference..

15:15 cemerick: twbray: agents and threads are *not* 1:1

15:15 and you wouldn't pay the price of transactions at all

15:15 twbray: Gotta go, later

15:24 shoover: Also record/incr look like a race condition

15:24 Shouldn't the transaction include the counter check?

15:44 somnium: trying to try out new branch, getting error: NoSuchMethodErrror: clojure.lang.RestFn.<init>(I)V with some contrib libs from build.clojure.org, am I doing something wrong?

15:45 the-kenny: somnium: You have to rebuild contrib

15:47 chouser: might need to do ant clean first

15:49 rhickey: (instance? X nil) returns false. satisfies? throws NPE

16:19 hiredman: I've recently noticed vim's undo is mangling my clojure source files

16:19 :(

16:19 hamza: emacs ftw :)

16:20 hiredman: if I wanted your opinion I would have asked

16:24 hamza: just joking man, no flame war intented.

16:42 rhickey: chouser: fixed

16:47 michaeljaaka: people there are two cool options

16:48 clojure-mode for emacs

16:48 and enclojure for netbeans

16:48 these editors are very cool

16:48 especially for netbeans if you are planning to mix your written java + just written in clojure modules

16:57 chouser: rhickey: thanks!

16:58 unfortunately that's not the only NPE I'm getting :-P

16:58 rhickey: send em on!

16:59 chouser: yeah, I think this one's my fault.

17:02 * chouser finds where the @ was missing.

17:07 srader: rhickey: lines 5440-5441 in compiler.java are repeated from previous lines

17:09 rhickey: huh

17:13 srader: lines 5437-5438 are the same as lines 5440-5441. duplicates.

17:19 rhickey: srthanks

17:19 srader: thanks

17:26 lisppaste8: Chouser pasted "chain of agents" at http://paste.lisp.org/display/90261

17:36 srader: chouser: nice!

17:37 slyrus_: is swank-clojure broken for others, or is it just me?

17:38 somnium: slyrus_: with new branch?

17:38 slyrus_: (going back to Sept. 28 works)

17:38 branch?

17:38 somnium: I have an old version, attempts to upgrade haven't worked

17:38 slyrus_: git branch -a doesn't show any branches

17:38 somnium: I ment clojure's new branch

17:39 slyrus_: oh... i'm using the HEAD as of last night

17:39 somnium: I suspect swank will need to be rebuilt to work with it, but it seems were talking about different things

17:39 _ato: HEAD of swank-clojure is working fine for me

17:39 slyrus_: how do I rebuild swank-clojure with the new maven stuff?

17:41 * somnium eagerly awaits the arrival of the new swank on elpa

17:41 * slyrus_ knows nothing about maven (other than that he installed earlier today)

17:41 slyrus_: would have preferred keeping it that way...

17:42 technomancy: slyrus_: you can use the "maven" branch without using maven itself

17:42 you only need maven if you're going to hack on the swank-clojure source itself; see the readme in the maven branch

17:42 slyrus_: well, yeah, i figured that. but what do you mean by "use"

17:43 technomancy: actually at this point it's probably best to wait for it to land in elpa

17:43 the install-by-hand process is tedious

17:47 duncanm: technomancy: is it gonna land soon?

17:48 technomancy: duncanm: unfortunately the elpa upload process is still manual... total crap shoot on how long it takes. I'll ping the maintainer later tonight.

17:51 hiredman: ~web dev

17:51 clojurebot: web dev is the worst dev

17:51 somnium: hiredman: struggling with facebook php?

17:52 hiredman: no

17:52 facebook clojure :P

17:53 mostly facebook and appengine

17:53 and librarything not updating rss feeds for up to 26 hours at a time

17:54 somnium: the facebook api looked truly hideous, datastore didn't seem that horrible

17:54 hiredman: there's always slicehost :P

17:55 hiredman: appengine isn't too bad, just makes debugging with println's difficult

17:55 facebook is not too bad, as long as you don't use any of the java clients, and just make api calls directly over http

17:56 chouser: heh

17:56 hiredman: but all those combined + librarything's rss latency is maddening

17:57 http://gist.github.com/233395 <-- clojure facebook "api"

17:58 duncanm: hiredman: why couldn't you use the java clients?

17:58 hiredman: duncanm: I suppose I could

17:58 they just all seemed horrible

17:59 like the client that was formerly maintained by facebook

18:00 POSTing to restserver.php is just so much simpler

18:00 http://mrepo.happyfern.com/sites/facebook-java-api/facebook-java-api/apidocs/com/google/code/facebookapi/IFacebookRestClient.html

18:00 ^- ugh

18:01 there are other clients, that do stuff like add servlet filters and I didn't want to mess with that and compojure

18:02 http://gist.github.com/233400 <-- what a call looks like

18:03 duncanm: i need to learn more about compojure, i just finally learned what a servlet meant the other day, i was at B&N and flipped through one of those head start books

18:03 there's all this terminology that i never bothered to learn

18:04 hiredman: I still can't be bothered, which is why I didn't even try to use one of the other clients

18:05 duncanm: hiredman: i don't really know all the variations to the destucturing syntax, what does {:keys [uid title link description image]} mean?

18:05 hiredman: it destructures a map

18:06 uid gets the value of (:uid map), titles gets (:title map), etc etc

18:06 duncanm: oh cool

18:06 i get it now

18:06 hiredman: it's very cool

18:07 somnium: duncanm: defnk in c.c.def uses it for keyword fns

18:07 (which btw seem to lose argmap metadata for some reason)

18:07 duncanm: yeah, coming from Scheme, i wish Scheme implementations experiemented more with these little syntactic niceties

18:07 hiredman: call 'call' comes from compojure?

18:08 hiredman: no

18:08 call is defined in previous gist

18:09 call turns the map into a facebook api call (a POST) and, uh, POSTs it

18:11 the definition of call is a little mangled because I just went through a debugging session and was shoving (.info log _) everywhere

18:13 duncanm: hiredman: which library contains with-open?

18:13 hiredman: core

18:14 duncanm: hiredman: i should go back and clean up some of my clojure code, i had to spend an afternoon chasing down missing close/flushes because i didn't use with-open

18:15 hiredman: I really hate the pull nature of rss

18:16 duncanm: hiredman: that's because of HTTP, is you need notification, you could use XMPP, right?

18:18 hiredman: sure, but xmpp is fairly complex

18:18 webhooks seem nice and simple

18:19 I think I might make myself a rss->webhook translator so I never have write the rss polling code again

18:20 I think protocols may have spooked headius

18:20 bitbckt: hiredman: we'll polish him up at RC, next week ;-)

18:20 hiredman: http://twitter.com/headius/status/5658380443

18:20 bitbckt: Yeah, I saw.

18:27 Luyt: 'developer ability'?

18:28 Are they afraid people cannot understand lisp-like languages?

18:28 hiredman: high cognitive load? dunno, his words

18:28 I don't think it's a lisp thing

18:28 bitbckt: These Go Interfaces will blow your stack, too.

18:29 Languages sure are fun.

18:29 hiredman: like I said, seems like maybe a response to the complexity of protocols

18:29 or a crystalization of opinion brought about by exposure to same

18:33 _ato: eh... how are protocols any more complex than interfaces?

18:33 krumholt__: is there a debugger i can use from emacs for clojure?

18:34 jabley: hiredman: I'm not sure it's solely clojure - add in scala and others

18:34 hiredman: _ato: I think the logs of #clojure contain evidence that they are. but a lot of that might clear up once their are more examples

18:35 jabley: sure

18:35 scala is digustingly complex

18:36 jabley: "this type system goes up to 11!"

18:37 hiredman: not so much the type system

18:38 the api and the standard library (which feed back into the type system)

18:39 _ato: I think the logs of #clojure just contain evidence that everyone is more used to interfaces rather than protocols and there's still a few kinks to be worked out in the implementation, but the concept is no more complex IMO

18:40 hiredman: ~logs

18:40 clojurebot: logs is http://clojure-log.n01se.net/

18:41 hiredman: *shrug*

18:42 _ato: :)

18:43 patrkris: Question: I have a ref that contains a vector. An agent needs to be awoken when something is put in the vector. The agent will set the ref to the empty vector [] and process the old vector (with elements in it). While it is processing these elements, it shouldn't be notified of new elements. When it is done processing, it should either process new elements added in the meantime or wait until new elements are added. How do I get

18:44 Should I add a watch or watcher?

18:45 krumholt__: patrkris, i think you want an agent instead of a ref? instead of putting something in the ref you send it of to the agent to process it

18:45 patrkris: krumholt__: hmmm.... you may have a point there

18:48 krumholt__: but the thing is, I don't want an agent to process a single element at a time... it is better that it processes a batch of elements

18:48 krumholt__: btw, it is a simulation of disk scheduler

18:49 krumholt__: patrkris, you could save the vector as the state of the agent. when you send-off something to the agent it will add it to the vector or if there are enough items accumulated it will process them

18:51 duncanm: hiredman: i think it'll be interesting to ask someone like stuart halloway what he thinks about 'avg developer ability'

18:51 hiredman: from the comments i see in this channel, i'm usually surprised at how fast non-Lispers seem to pick up on the language

18:51 patrkris: krumholt__: yes, that is a good suggestion, except that I do not depend on a specific number of requests to have accumulated; I depend on the disk scheduler being ready (i.e. not in the midst of processing elements). The disk scheduler itself is represented by an agent and an action that takes a batch of current elements and processes them.

18:52 hiredman: I think focusing on lisp/not-lisp misses the point

18:52 duncanm: hiredman: i agree

18:53 hiredman: the point is, when do you use alter, commute, or ref-set

18:53 or similar

18:53 krumholt__: patrkris, no idea then :) probably a watcher will be a good idea never used it

18:54 patrkris: krumholt__: thanks for you help though

18:54 hiredman: I have very limited exposure to "developers" (outside of irc) so I cannot comment on their average ability

18:56 I just remember taking a java class at the local community college (mind you this was the second java class, after taking a class that was javascript) a large number of people still couldn't figure out how to loop over an array

18:57 Chousuke: I once tried to teach a person some python basics.

18:57 I kind of gave up after an hour when he was just somehow unable to understand how a simple while loop worked :/

18:57 hiredman: :(

18:58 duncanm: Chousuke: you should have taught tail-recursive calls instead ;-)

18:58 Chousuke: It lead me to think that maybe some people are just unable to learn programming :)

18:58 jabley: Or logical thinking of any type!

18:58 patrkris: some people simply cannot learn to program: http://www.cs.mdx.ac.uk/research/PhDArea/saeed/

18:58 Chousuke: it does require the ability to visualise rather abstract things.

18:59 duncanm: in some sense, tail-recursion is easier to understand, right? as long as you don't care about stack size, it's just calling a procedure. if they can understand (f x), they can understand (f (dec x))

19:00 Chousuke: but can they understand a procedure calling itself?

19:00 duncanm: well, you gotta start with that, also you'd hope they learned some of that from high school math

19:00 hiredman: duncanm: you also need a terminating case

19:01 _ato: at ANU they teach haskell first and then java... it's quite interesting how it seems to polarize the students, those that have no programming experience often cope better with haskell (as it's more like maths), while those that have imperative language experience tend to find it more difficult

19:01 hiredman: interesting

19:01 duncanm: i went to school where they taught PLT Scheme, and the experience there is similar to _ato's

19:02 it was fun being a tutor for the 2nd year java class, and having kids write code like 'return for (int i; ...)'

19:02 that was memorable moment for me

19:02 krumholt__: thats my experience too people who have been "exposed" to imperative languages tend to have more problems learning a functional language

19:02 * somnium feels scarred from years believing c++ was the only language

19:03 Draggor: Is there a way to get around clojure forcing me to define all of my functions in order?

19:03 Chousuke: use declare

19:07 duncanm: Chousuke: is there a reason why order of function definitions is not implemented like other languages? does it have to do with the reader?

19:08 Chousuke: yes. :P

19:08 or rather, the compiler.

19:08 or both.

19:09 gbt: Chousuke: how is your reader going?

19:10 Chousuke: gbt: Compiles Clojure, contrib and itself, passing all tests. I just haven't had the time to polish it up.

19:10 duncanm: Chousuke: what are you writing?

19:10 Chousuke: or "compiles". I mean I can use it in place of the Clojure reader and it works.

19:11 But it's unoptimised and undocumented and still fairly messy.

19:12 chouser: so, a naive port of finger trees from letfn+reify to deftype+defprotocol costs between 15% and 300% in performance, depnding on work load.

19:12 Chousuke: however, since it works it'll be easy to improve. I thought about rebasing it on the 'new' branch

19:12 hiredman: :|

19:13 300%

19:13 _ato: I think I must be brain damaged from writing too much C code, I actually *like* having a forced order of function definitions :p

19:13 gbt: duncanm: he's written a reader in clojure rather than java

19:13 Chousuke: the worst of the mess right now is syntax-quote though.

19:14 I put that in core.clj in my branch, intending to make it a macro... but that didn't work.

19:14 so now it's just a read-time function

19:14 but the remnants of the macro still exist in core.clj :P

19:14 and other stuff like that which needs cleaning up

19:15 it turned out that autogensyms complicate syntax-quote a fair bit.

19:16 _mst: _ato: I misread you for a minute there and thought you were saying that you liked having the order of evaluating function *arguments* undefined. Now I only think you're partially crazy rather than fully crazy...

19:16 Chousuke: I suppose a code-walker is needed to make it a real macro, but clojure.walk isn't available when syntax-quote is defined :(

19:18 or hmmh.

19:18 timothypratley: I'm adding some tests for sorted-set-by and am confused by the following behavior if anyone can give me a hint:

19:18 Chousuke: I wonder if it is possible to just take advantage of the bootstrapping and define syntax-quote as a macro in the reader namespace, where all of clojure.core is available.

19:18 timothypratley: ,(sorted-set 1 "a")

19:18 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

19:19 timothypratley: ,(sorted-set-by compare 1 "a")

19:19 clojurebot: java.lang.Exception: Unable to resolve symbol: sorted-set-by in this context

19:19 timothypratley: oh well in head it says RuntimeException : ClassCastException

19:19 I can't figure out why its not the same exception.

19:20 Chousuke: ,(compare 1 "a")

19:20 clojurebot: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number

19:20 Chousuke: your comparator makes no sense it seems

19:20 timothypratley: Yup I want it to throw a ClassCastException

19:21 but I'm getting a RuntimeException wrapping the ClassCastException for sorted-set-by

19:21 but just ClassCastException for sorted-set

19:21 gbt: Chousuke: it all sounds really interesting and I wish I understood, but you're talking well above my head :)

19:22 Chousuke: gbt: implementing syntax-quote as a macro seems to be way above *my* head as well, so don't worry too much.

19:22 but hm

19:22 now I guess need to try out a few things...

19:25 timothypratley: ah I think I see what is going on... Util.compare must have a catch or something I'll look there

19:29 Nope... the util compare explicitly casts its arguments maybe that's where the exception gets triggered, whereas with a custom comparator it goes further and somehow that results in a runtime exception wrapping it, but I don't understand why or how to fix it.

19:35 _ato: ,(sorted-set 1 2 :a)

19:35 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.Keyword

19:35 _ato: ,(sorted-set :a "b")

19:35 clojurebot: java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.String

19:36 _ato: timothypratley: does it make sense to have a sorted set of things of different types? how are 1 and "a" supposed to be ordered?

19:36 oh wait sorry, missed that you said you're just expecting the same exception

19:44 chouser: http://tinyurl.com/yeh5fgg/finger_tree.clj

19:45 dunno why I pasted that, except it's passing all its tests again.

19:47 _ato: timothypratley: so it's line 44 in AFunction.java... not sure if there's a way to get around java's declared exceptions

19:54 chouser: clojure is an excersize in trying to get around java's declared exceptions

19:54 :-/

19:55 timothypratley: _ato: ah yeah thanks I should have noticed that, all compares were looking the same to me but you are quite right - totally different.

19:55 chouser: hahahaha what have I got myself into :(

19:57 _ato: http://www.mail-archive.com/javaposse@googlegroups.com/msg06200.html

19:58 gbt: oh my, defprotocol, extend, deftype ... it may take me a while to understand, but that is an example of all the new features

19:58 _ato: there's that, but it's not perfect as you can't write a catch in java with a checked exception that's not declared

20:10 timothypratley: Hmmm _ato/chouser: n00bish question but I've discovered (sorted-map-by) and (sorted-map) has the same asymmetric exceptions, so maybe its fine to just leave it as is. Or I could easily create a RuntimeException for the compare that doesn't catch and re-throw. It seems to me that wrapping the exception is preferred? If I do that they will be the same. Or I can just make the tests ignore the fact that different exceptions ar

20:16 I'm inclined to just remove the exception test and post about it on the group for now.

20:17 So I don't cause any damage :)

20:19 chouser: I don't think the type of exception thrown is part of the promised interface of much of anything in Clojure.

20:20 throwing vs. not throwing perhaps, but not the type of the exception.

20:20 timothypratley: yeah good point - I'm happy with that!

20:28 rhickey: chouser: snazzy!

20:29 looking at your code, it looks like, when extending with fn defs inline, a macro could get rid of the maps and (fn s

20:30 making the extend as concise as the defype inline methods

20:33 Chousuke: rhickey: does the :private metadata work on protocols btw?

20:46 rhickey: Chousuke: not sure all metadata is flowing through and maintained yet

20:53 alexyk: hi guys -- I'm trying to do mvn install in clojure-contrib, but it needs the clojure jar in maven repo. Going back to the original clojure, pom.xml has no real install targets. How do you deploy clojure itself into maven repo locally?

21:01 durka42: is there a way to make interleave "greedy"? i.e. if one seq runs out, just conj the rest of the other one on

21:01 ,(interleave [1 2 3] [4 5 6])

21:01 clojurebot: (1 4 2 5 3 6)

21:02 durka42: ,(interleave [1 2 3] [4 5])

21:02 clojurebot: (1 4 2 5)

21:06 alexyk: ok, take 2... anyone installs clojure jar into his/her own local m2 repo?

21:07 hiredman: alexyk: have you looked at the deploy target in build.xml?

21:08 alexyk: hiredman: yeah, but when I say and deploy it says not so fast. It's some macro, no such target deploy...

21:09 hiredman: oh

21:10 *shrug*

21:10 alexyk: furthermore, some projects depend on clojure-lang jar; is it the same as clojure-1.1.0-alpha-SNAPSHOT.jar?

21:11 _ato: alexyk: you could just add http://build.clojure.org/snapshots/ as an extra repository in your pom or settings.xml

21:11 alexyk: yeah clojure-lang is the same as clojure.. the pom had clojure-lang by mistake in older versions

21:12 alexyk: _ato: yeah, I can grab a snapshot off external repo, but I wonder how I deploy a local build.

21:13 chouser: rhickey: should the existing method checks happen at defprotocol macro-expand time, or be in the expansion?

21:13 _ato: mvn install:install-file -DpomFile=pom.xml -Dfile=clojure-1.1.0-alpha-SNAPSHOT.jar

21:13 ^ alexyk that should do it

21:14 chouser: if you load something that's been AOT compiled, the macros don't get called, right? So it should be in the expansion.

21:15 alexyk: _ato: true, too :) still I wonder why there's a pom.xml in clojure off github doing nothing, and a macro deploy in build.xml which does nothing obvious, and a "-setup-maven" target which can't be called...

21:16 gilbertleung: hi everyone

21:16 chouser: except this is only a problem within the same namespace. You're not going compile one namespace into separately loadable things, so checking at macro-expand time (that is, during non-AOT load or during AOT compile) should be sufficient?

21:16 _ato: alexyk: because Rich doesn't use maven. the stuff in build.xml is probably for auto-deployment to external repo (like for build.clojure.org to use)

21:17 alexyk: _ato: ah ok...

21:17 gilbertleung: does anyone kno why, even thought i've set *prxml-indent* to 10, but prxml still prints my xml structure as a one liner?

21:17 chouser: but the interning of the protocol methods doesn't happen until until runtime. if you put the two conflicting defprotocols in, say, a do form, when the macros expand neither will see the other.

21:17 ok, it clearly has to go in the expansion.

21:18 rhickey: I'm glad we had this little talk. ;-)

21:21 _ato: gilbertleung: works for me, how are you setting *prxml-indent* ?

21:21 gilbertleung: (def *prxml-indent* 10)

21:21 _ato: (binding [*prxml-indent* 10] (prxml [:foo [:bar]])) <-- I did this

21:22 gilbertleung: oh, icic

21:25 _ato: if you always want to pring with indent 10, a common idiom is just to wrap the prxml function, so something like: (defn myprxml [& args] (binding [*prxml-indent* 10] (apply prxml args)))

21:26 gilbertleung: thx _ato

21:28 rhickey_: chouser: np, glad to help :) you've got it right, must be in expansion

21:34 Qvintvs: i'm trying to write a function that checks if its argument is in one of three vectors, returning a corresponding symbol, or nil if it's in none of them. what would be an elegant way to do this? i was going to do something like (if (in-col? str nouns) :noun (if in-col? str verbs.... in-col? is a function i wrote, im not sure if there's something like that in clojure already

21:35 hiredman: you could use a multimethod

21:35 oh

21:35 nevermind

21:37 ((comp first first filter) second (map (juxt identity #(.contains % "foo")) v1 v2 c3))

21:37 rlb: Qvintvs: (not-any? pred coll)?

21:38 Qvintvs: or (some ...) depending on what you want...

21:38 hiredman: [v1 v2 v3]

21:46 _ato: ,(some #(when (some (partial = :poke) (val %)) (key %)) {:nouns [:cat],:verbs [:poke]})

21:46 clojurebot: :verbs

21:47 somnium: no animals were harmed in the creation of this example

21:47 _ato: ,(contains? [:fish] :fish)

21:47 clojurebot: false

21:47 _ato: that always throws me off

21:48 tomoj: ,(contains? [:fish] 0)

21:48 clojurebot: true

21:48 tomoj: :)

21:49 _ato: yeah, I'd prefer if it was called contains-key? or something like that

21:54 chouser: rhickey: I've got a patch, where do you want it?

22:04 _ato: ,(condp #(%1 %2) :dog #{:cat :dog} :noun #{:chase} :verb)

22:04 clojurebot: :noun

22:05 _ato: Qvintvs: better to use sets if order doesn't matter, will be faster

22:05 Qvintvs: _ato, ah, thx

22:05 chouser: ,(case :dog (:cat :dog) :noun (:chase) :verb)

22:05 clojurebot: java.lang.Exception: Unable to resolve symbol: case in this context

22:13 ngoc: Hi, I think Compojure is still young. Which (Java) web framework is suitable for Clojure? I heard from the mailing list that Restlet is good. But doesn't it use annotation, and Clojure does not support annotation at the moment?

22:14 somnium: ngoc: what does compojure not do that you want it to do?

22:18 ngoc: somnium: Actually I do not have concrete requirements right now, so I can't answer your question. I just want to know about Compojure's alternatives beforehand. Java has a lot of web frameworks right?

22:19 _ato: ngoc: I don't think you're going to find many java web frameworks that work well with Clojure as most java frameworks are designed around classes.

22:19 you could use them with gen-class but it would be painful

22:19 an alternative to compojure is cascade: http://wiki.github.com/hlship/cascade/

22:23 rhickey: chouser: email to dev ok - thanks!

22:25 somnium: ngoc: there is also conjure, I'm not sure mature it is either. I would say that compojure does a good job of exposing http request/response to the developer, so its easy to extend it with clojure's strengths.

22:27 eg. its remarkably easy to imitate rails insta-routes with a macro if thats what you want

22:35 Qvintvs: is there a function that gives you a subset of an ordered collections based on start/end index numbers?

22:36 collection*

22:37 somnium: ,(take 5 (drop 5 (iterate inc 1)))

22:37 clojurebot: (6 7 8 9 10)

22:38 _mst: or if you've got a vector, subvec can do it in constant time

22:58 cataska: hi, (iterate inc 1) means clojure know "inc" is a function, so i don't have to quote "inc", right ?

23:00 _ato: ,inc

23:00 clojurebot: #<core$inc__4430 clojure.core$inc__4430@b551e4>

23:00 _ato: ,(type inc)

23:00 clojurebot: clojure.core$inc__4430

23:00 _ato: cataska: you almost never have to quote functions

23:02 cataska: _ato: ok, "almost" means there are some exceptions

23:04 chouser: 'inc evaluates to a symbol. inc evaluates to a function

23:10 headius: protocols didn't spook me

23:10 I just can't imagine 90% of the devs I've worked with ever getting them

23:12 cataska: chouser: thanks

23:12 hiredman: headius: "spook" was a poor choice of words on my part

23:13 headius: it was

23:13 I should gush more about the good aspects of these languages

23:13 but that seems less useful

23:40 yacin: is there a way to make clojure.xml/parse work on a string of xml?

23:40 hiredman: StringReader

23:40 or whatever

23:41 yacin: gotcha, cool

23:41 hiredman: I think I used ByteArrayInputputStream or something like that

23:41 from java.io

23:47 yacin: java.io.StringReader worked for what i needed

23:47 just needed to convert it to org.xml.sax.InputSource

23:47 before i threw it to xml/parse

23:51 hiredman: erm

23:51 ,(doc clojure.xml/parse)

23:51 clojurebot: "([s] [s startparse]); Parses and loads the source s, which can be a File, InputStream or String naming a URI. Returns a tree of the xml/element struct-map, which has the keys :tag, :attrs, and :content. and accessor fns tag, attrs, and content. Other parsers can be supplied by passing startparse, a fn taking a source and a ContentHandler and returning a parser"

23:51 hiredman: http://java.sun.com/javase/6/docs/api/java/io/ByteArrayInputStream.html

23:52 ,(-> "foo" .getBytes java.io.ByteArrayInputStream.clojure.xml/parse)

23:52 clojurebot: java.lang.ClassNotFoundException: java.io.ByteArrayInputStream.clojure.xml

23:52 hiredman: ,(-> "foo" .getBytes java.io.ByteArrayInputStream. clojure.xml/parse)

23:52 clojurebot: org.xml.sax.SAXParseException: Content is not allowed in prolog.

23:56 yacin: ,(-> "foo" java.io.StringReader. org.xml.sax.InputSource. clojure.xml/parse)

23:56 clojurebot: org.xml.sax.SAXParseException: Content is not allowed in prolog.

23:58 yacin: ,(-> "<test>lol</test>" java.io.StringReader. org.xml.sax.InputSource. clojure.xml/parse)

23:58 clojurebot: {:tag :test, :attrs nil, :content ["lol"]}

Logging service provided by n01se.net