#clojure log - Feb 25 2009

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

1:25 durka42: ...is clojurebot self-aware now?

1:25 hiredman: so every hour it sends tweets since the last hour about clojure (limit 3)

1:26 in theory it does that

1:26 durka42: ah

1:26 hiredman: we will see in an hour

1:26 * durka42 will be asleep

1:31 durka42: are tweets tagged? or do you just grep on "clojure"?

1:31 hiredman: http://search.twitter.com/search?q=clojure

1:32 durka42: cool

1:33 hiredman: I pushed with the tweet plugin

1:33 I mean, source of the tweet plugin is pushed

1:34 durka42: is if-let what lispers refer to as anaphoric if?

1:38 hiredman: looks similar (as far I as I can tell)

1:42 * durka42 wonders if clojurebot should do some simple stats and skip tweeting during high traffic

1:43 hiredman: that has occured to me

1:44 durka42: it could just be elapsed time since last message

1:44 clojurebot reads every message anyway looking for , or ~

1:45 hiredman: yes

1:50 durka42: (Thread/sleep)

2:23 __marius__: so i have a strange error - if i launch slime (both slime an dclojure are completely up to date), i get java.lang.ClassNotFoundException: swank.swank (NO_SOURCE_FILE:9) after trying to start the swank serer

2:23 however

2:23 if i recompile clojure, it works

2:23 but only once...

2:29 hiredman: is swank up-to-date?

2:31 __marius__: yep.

2:32 adakkak: ,(.split "this" "h")

2:32 clojurebot: #<String[] [Ljava.lang.String;@1a05bdb>

2:32 adakkak: how do go from String[] to a clojure type?

2:38 cmvkk: ,(seq (.split "this" "h"))

2:38 clojurebot: ("t" "is")

2:40 adakkak: thanks

2:44 hiredman: ,(vec (.split "this" "h"))

2:44 clojurebot: ["t" "is"]

2:44 hiredman: ooh

2:51 adakkak: ,(isa? \a ::char)

2:51 clojurebot: false

2:52 hiredman: correct

2:52 (doc isa?)

2:52 clojurebot: Returns true if (= child parent), or child is directly or indirectly derived from parent, either via a Java type inheritance relationship or a relationship established via derive. h must be a hierarchy obtained from make-hierarchy, if not supplied defaults to the global hierarchy; arglists ([child parent] [h child parent])

2:52 jochu: __marius__: Bah, swank-clojure compiling must be broken. You can turn it off by (setq swank-clojure-compile-p nil). If it ends up being a recurring issue, I'll have it turned off on default. In the mean time, I'm curious - are there compiled class files in your ~/.slime/cljclass/ directory?

2:52 hiredman: ,(isa? \a Character)

2:52 clojurebot: false

2:52 adakkak: is there a clojure name for java.lang.char ? like ::a-collection

2:52 hiredman: ,(isa? \a Character/TYPE)

2:52 clojurebot: false

2:53 hiredman: ,(isa? (Character. \a) Character)

2:53 clojurebot: false

2:53 hiredman: oh

2:53 duh

2:53 ,(isa? Character Object)

2:53 clojurebot: true

2:54 hiredman: isa? is for inheritence, not determining types

2:54 (instance? \a Character)

2:54 ,(instance? \a Character)

2:54 clojurebot: java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.Class

2:54 hiredman: ,(instance? Character \a)

2:54 clojurebot: true

2:54 cmvkk: instance? is backwards from isa?

2:54 oh wait that makes sense.

2:56 __marius__: jochu: thanks, i'll try that

2:56 jochu: yep

2:56 jochu: (re: compiled classes there)

3:02 jochu: __marius__: Boo, so does turning off compilation or deleting the directory fix it? (deleting would be a one time fix)

3:36 adakkak: is there a reason why the following would not work: http://paste.lisp.org/display/76135

3:36 in particular the defmulti part

3:37 hiredman: where is the exception?

3:37 well

3:37 there are a few things

3:37 but I am not going to say until you paste the exception

3:42 adakkak: java.lang.IllegalArgumentException: No matching method found: split for class java.lang.Character (NO_SOURCE_FILE:0)

3:43 actually : java.lang.ClassCastException: Cannot cast java.lang.Character to java.lang.String (NO_SOURCE_FILE:0

3:44 hiredman: well

3:45 ~jdoc Character

3:45 as you can see Character does not have a .split

3:46 also, generally you don't deal with Characters you deal with chars which are a primitive type and have no methods

3:46 and you method with ::collection will never be used because (class ...) will never return ::collection

3:47 and the syntax of defmulti has changed

3:47 cmvkk: ,(.split "baha" \h)

3:47 clojurebot: java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.String

3:48 cmvkk: ,(.split "baha" (str \h))

3:48 clojurebot: #<String[] [Ljava.lang.String;@19a6087>

3:48 hiredman: and?

3:48 adakkak: ,(instance? \a ::chars)

3:48 clojurebot: java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.Class

3:48 hiredman: adakkak: ::chars is not a type

3:48 ::chars is a keyword

3:49 ,(instace? Character \a)

3:49 clojurebot: java.lang.Exception: Unable to resolve symbol: instace? in this context

3:49 adakkak: I though you said there was a type called chars

3:49 hiredman: ,(instance? Character \a)

3:49 clojurebot: true

3:49 adakkak: an I should be using it

3:49 hiredman: there is a primitive type called char

3:49 no, you shouldn't

3:49 :foo is a keyword

3:49 not a type

3:50 ::collection is not a type, but java.util.Collection is

3:51 ::collection is a keyword

3:51 adakkak: ahh.. http://clojure.org/multimethods confused me ; you said that the syntax for defmulti has changed. is there a documentation for that.

3:51 hiredman: ,(doc defmulti)

3:51 clojurebot: "([name docstring? attr-map? dispatch-fn & options]); Creates a new multimethod with the associated dispatch function. The docstring and attribute-map are optional. Options are key-value pairs and may be one of: :default the default dispatch value, defaults to :default :hierarchy the isa? hierarchy to use for dispatching defaults to the global hierarchy"

3:52 hiredman: actually, that will still work

3:52 adakkak: any examples of its use?

3:52 cmvkk: yours is still right, i think.

3:53 hiredman: ,(class [])

3:53 clojurebot: clojure.lang.PersistentVector

3:53 hiredman: ,(class "foo")

3:53 clojurebot: java.lang.String

3:53 hiredman: ,(class \a)

3:53 clojurebot: java.lang.Character

3:53 cmvkk: ,(class '(1 2))

3:53 clojurebot: clojure.lang.PersistentList

3:53 hiredman: these are the things your dispatch fn will be returning

3:55 what are you even trying to do?

3:55 adakkak: I am trying to split a string based on a few seperators without using regex

3:56 cmvkk: you want the function to take either a char or a list of chars.

3:56 maybe try using (seq? x) for dispatch then methods for true and false?

3:56 hiredman: just use mapcat

3:57 ,(.split "a|b;c'd" "|")

3:57 clojurebot: #<String[] [Ljava.lang.String;@1b7a553>

3:57 hiredman: ,(mapcat #(.split % ";") (.split "a|b;c'd" "|"))

3:57 clojurebot: ("" "a" "|" "b" "c" "'" "d")

3:58 hiredman: odd

3:58 cmvkk: ,(seq (.split "a|b;c'd" "|"))

3:58 clojurebot: ("" "a" "|" "b" ";" "c" "'" "d")

3:58 hiredman: ,(.split "a|b;c'd" "\|")

3:58 clojurebot: Unsupported escape character: \|

3:59 hiredman: ,(.split "a|b;c'd" "\\|")

3:59 clojurebot: #<String[] [Ljava.lang.String;@1335207>

3:59 hiredman: ,(seq (.split "a|b;c'd" "\\|"))

3:59 clojurebot: ("a" "b;c'd")

3:59 cmvkk: weird escape stuff? that's weird.

3:59 hiredman: not really

3:59 split uses its arg as a regex

3:59 so you need to escape |

4:00 cmvkk: ,(seq (mapcat #(.split % "y") (.split "axbyc" "x")))

4:00 clojurebot: ("a" "b" "c")

4:00 hiredman: and \ needs to be escaped in strings because \ is used for character literals

4:00 so you need \\

4:02 adakkak: thanks, that is what I was looking for

4:03 hiredman: (really you should just use a regex)

4:04 ,(seq (.split "axbyc" "x|y"))

4:04 clojurebot: ("a" "b" "c")

4:06 hiredman: ,(seq (.split "axbyc" (apply str (interpose "|" "xy"))))

4:06 clojurebot: ("a" "b" "c")

4:12 adakkak: I should be using it with regex, but part of thing I am doing requires one not to use regex

4:36 Lau_of_DK: Morning all

4:48 cgrand: Hi Lau_of_DK!

4:57 niet: is clojure ore for concurrency thatn distributed systems?

4:57 more

4:58 AWizzArd: kotarak: hoi

5:00 hiredman: niet: yes

5:01 although I think I recall rhickey mentioning something about amq

5:02 but presnetly there isn't a "blessed" distributed mechanism

5:38 AWizzArd: hiredman: is that thine blog?

5:39 hiredman: eh?

5:39 clojurebot tracks twitter now

5:40 so, No, that is not my blog

5:42 Lau_of_DK: descent article

5:45 lisppaste8: Bracki pasted "What's wrong with the dispatch fn?" at http://paste.lisp.org/display/76137

5:46 Bracki: Can the dispatch fn for a multimethod be any kind of function?

5:48 I get an NPE when calling the defmethods but I have no clue why and where.

5:49 Lau_of_DK: Missing a \space after keyword?

5:50 And are you sure what re-find will return for your call ?

5:52 Bracki: Yes but no, I forgot to put a + after [A-Z].

5:52 thx.

5:53 Lau_of_DK: Yea, maybe it'd be easier with something like this

5:53 user> (re-find #"\b([^\/]\w+)(\s.*)+" "/part #clojure")

5:53 ["part #clojure" "part" " #clojure"]

5:53 ?

5:55 Bracki: Lau_of_DK: But IRC clients transform "/nick Bracki" to "NICK Bracki".

5:56 Lau_of_DK: oh

5:56 user> (re-seq #"\b([^\/]\w+)(\s.*)+" "PART #clojure")

5:56 (["PART #clojure" "PART" " #clojure"])

5:56

5:56 So thats better?

5:57 Bracki: ,(re-find #"^[A-Z]+\b" "PART #clojure")

5:57 clojurebot: "PART"

5:57 Bracki: is sufficient for me.

5:58 ,(doc re-seq)

5:58 clojurebot: "([re s]); Returns a lazy sequence of successive matches of pattern in string, using java.util.regex.Matcher.find(), each such match processed with re-groups."

5:58 Lau_of_DK: k

6:33 AWizzArd: yeah great, news spam :)

6:34 cemerick: wow, lots of heat coming from the CL world these days

6:54 AWizzArd: yup

6:54 they are scared

6:55 they are happy because they have fset and some basic implementation of a STM

6:55 cemerick: I doubt they're scared -- I don't think the CL world can lose any more relevance than it already has.

6:55 I suppose a big vendor disappearing would be another notch down...

6:58 AWizzArd: And I hope that won't happen too soon.

6:58 But well, evolution is in progress, so, anything can happen.

6:58 survival of the ...

6:59 In fact, we can congratulate them. They were able to survive way longer than most others.

7:02 cemerick: I suppose.

7:03 I've had enough bad experiences with the community that I can't easily work myself up to be congratulatory.

7:05 AWizzArd: although:

7:05 ,(= 'community 'vendors)

7:05 clojurebot: false

7:06 AWizzArd: And btw, I am also one of those CL guys ;)

7:06 At least that's what I've been doing in the past 6 years.

7:06 But for me the age of Clojure began.

7:09 cemerick: Well, I've seen some serious venom poured forth by people with emails from some of those vendors' domains, but yeah, point taken.

7:11 There's thousands of perfectly peaceful CL programmers tending their own gardens, but those that throw stones in very public forums (perhaps only *in* those public, at-arms-length forums) end up defining the public profile of the community as a whole.

7:12 Lau_of_DK: cemerick: Pride goes before a fall :)

7:13 cemerick: AWizzArd: BTW, I was tinkering with javafx over the weekend -- it's a pretty pleasant environment. Not clojure, obviously, but it actually has a lot of primitives that make building UIs a lot easier. It might make a really good front end to some clojure libs that contain the real workings of an app. Are you still plowing ahead in netbeans/swing?

7:13 Lau_of_DK: cemerick: You're driving fx from clojure?

7:15 cemerick: Lau_of_DK: not really -- but fx can call into clojure as readily as any other java lib. I only brought it up because it's actually looking like it has serious potential to be better than swing (as we've known it).

7:16 Lau_of_DK: Ok cool - I had a look at it a while ago, but didnt use it (primarily because I was investing my time in QtJambi)

7:16 cemerick: ...and I know AWizzArd was looking for UI solutions -- driving a UI with clojure is appealing, but if the javafx guys do well, the "right tool for the job" rule might override any impulse to do everything with our favorite language.

7:16 rhickey: cemerick: I wonder how much of fx goodness is in libs we can drive from Clojure

7:17 I know a lot of it is

7:17 cemerick: I was pretty disappointed to see jambi dropped so quickly -- that could have had real potential in some usages

7:17 Lau_of_DK: cemerick: Im still on Jambi - I use it for my GitDoc project

7:17 I just paralized it with CQL and a 3D game :)

7:18 cemerick: rhickey: I'm not entirely clear on it all, but from interviews I've listened to (I'm a podcast junkie), the plan is to start opening up the object model for any jvm language later this year.

7:19 early releases had the object model very tied up with specifics of javafx script, which is no longer true. I'll bet you can drive the scenegraph and such using any language today, but they just haven't publicly documented the API and such yet.

7:20 rhickey: good show on c.l.l, BTW. It was a valiant effort. :-)

7:21 Lau_of_DK: the project has already been open-sourced, so it could be maintained. Being 'unendorsed' is a big blow, though -- it'll probably lag the core libs forever.

7:26 AWizzArd: cemerick: yes, I am doing netbeans/swing, but would be highly interested in JavaFX. The quesion is though: can one use all FX libs from Clojure?

7:26 I would want to use it without writing a line (well, 1% of the overall project) in JavaFX

7:26 Lau_of_DK: cemerick: which project has been open-sourced, fx? And which valiant effort, on which c.l.l ?

7:27 AWizzArd: my NetBeans+Clojure approach works by clicking until I have the gui, and then I write one export function in Java. This just returns an Object[] in which all the components sit which I want to touch in Clojure.

7:27 cemerick: rhickey: Did you happen to see my post yesterday on the reader oddness in #= forms? http://groups.google.com/group/clojure/browse_frm/thread/34e4d47fc5144512 I need to start serializing certain object graphs (excuse my likely wrong terminology), and these things are hanging me up.

7:27 AWizzArd: In Clojure then I have a (def my-frame (MyNetBeansStuff.)) and (def my-components (.getComponents my-frame))

7:27 cemerick: maybe I'm just missing something fundamental...

7:28 AWizzArd: Now I can happily add event handlers, change texts, etc.

7:28 cemerick: AWizzArd: ostensibly, yes, and using them from any jvm language is promised for later this year

7:28 Lau_of_DK: I was referring to jambi and comp.lang.lisp, respectively.

7:28 AWizzArd: well, I would love to have something better than Swing. Swing is nice but could be way nicer.

7:29 One solution that could work for FX and maybe also frameworks such as RIFE: writing lots of code in Clojure, and in Java then call it.

7:30 cemerick: AWizzArd: using fx-script may just be a perfectly reasonable thing to do -- it has a lot of very nice primitives for binding state, timers, etc etc that would likely require some/a lot of work in any other language.

7:30 rhickey: user usage of #= is not yet supported - it is not full eval

7:30 AWizzArd: My experience with Rife so far was, that it can't handle the .class files generated by Clojure.

7:30 cemerick: okay sure, if it is just abount handling boring GUI work it may be fine. The application logic however can and should still be 99% Clojure.

7:31 cemerick: rhickey: OK, I wasn't clear on that. Is that going to change anytime soon, or should we just create normal fns to be used in #= forms (find-enum, make-char-array, etc)?

7:32 AWizzArd: Right, right. I think the plan is to make it reasonably easy for other languages to create "binding sites" that can be readily tapped by fx-script-driven UIs.

7:36 Lau_of_DK: cemerick: thats news to be regarding Jambi... and bad news :(

7:37 cemerick: Lau_of_DK: oh, you hadn't heard? http://www.qtsoftware.com/about/news/preview-of-final-qt-jambi-release-available

7:37 AWizzArd: And if we can get our fingers on JavaFX then sooner or later there maybe a ClojureFX lib which will offer all the nice things from JavaFX, so that we can drive a 100% Clojure solution.

7:38 cemerick: AWizzArd: that last 5 or 1% will kill you -- and probably result in zero real benefit (IMO).

7:39 rhickey: cemerick: I guess you'll have to do that, but note it is still not full eval - all args must be readable constants

7:40 cemerick: rhickey: ah, OK. That criteria clarifies the class cast in the second example.

7:41 * cemerick continues to be unclear about class-symbol vs. Class class handling in various contexts in general

7:41 rhickey: cemerick: #= is subject to change

7:41 cemerick: rhickey: I think we're used to that ;-)

7:42 rhickey: :(

7:42 cemerick: there's not really any other reasonable option, though. bean serialization is really painful, especially for arrays and such.

7:43 rhickey: cemerick: ah, well I'm glad you agree about that, too bad though

7:43 cemerick: rhickey: oh, no worries. Sometimes that's the price one must pay to use the good stuff. I do feel bad for Stuart, though.

7:43 AWizzArd: cemerick: have you combined a JavaFX (toy-)app in any way with Clojure so far?

7:43 cemerick: AWizzArd: No -- I just played with it for the first time this weekend (as the demos now run reasonably, so I figured I was duty-bound to check it out).

7:44 AWizzArd: maybe you can find the time to call a clojure function wich returns "Hello JavaFX" and display that? ;)

7:44 rhickey: cemerick: I pushed on lazy just for Stuart, since I knew it would be breaking. There hasn't been any breaking other than that since AOT

7:45 cemerick: rhickey: Yeah -- it only feels worse for me because we didn't port to post-AOT until a couple weeks ago :-D

7:45 rhickey: ah

7:46 cemerick: we're probably going to come up to date with the lazy stuff, and then fall behind for another cycle.

7:47 ...or maybe we'll try to track things in real time, and be adventurous.

7:47 * cemerick is arbitrary and capricious ;-)

7:47 cemerick: AWizzArd: yeah, maybe this coming weekend

7:48 it shouldn't be hard -- fx script can call any java lib. The real trick is enabling jvm languages to expose fx script "native" structures, I think.

7:48 s/is/will be

7:49 AWizzArd: would be nice, yes

7:58 wb kotarak

8:00 clojurebot: svn rev 1306; made line-seq fully lazy

8:11 Lau_of_DK: This question might be spawned out of a lack of coffee, but here goes

8:11 user> (defn myAdd [ x y ] (+ x y))

8:11 #'user/myAdd

8:11 user> (myAdd (map #(* 2 %) [ 1 2 ]))

8:11 ; Evaluation aborted.

8:11

8:12 Is there anyway that I can make this possible? Because I have scenarios where I would like to use map as a type-caster/value-modifier, before the result should be passed to a javafunc which expects a certain number of arguments...?

8:13 gnuvince: (hi "everyone")

8:13 Chousuke: Lau_of_DK: use apply

8:15 ,(apply (fn [x y] (+ x y)) (map #(* 2 %) [1 2]))

8:15 clojurebot: 6

8:15 Chousuke: ,(apply (fn [x y] (Math/pow x y)) (map #(* 2 %) [1 2]))

8:15 clojurebot: 16.0

8:16 Chousuke: Lau_of_DK: and just as an aside, the spaces after [ and before ] look ugly :)

8:16 Lau_of_DK: Chousuke: Thank you for the first part of your input :)

8:17 Chousuke: I've seen some people use (defn foo[x y]) which I don't like either :/

8:17 it makes the argument vector look like special syntax

8:17 Lau_of_DK: Hang on, while I fetch my little violin :)

8:19 cemerick: I love the smell of snark in the morning.

8:22 Lau_of_DK: "The Snark is the fictional monster that Lewis Carroll created in his nonsense poem The Hunting of the Snark. His descriptions of the creature were, in his own words, unimaginable, and he wanted that to remain so."

8:22 "Snark is a 1974 text-based computer game for BASIC designed by People's Computer Company in which one must "net" the "snark," a point on a 10x10 ..."

8:23 cemerick: ooh, I didn't realize -clojurebot was watching twitter!

8:25 rhickey: is there any reason why EvalReader couldn't simply pass the read object to Compiler.eval? Or am I turning over stones that are going to get bulldozed to make way for a subdivision?

8:29 AWizzArd: cemerick: duh, another such a Swing incompetency: I can't simply add new Elements to a JList. First I need to put in a new Modell and do 300 extra calls and create objects.

8:31 cemerick: AWizzArd: nah, just ((DefaultListModel)jlist.getModel()).add(0, "my new item's name")

8:31 simpler in clojure with reflection, of course

8:32 and you can add any object -- its .toString will be used to generate the label

8:33 JLists always start with a DefaultListModel, JTables always start with a DefaultTableModel, etc., so it's safe to assume their base functionality

8:38 AWizzArd: ,(class (.getModel (javax.swing.JList.)))

8:38 clojurebot: javax.swing.JList$3

8:38 AWizzArd: ,(cast (.getModel (javax.swing.JList.)) 'javax.swing.DefaultListModel)

8:38 clojurebot: java.lang.ClassCastException: javax.swing.JList$3 cannot be cast to java.lang.Class

8:39 AWizzArd: ,(cast (.getModel (javax.swing.JList.)) javax.swing.DefaultListModel)

8:39 clojurebot: java.lang.ClassCastException: javax.swing.JList$3 cannot be cast to java.lang.Class

8:40 AWizzArd: ,(.add (.getModel (javax.swing.JList.)) 0 "Hallo")

8:40 clojurebot: java.lang.IllegalArgumentException: No matching method found: add for class javax.swing.JList$3

8:40 cemerick: oh no, I think I just dished out a steaming pile, instead of advice! :-(

8:42 AWizzArd: JList is the exception -- JTable does use DefaultTableModel, JComboBox uses DefaultComboBoxModel, etc.

8:42 AWizzArd: things like this maybe improved in JavaFX?

8:44 cemerick: AWizzArd: you mean common things made easy? One can only hope. I honestly didn't get that far -- was looking more at the binding and widget layout mechanisms.

8:44 AWizzArd: In Swing there is even not a center method for JFrames. As if people were not interested to center their windows from time to time.

8:44 cemerick: there's always....

8:45 ,(.add (.getModel (javax.swing.JList. (javax.swing.DefaultListModel.))) 0 "fooey")

8:45 clojurebot: nil

8:45 AWizzArd: cemerick: yes, it is just that I already created the JList in NetBeans and placed it at the right position.

8:45 Maybe in NetBeans I can make it so that the JList will be created with a DefaultListModel

8:46 cemerick: AWizzArd: See Window.setLocationRelativeTo(Component)

8:46 yeah, you can do that

8:46 model is just another bean "property"

8:49 AWizzArd: What I did is: right-clicked the JList, selected "Customize Code" and made the new JList() ==> new JList(new DefaultListModel())

8:49 cemerick: yeah, that'll work

8:52 heanol: is lazy-seq supposed to be commented out in core.clj? i'm trying to run swank-clojure and it seems to use it..

8:52 rhickey: heanol: you've got mismatched versions

8:53 heanol: well i got trunk/head of both, i think

8:54 which one of them is too new? :-)

8:54 cemerick: AWizzArd: the more idiomatic way would be to hang the 'new DefaultListModel()' code off of the widget's model property

8:55 AWizzArd: cemerick: yes, but this would add one more line cof code ;)

9:04 heanol: to answer my own question, jumping back to commit 581954d1fc0cb115a87233426bae5d53455eb4bb for swank-clojure made it work.. was before it started using lazy-seq

9:17 AWizzArd: ,(isa? 25 Integer)

9:17 clojurebot: false

9:17 AWizzArd: ,(class 25)

9:17 clojurebot: java.lang.Integer

9:17 AWizzArd: how should isa? be used?

9:17 danlarkin: with clojure hierarchies

9:23 * danlarkin gasps!

9:23 rhickey: AWizzArd: isa? isn't instance?

9:24 AWizzArd: thx

9:24 rhickey: but it can be used with Java classes too

9:24 ,(isa? String Object)

9:24 clojurebot: true

9:24 AWizzArd: instance? works for me, thanks

9:25 Lau_of_DK: hiredman: Why does clojurebot repeat the same news ?

9:26 AWizzArd: Lau_of_DK: it posted this link now at least 3x

9:27 Is there an easier way to extract values out of a hashmap for a vector of specific keys? Easier than (map #(apply % %2) [:a :b :c] some-map)

9:27 gnuvince: select-keys?

9:28 AWizzArd: good

9:28 gnuvince: ,(select-keys {:a 1, :b 2, :c 3} [:a :c])

9:28 clojurebot: {:c 3, :a 1}

9:28 AWizzArd: btw, the #(apply % %2) should be just apply

9:28 gnuvince: ,(vals (select-keys {:a 1, :b 2, :c 3} [:a :c]))

9:28 clojurebot: (3 1)

9:28 gnuvince: tadam

9:28 AWizzArd: ,(map apply [:a :c] {:a 1, :b 2, :c 3})

9:28 clojurebot: (1 2)

9:29 gnuvince: fail

9:29 AWizzArd: sure, of course

9:29 select-keys is good, thanks

9:29 gnuvince: Np

9:30 cemerick: Lau_of_DK: -clojurebot is monitoring twitter, so dupes are likely

9:34 Lau_of_DK: Then I'd like to suggest (remove-duplets (monitor-twitter))

9:35 cemerick: that'd get dicey with the diversity of url-shortening services out there

9:39 Lau_of_DK: then I'd like to suggeste (filter *.* (monitor-twitter)) ? :)

9:39 cooldude127: is wanting to write a better java mode for emacs a completely crazy idea?

9:40 Bracki: Are structs ordered? Can I rely on their keys being in order as defined?

9:40 cooldude127: Yes, use Vim.

9:40 Lau_of_DK: haha

9:40 "use Vim" - Bracki you know this is 1981 anymore right?

9:40 man that was fun...

9:41 rhickey: Bracki: yes, see: http://clojure.org/data_structures - "A struct map will retain its base keys in order."

9:41 cooldude127: Bracki: i should clarify that i have no real beefs with emacs' java syntax highlighting or anything like that, it's just that actually coding java requires a little more help, like some better project management

9:42 and JDEE is a big box of FAIL

9:42 Bracki: Well, IntelliJ IDEA is nice.

9:42 cooldude127: i've used all the IDEs, i find myself dissatisfied

9:43 idea is the least awful

9:43 * Raynes uses eclipse for Clojure just because he can.

9:43 cooldude127: lol

9:43 cemerick: you could spend a lifetime building a good java toolchain in emacs

9:43 jbondeson: Raynes: D= whyyyyyy?

9:43 cooldude127: cemerick: well it doesn't have to do everything, just needs to fill in the gaps that keep me using eclipse

9:43 cemerick: best to live with the 90% that NetBeans or IDEA or Eclipse gets you (w.r.t. your ideal state)

9:44 cooldude127: NO, i've tried that for too long

9:44 i can't take it anymore

9:45 plus i figure this an AWESOME way to learn emacs-lisp

9:45 Raynes: jbondeson: "because I can".

9:45 ;)

9:46 jbondeson: Raynes: my soul weeps for you

9:46 Raynes: Give me a break, they aren't that bad. At least they're improving.

9:46 jbondeson: every time i see the eclipse startup screen a little piece of me dies

9:47 Raynes: Oh, you just don't like Eclipse in general.

9:47 cemerick: I'm becoming very happy with enclojure of late for straightforward editing and development. Hopefully the debugging and profiling aren't too far behind.

9:47 * jbondeson uses Visual Studio every day, so he's not much better

9:47 Raynes: cemerick: Enclojure isn't bad at all, but I get persecuted for using Netbeans. :|

9:48 jbondeson: Raynes: i first used eclipse back when it when you could type faster than it could display because of all the extra work it was doing.

9:48 cooldude127: haha

9:48 Raynes: I switch between the two all the time though.

9:58 Bracki: Is there something that does exception to nil conversion with out using excessive try/catch blocks?

9:58 Chouser: Bracki: sure, the macro you're about to write.

9:59 Bracki: ,(doc defmacro)

9:59 clojurebot: "([name doc-string? attr-map? [params*] body] [name doc-string? attr-map? ([params*] body) + attr-map?]); Like defn, but the resulting function name is declared as a macro and will be used as a macro by the compiler when it is called."

9:59 Chouser: or the one cgrand already wrote for you: http://clj-me.blogspot.com/2009/01/try-or-or-try-try-else-or-else-try.html

9:59 gotta love that url.

10:00 Bracki: Hm what does ~ do?

10:00 AWizzArd: it unquotes

10:01 gnuvince: ,(let [x 10] `(x ~x))

10:01 clojurebot: (sandbox/x 10)

10:01 Bracki: ?

10:01 AWizzArd: ,'(a b c)

10:01 clojurebot: (a b c)

10:02 AWizzArd: ,(quote (a b c))

10:02 clojurebot: (a b c)

10:02 AWizzArd: now imagine b is a variable of the value 10

10:02 and you want to give that 10 back

10:02 instead of the symbol "b"

10:02 then you unquote

10:03 ,`(1 2 (+ 1 2) ~(+ 1 2))

10:03 clojurebot: (1 2 (clojure.core/+ 1 2) 3)

10:03 Bracki: Aight, the wholde code is data/data is code drama.

10:03 AWizzArd: just imagine the clojure.core/ would not be there

10:03 `(1 2 (+ 1 2) ~(+ 1 2)) ==> (1 2 (+ 1 2) 3)

10:04 gnuvince: If it were Ruby, ~ would be sort of like #{} in strings

10:04 Chouser: gah!

10:04 gnuvince: gu!

10:08 Damn

10:08 cgrand just left

10:09 Chouser: cgrand1 is still here. Hi, cgrand1!

10:09 gnuvince: oh

10:09 Chouser: or maybe not. *shrug*

10:09 gnuvince: His try-or looks sort of the opposite of the Maybe monad, does it not?

10:10 Chouser: "real world hasekll" is on my reading list. or would be if I had a reading list.

10:10 cgrand1: I'm here!

10:15 gnuvince: try-or is somewhat related to mplus in the Maybe monad

10:29 * danlarkin wonders if this will be annoying

10:29 cemerick: asymptotically so as clojure gains in popularity, I suspect

10:29 gnuvince: If people find it annoying, a lot of IRC clients have ignore and soft ignore features.

10:31 cemerick: at a certain point, that convention would repel newcomers to the channel. A similar feed of mentions of python (or whatever) would get XXX updates each minute.

10:31 it's nice for now, though :-)

10:33 gnuvince: At one point, we could just have a planet.clojure.org site to keep the channel cleaner.

10:36 cemerick: definitely

10:36 danlarkin: +100

10:52 Raynes: "I suppose I should learn Lisp, but it seems so foreign." - Paul Graham, Nov 1983

10:52 Chouser: wow, nice.

10:54 * cooldude127 kills himself realizing that emacs has 15 trillion types of variables

10:54 cemerick: just wait 'til you get to the forest of hooks

10:54 cooldude127: lol

10:55 * Raynes nudges a Clojure-dev and Enclojure installation over to cooldude127 and winks.

10:56 Raynes: March 4th is the 50th anniversary of LISP.

10:57 arbscht_: again? :)

10:57 Raynes: Yessir.

11:00 lisppaste8: cgrand pasted "form-scoped expansion-time bindings" at http://paste.lisp.org/display/76144

11:01 Bracki: Hm, I need help w/ ns problems.

11:01 java.lang.Exception: namespace 'protocol' not found after loading '/protocol' (urkle.clj:0)

11:04 Chouser: cgrand2: is this enlive-related?

11:05 cgrand2: Chouser: yup

11:06 Chouser: I haven't tried that yet, but I just recommended it to a friend.

11:06 AWizzArd: A (sorted-set) will stay sorted, right? Even if I conj elements into it.

11:06 Chouser: AWizzArd: yes

11:07 AWizzArd: that is its purpose

11:07 cgrand2: Chouser: while coding enlive, I didn't find a good way to make the current node contextual for other (lexically scoped) macroexpansions

11:09 and I ended using unquote as a quick and dirty way to say "here I need to pass the current node"

11:09 AWizzArd: Is there a better way to do this:

11:09 ,(get {:x 25} :y (delay (throw (Exception.))))

11:09 throwing an exception if a key is not present in a map/set

11:10 cgrand2: (since ~ expands to a fully qualified clojure.core/unquote it's easy to find)

11:10 Chouser: AWizzArd: Jason Wolfe wrote a safe-get or safe-map thing to do that.

11:10 cgrand2: Chouser: thanks for recommending it

11:11 Chouser: cgrand2: oh, you used ~ outside of ` ?

11:11 cgrand2: yes

11:11 Bracki: Hm, what do I need to set the classpath to if I've got multiple source files?

11:12 cgrand2: and the above paste is my attempt to get rid of those ~ by "controlling" macroexpansion

11:12 Bracki: I have this layout: start.clj start/other.clj

11:12 I can't call the stuff in other.clj from start.clj

11:13 cooldude127: Bracki: start/other.clj is a new namespace

11:13 you need to use it

11:15 Chouser: a couple dozen lines of Clojure is a lot of Clojure. It's likely to contain the same level of complexity as pages of Java.

11:19 so propagate is a tree walker

11:19 cgrand2: yup

11:19 Chouser: cgrand2: did you look at clojure.contrib.walk?

11:20 I don't know if it would help or not.

11:21 cgrand2: Chouser: I looked at it

11:21 Chouser: ok

11:22 cgrand2: propagate is not a complete tree-walker: it cooperates with the compiler

11:23 Bracki: (ns start :use [other])

11:23 right?

11:25 gnuvince: Bracki: (ns start (:use [other]))

11:26 cgrand2: and the around-form macro can be seen as a continuation passing mechanism

11:26 gnuvince: cgrand2: do you work in Clojure at work?

11:28 cgrand2: gnuvince: I try to (I'm a freelancer)

11:28 gnuvince: Ah OK.

11:29 * Raynes freelances cgrand2 in the neck!

11:30 * cgrand2 ???

11:30 * gnuvince is confused as well...

11:31 Raynes: Remove the free part and it makes sense.

11:33 cemerick: uh...

11:34 Raynes: "lances cgrand2 in the neck!"

11:34 Stop being dicks :<

11:36 brianh: cgrand2: OT but is that a rock outcropping behind you in your picture? you a climber?

11:38 cgrand2: brianh: it's a sycamore :-)

11:40 brianh: cgrand2: ahh

11:41 cgrand2: was just curious. have been to Fountainbleau several times & love visiting France

11:48 cgrand2: brianh: to climb on the sandstone boulders?

11:48 brianh: cgrand2: yes

11:50 cgrand2: most times i was actually in the area for work

11:51 cgrand2: but made sure i had time for fun :)

11:53 niet: (partial map f) , what the hell is that? just map then?

11:54 Chouser: niet: that's a bit like #(map f %)

11:54 jbondeson: Chouser: i'm running into some problems persisting xml zippers, have you ever done anything with this, or should i write some code around it to get that to work?

11:55 niet: what is a zipper really?

11:55 Chouser: jbondeson: persisting as in converting to bytes? I've not done that.

11:56 jbondeson: you want to keep the current node, not just the underlying logical tree?

11:56 niet: zip(a,b) -> [(a[0],b[0])...(a[n],b[n])] ?

11:57 Chouser: niet: nope, that's (map vector a b)

11:57 cemerick: niet: no, Huet zippers

11:57 jbondeson: Chouser: i'm trying to figure out some way to keep the structure sharing without getting crazy. i think i may just have to store raw xml and re-zipper on load

11:58 Chouser: niet: zippers are clojure.zip -- a data structure for storing a tree plus a "current node" in the tree

11:58 cemerick: jbondeson: what's the specific problem? I'd think print-dup would serialize a zipper pretty well.

11:58 Chouser: jbondeson: If you don't need the current node saved, that's probably the most sensible.

11:59 jbondeson: or save as clojure.xml data, printed. Then you can 'read' instead of xml-parsing.

12:02 jbondeson: cemerick: running into class format issues

12:05 cemerick: jbondeson: it'd be worth giving print-dup a try, I'd think

12:05 jbondeson: cemerick: trying it right now

12:06 Raynes: (doc print-dup)

12:06 clojurebot: excusez-moi

12:06 Raynes: Haha

12:07 jbondeson: cemerick: takes a little bit since i'm working with quite a bit of data ~25MB of xml

12:07 cemerick: ah-ha. Eww. ;-)

12:07 lisppaste8: hmm pasted "same result, why?" at http://paste.lisp.org/display/76153

12:08 niet: can someone tell me when ^^ gives different results?

12:10 Chouser: the fn returned by partial will take any number of args, and pass them all to max

12:10 the fn created by #(... %) will take only a single arg.

12:11 jbondeson: hmmm, still getting ClassFormat errors.

12:27 Lau_of_DK: Good evening cgrand + (rest #clojure)

12:27 jbondeson: 'ello

12:28 WizardofWestmarc: heya Lau

12:29 cgrand: Hi Lau_of_DK!

12:29 gnuvince: ,#clojure

12:29 clojurebot: No dispatch macro for: c

12:30 Lau_of_DK: I think this is both ridicously funny, and at the sametime it says a lot about most people nowadays: http://i39.tinypic.com/24w7ed0.jpg :)

12:30 jbondeson: man, this xml is gonna be the death of me.

12:30 never trust a technology with an X in it!

12:31 Lau_of_DK: jbondeson: XML in Clojure is a breeze :)

12:31 jbondeson: Lau_of_DK: except if you want to persist the parsed xml structures =(

12:32 having trouble with xml zippers

12:32 Lau_of_DK: jbondeson: How is that a problem ? Persist how ?

12:32 zip-filter?

12:32 lisppaste8: hmm pasted "euler" at http://paste.lisp.org/display/76155

12:32 jbondeson: i'm writing them out to file with print-dup and trying to read them back in, and running into ClassCast exceptions

12:32 niet: i cant figure out how that solution ^^ works

12:33 hiredman: jbondeson: you are writting out zippers yes?

12:34 jbondeson: yeah

12:34 Lau_of_DK: niet: It looks like it sums all the pairs, starting at the second lowest row, picks the max of that, and does the same on the row above, working its way to the top

12:34 niet: lau: yes

12:34 hiredman: I am not sure about ClassCastE but zippers use metadata, and I dunno if print-dup handles that

12:34 niet: but i wasnt clear. the last def , of s . it is recursiv without a basecase

12:35 jbondeson: hiredman: i'm doing similar things as clojurebot does with svn, just with much more data, and in verbose mode. so i'm caching tons of xml

12:35 hiredman: that makes sense.

12:36 Chouser: jbondeson: you're printing the zipper object, or the underlying tree?

12:36 jbondeson: Chouser: the actual zipper, i'm trying to keep the amount of data i have to store in memory down.

12:37 Chouser: ,(binding [*print-dup* true] (prn '(#^{:some :meta} x)))

12:37 clojurebot: (#^#=(clojure.lang.PersistentArrayMap/create {:some :meta}) x)

12:37 Chouser: print-dup does fine with meta-data

12:39 jbondeson: Chouser: i should be able to read that in with a simple "read" right?

12:39 cgrand: How are constants stored in clojure class files?

12:42 jbondeson: when you try to serialze zippers on small structures, does it work?

12:42 Chouser: jbondeson: yes, you should be able to just 'read' and get all of it.

12:42 jbondeson: cgrand: it works on simple structures, yes

12:43 Chouser: cgrand: I'm not very sure about this (went looking for the code, but haven't found it yet), but I think the constants are printed with print-dup and then read on class load.

12:43 jbondeson: Chouser: i must have been doing the print-dup wrong, when i did it the way you just did i now gett errors about missing anonymous functions

12:44 Chouser: jbondeson: ah, that sounds better. :-)

12:44 jbondeson: it's storing things like (clojure.core$complement__3465$fn__3467. )

12:44 Chouser: the fns hanging off the zipper node meta-data probably can't be printed/read.

12:45 jbondeson: makes sense.

12:45 i guess i'll have to keep the xml data as well, and then re-zipper the xml on load

12:45 cgrand: Chouser: thanks

12:45 jbondeson: or just do without a zipper

12:46 Chouser: jbondeson: there are three stages, right?: xml, parsed xml, and zipper

12:46 parsed xml should print/read ok, I think.

12:46 jbondeson: Chouser: yeah, i was just about to try that.

12:46 if i'm careful about how much i zipper at a time i can probably do an on-demand zipper

12:56 hah, the xml read is saying there's no matching ctor for clojure.lang.PersistentStructMap/create

12:57 ,#=(clojure.lang.PersistentStructMap/create {:tag :msg, :attrs nil})

12:57 clojurebot: No matching method found: create

12:57 jbondeson: lots o creates

13:00 it seems PersistentStructMap/create takes two args...

13:04 gnuvince: ~seen rhickey

13:04 clojurebot: rhickey was last seen quiting IRC, 152 minutes ago

13:05 jbondeson: spose i'm back to storing raw xml.

13:09 Chouser: jbondeson: ah, sorry, forgot about that. structs don't print-dup either

13:09 you could try plain printing -- they'd be read as array-maps, which are less memory efficient.

13:11 jbondeson: Chouser: think i'm going to just emit when persisting

13:11 * Chouser nods

13:15 yason: Hmmm, printing from a Swing application under Slime doesn't seem to work when control comes from the Java event loop. Does it sound like a Slime issue?

13:17 jbondeson: yason: check your inferior-lisp buffer

13:18 yason: jbondeson: ah, you're right. Is it possible to redirect it to the *slime-repl clojure* buffer?

13:18 jbondeson: unfortunately, no.

13:19 slime only grabs the result of an action.

13:19 it ignores anything else

13:19 yason: jbondeson: OK, good to know. Thanks!

13:19 jbondeson: if you're going to be doing tons of async printing turn off fancy

13:20 that'll give you slime features but drop the redirect buffer iirc

13:21 yason: "fancy" being which variable/function/mode? Didn't find anything immediately.

13:21 jbondeson: the call to slime-setup

13:22 usually it's (slime-setup '(slime-fancy))

13:22 yason: ah, that

13:22 jbondeson: if you just (slime-setup) fancy is disabled

13:23 yason: jbondeson: C-c C-z then switches to inferior lisp buffer if there's no repl buffer?

13:23 jbondeson: i don't have C-c C-z defined, what is it for you?

13:24 yason: slime-switch-to-output-buffer

13:25 jbondeson: haven't used non-fancy, but i would hope so =D

13:26 yason: I'll have to check it out

13:26 I don't print much or regularly, but debug prints are handy if you know where to find them

13:27 I don't use repl much though so I might stick with non-fancy, actually. Will have to check it out.

13:27 There's so much to configure in Slime I've never bothered to learn all the features :)

13:28 gnuvince: yason: just do like I do: use it like you have it now, when you see a configuration from someone else that you don't have try it out.

13:30 shoover: yason: M-x slime-redirect-inferior-output

13:30 yason: gnuvince: that's pretty much how I do it :)

13:31 jbondeson: yason: proof of your point, had no idea that slime-redirect-inferior-output existed.

13:31 yason: gnuvince: I trust I'll bump into any interesting and useful configurations over time

13:31 shoover: ditto!

13:31 gnuvince: yason: indeed. You can search for references to slime, init.el, etc. on github, you often find nice little jewels

13:34 jbondeson: you can have it always on by putting (add-hook 'slime-connected-hook 'slime-redirect-inferior-output) in your .emacs

13:39 Lau_of_DK: I asked a question earlier that I probably didnt understand the answer to. I'll try again. Lets say I have a Javafunc which takes 3 floats - clojure doesnt have shorthand for floats yet, so in the meantime, I want to do something like (.javaFunc obj (apply (fn [x] (float x)) [1 2 3])) - Why doesnt this work ?

13:39 yason: gnuvince: the usual for emacs too. I often end up coding some useful function in elisp until I find out next year that there's a package for it and it has been included in Emacs for years :)

13:39 jbondeson: thanks

13:42 Chouser: Lau_of_DK: did you try (.javaMethod obj 1 2 3) ? Numbers seem to be converted automatically.

13:42 ,(Float/isNaN 5)

13:42 clojurebot: false

13:42 Chouser: isNaN takes only a float

13:43 Lau_of_DK: hmm - Why didnt I think of that

13:43 I just noticed that 5.0 => double, so I figured it'd never work

13:43 jbondeson: Lau_of_DK: cause it was obvious and we programmers are in the business of making things harder ;)

13:44 Lau_of_DK: But ok, on principle, if I want to apply a function to a stream of numbers, and the resulting streams has to be passed as arguments, can that be done?

13:44 Chousuke: Lau_of_DK: for the manual conversion you want (apply #(javafunc %&) (map float [1 2 3]))

13:44 with a .

13:44 Lau_of_DK: %& ?

13:44 Chousuke: rest

13:44 Lau_of_DK: k

13:44 Thanks guys

13:44 Chouser: Chousuke: next. :-)

13:45 hm, not that either, I guess.

13:45 * Chousuke is not lazy yet!

13:45 Lau_of_DK: Chouser: I didnt update to LazyTown yet :) Still scared

13:45 * drewr isn't either

13:45 drewr: I'm still using a working copy from late Jan

13:46 jbondeson: lazy is fun

13:46 regardless of what clojurebot says

13:46 Chousuke: I should figure out how to make dd-wrt distribute the 5 DHCP IPs I get from my ISP to machines on my LAN

13:46 jbondeson: ~lazy?

13:46 clojurebot: lazy is hard

13:47 drewr: I'm sure it is fun, but I've got a alot of code to change.

13:47 jbondeson: come on, nothing is more fun than losing your mind debugging an infinte loop in the new lazy branch.

13:48 * jbondeson shakes his fist at swank-clojure

13:48 jbondeson: well, not branch, trunk now

13:48 Lau_of_DK: jbondeson: Isnt swank-clojure up and running with latest rev of Clojure?

13:48 jbondeson: yeah, it is

13:48 but i spent a couple days trying to fix it before jacho got to it

13:49 it was an adventure to say the least

13:56 danlei: kwoi

13:57 oops

14:02 Lau_of_DK: How do I get ant to realise where its dependencies are ?

14:03 jbondeson: ant dependencies or the project ant is compiling?

14:04 pietia: hello, which other language for JVM may be called "language for easier conurrent programming" ?

14:04 scala,clojure ... ?

14:05 Lau_of_DK: jbondeson: seems -lib did something

14:06 jbondeson: Lau_of_DK: i add a classpath node to the java node

14:06 Lau_of_DK: how ?

14:08 its The Hoeck !

14:09 jbondeson: Lau_of_DK: unger the java node you can add <classpath><path location="another.jar"/></classpath>

14:09 Lau_of_DK: oh ok

14:11 jbondeson: i'm not an ant expert, but that's how i have it setup

14:12 Chouser: pietia: I think Clojure addresses concurrent programming more directly than Scala. Another interesting choice may be Erlang.

14:12 WizardofWestmarc: does Erlang have a JVM version?

14:12 pietia: Chouser, but in must be for jvm :)

14:13 WizardofWestmarc: Erlang does look pretty awesome however, but thanks to clojure it dropped down my must learn list a fair bit

14:13 at the very least I want to pick up Haskell before I mess with it now

14:13 Chouser: pietia: ah, you did say that. Clojure, then. :-)

14:13 pietia: :)

14:13 any other language?

14:14 x10 from ibm

14:14 zakwilson: I just saw some Haskell-derived language for the JVM that might do a pretty good job with concurrency. I can't remember what it's called.

14:14 Chouser: WizardofWestmarc: Haskell's next for me, though mostly to understand monads in their natural habitat, and to see if there are any other goodies to bring back to Clojure.

14:14 WizardofWestmarc: right

14:15 it's a different style of coding then anything else w/o static typing or the like

14:15 zakwilson: Ahh, here we go: CAL - http://openquark.org/Open_Quark/Welcome.html

14:15 WizardofWestmarc: and I want to experience it to see what's useful

14:15 especially now that Real World Haskell is out

14:15 my one beef from my super limited time in Haskell is you can't define functions in the REPL >_<

14:21 Fib: WizardofWestmarc: You can, you just have to use 'let'...

14:21 e.g. >let my_add a b = (a + b)

14:23 shoover: what is clojurebot up to? Earlier I thought it was really working on a Clojure elevator controller, until I realized it was reporting links from somewhere

14:23 WizardofWestmarc: those are tweets

14:25 shoover: ah, thus the deja vu between that and my RSS reader

14:25 hoeck: Lau_of_DK: yes!

14:26 WizardofWestmarc: have a feed set up for the clojure search?

14:26 shoover: WizardofWestmarc: yes

14:26 WizardofWestmarc: I should do that

14:26 but instead I just go back to the page every so often

14:26 shoover: or just watch this channel, apparently :)

14:27 WizardofWestmarc: true enough hah

14:36 Lau_of_DK: java.lang.reflect.InvocationTargetException (NO_SOURCE_FILE:1)

14:36 I keep getting these when constructing an instance of a class - WHY? :)

14:44 0: sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

14:44 1: sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

14:44 2: sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

14:44 3: java.lang.reflect.Constructor.newInstance(Constructor.java:513)

14:44

14:44 I mean - What is this?

14:46 WizardofWestmarc: Fib: just saw your comment to me from before. Huh interesting

14:47 adakkak: can someone help me in compiling my clojure program into bytecode

14:50 here is the error http://paste.lisp.org/display/76160

15:01 zakwilson: adakkak: you need to have the classes directory in your classpath.

15:01 adakkak: is that something that I create?

15:03 Chouser: adakkak: yes, you need to create it and make sure it's in your classpath before you start up the jvm.

15:08 adakkak: Chouser: how does compile know that something is a class directory? also, I placed my class directory "../build/classes/nlp/" in my classpath with the same result

15:09 hiredman: adakkak: by default clojure writes out classes to a directory called "classes" in the working directory

15:09 if "classes" does not exist or is not on the classpath, it will not work

15:10 adakkak: created classes, but I get the same result

15:11 hiredman: is "classes" in your classpath?

15:11 (System/getProperty "java.class.path")

15:11 or something like that

15:12 adakkak: here is the output http://paste.lisp.org/display/76160#3

15:12 yes it is

15:13 hiredman: ah

15:13 here is you problem

15:13 don't compile single segment namespaces

15:13 switch to entity.detect

15:13 adakkak: what does that mean?

15:14 hiredman: segments are deliminated by dots

15:14 adakkak: so I should call my file entity.detect.clj and change the namespace accordingly?

15:15 hiredman: no

15:15 the file would be detect.clj

15:16 adakkak: and ns will be (ns nlp.entity.calais.entity.detect) right?

15:16 and ns will be (ns nlp.entity.calais.entity.detect) right?

15:16 hiredman: sorry about that, irssi went ape

15:16 adakkak: np

15:17 hiredman: if detect.clj is in nlp/entity/clais/entity/ then yes, that would be the namespace

15:17 hoeck: kotarak: will there be a port of your lazyMap to lazy clojure?

15:19 adakkak: nothing changed :(

15:21 cooldude127: ~gen-class

15:21 clojurebot: No, cooldude127, you want gen-interface + proxy

15:21 cooldude127: that's what i thought

15:22 hiredman: adakkak: "./classes/" still is not in your classpath

15:22 cooldude127: in that case, can someone explain to me why gen-interface is documented to do nothing if code is not being compiled? can code that uses gen-interface possibly work correctly when not compiled with this being the case?

15:22 adakkak: yep

15:23 hiredman: cooldude127: I think the idea is you compile the interface, and then use proxy at runtime

15:23 cooldude127: hiredman: oh

15:24 well we'll just see about that

15:24 adakkak: hiredman: it just worked

15:25 so if I want the classes files to be somewhere else then all I have to do is change the classpath and rerun the (compile...) function

15:25 hiredman: there is some ** var you can rebind to change the place where compile puts classes

15:25 ,(doc *compile-path*)

15:25 clojurebot: "; Specifies the directory where 'compile' will write out .class files. This directory must be in the classpath for 'compile' to work. Defaults to \"classes\""

15:26 adakkak: also, will java see the class as calais.detect, or will it be calais.Detect ?

15:27 hiredman: it will be whatever the namespace is

15:27 nlp.entity.calais.entity.detect

15:27 adakkak: does the file name play a role?

15:27 cooldude127: is swank-clojure still broken after the merge?

15:27 or do i just suck?

15:28 hiredman: adakkak: the last segment of the namespace and the filename should be the same

15:28 adakkak: ok

15:29 hiredman: adakkak: now, uh, if you are using (gen-class ...) outside of (ns ...) thinks are a little different

15:29 and even in the (ns ...) there are knobs you can tweak

15:33 adakkak: found it. thanks

15:33 kotarak: hoeck: there will. Just didn't come to it. Lazy branch merge happened with some other time-consuming things here. :)

15:36 adakkak: now I have to figure out how to let netbeans know about this new class

15:38 hoeck: kotarak: fine, i just looked at the lazymap sources today, currently I'm using hand-craftet maps of delays or pseudo-maps

15:39 cooldude127: ok i don't know what i'm doing wrong, i try compiling a namespace and i get and IOException: no such file or directory

15:39 kotarak: hoeck: that's what basically happens under the hood. However one needs also a LazyMapEntry to be truly lazy.

15:49 Bracki: Todays work: http://github.com/bracki/urkle/tree/master

15:49 hiredman: cooldude127: lets see some details

15:49 Bracki: kotarak: did you see my change to vimclojure? Without that it wouldnt run on my machine.

15:49 cooldude127: hiredman: (gen-interface

15:49 :name clojure.contrib.chrono.Instant

15:49 :extends [clojure.lang.IFn])

15:50 kotarak: Bracki: did you send me the pull request?

15:50 cooldude127: in the clojure.contrib.chrono namespace

15:50 Bracki: kotarak: yesa.

15:50 cooldude127: hiredman: tried (compile 'clojure.contrib.chrono)

15:50 hiredman: Bracki: awesome

15:50 cooldude127: i have an idea

15:50 Bracki: hiredman: aweful

15:50 hiredman: poor parsing etc.

15:51 kotarak: Bracki: yes. saw it. Sorry just didn't come around. I'm merging Gorilla with VimClojure and the lazy changes really hit me at difficult time.

15:51 Bracki: Ah ok.

15:51 cooldude127: nope idea fail

15:51 Bracki: kotarak: I just rebuilt gorilla w/ the lazy changes and it kind of works for me.

15:52 cooldude127: hiredman: nvm i got it figured out

15:52 kotarak: Bracki: in the bleeding edge there were some changes necessary. Geez. If have to get the changes out soon. :|

16:10 durka42: writing a program that reads files named ".update"... does anyone know if that name is taken?

16:12 kotarak: hoeck: pushed some changes for lazymap. I hope they are correct. I'm still not 100% sure about the lazy branch merge things. http://bitbucket.org/kotarak/lazymap/overview There is also a download button for .zip or .tgz. So you don't need hg.

16:25 hiredman: (doc alter)

16:25 clojurebot: Must be called in a transaction. Sets the in-transaction-value of ref to: (apply fun in-transaction-value-of-ref args) and returns the in-transaction-value of ref.; arglists ([ref fun & args])

16:34 Lau_of_DK: Do we have the 'final' keyword in clojure ?

16:34 (el-finito JPanel.) ?

16:36 (doc amap)

16:36 hiredman: uh

16:36 I broke clojurebot

16:36 I'd fix that

16:37 (doc amap)

16:37 clojurebot: Maps an expression across an array a, using an index named idx, and return value named ret, initialized to a clone of a, then setting each element of ret to the evaluation of expr, returning the new array ret.; arglists ([a idx ret expr])

16:38 powr-toc: Lau_of_DK: which sense of final do you mean?

16:38 durka42: how do you do (alias 'zip 'clojure.zip) in the ns macro?

16:38 Lau_of_DK: powr-toc: the keywords which disallows subclasses

16:38 hiredman: durka42: (:require [clojure.zip :as zip])

16:39 durka42: aha

16:39 hiredman: Lau_of_DK: you mean for gen-classed classes?

16:39 durka42: require is the only one i didn't try

16:39 Lau_of_DK: hiredman: no I mean for instantiations of java classes

16:40 powr-toc: Lau_of_DK: it doesn't look like it

16:40 hiredman: Lau_of_DK: "the keywords which disallows subclasse" has no meaning in that case

16:41 Lau_of_DK: Why

16:41 hiredman: because you are not doing anything subclass realated

16:41 powr-toc: hiredman: sure it does... final classes can't be specialised

16:41 hiredman: you are instatiating a class

16:42 not making a new class (which you would declare final)

16:43 Lau_of_DK: final PhysicsGameState physicsGameState = new PhysicsGameState("Physics tutorial");

16:43 When I port this java code to clojure, it boorks

16:43 Im wondering if its the keyword final

16:43 powr-toc: Lau_of_DK: that's just an immutable reference type

16:43 durka42: if you declare a variable in clojure it's going to final, no?

16:43 going to be*

16:43 powr-toc: Lau_of_DK: in clojure vars, refs, agents, atoms etc... all have concurrency semantics

16:44 durka42: ,(prn (String. "test"))

16:44 powr-toc: so you don't really need final

16:44 clojurebot: "test"

16:45 hoeck: kotarak: wow, that was fast!

16:45 Lau_of_DK: k

16:45 powr-toc: durka42: not exactly... I don't think clojure has a direct parallel to final, i.e. you can rebind all clojure reference types... it's just they all have concurrency semantics

16:45 hoeck: kotarak: hg is just one "emerge" away :)

16:46 kotarak: hoeck: well it's a small library. It can be improved however. Will check whether a LazyMapSeq should extend ASeq.

16:47 hoeck: on the webinterface there are also links to clone the repo. hg clone http://bitbucket.org/kotarak/lazymap IIRC.

16:48 hoeck: kotarak: yeah, just figured that out, even simpler than downloading, unzipping ... :)

16:48 kotarak: hoeck: oh, and the changes are without warranty. If you try, please let me know, whether there are problems.

16:50 hoeck: kotarak: unfortunately there are, the new rest does not work on the lazy map's seq, only next does

16:51 kotarak: hoeck: huh? I checked in the repl. There it seemed to work. Let me check again.

16:51 * kotarak needs more unit tests.

16:54 danlarkin: Lau_of_DK: is "breena" a good name?

16:54 * kotarak bangs head against the wall.

16:55 hoeck: kotarak: and building lazymap with a assert-if-lazy-seq fails here, but without it works

16:55 hiredman: ,@hiredman.clojurebot.seenx/activity

16:55 clojurebot: Pardon?

16:56 hiredman: damn your eyes

16:57 danlei: why did rhickey call it "next" btw? i liked "more" better somehow. (next sounds like "the next element" to me)

16:57 tashafa: hello clojure

16:58 clojure gives me that warm and fuzzy feeling inside

17:00 Chouser: tashafa: and it tastes great, besides.

17:00 danlei: there a big ol' thread on that topic. You missed it?

17:01 danlei: 69 messages: http://groups.google.com/group/clojure/browse_thread/thread/88d9fdb5bcad36a/ac087a3c5447a43b

17:01 danlei: Chouser: i'm not following the group closely, i'll read it up, thanks.

17:02 tashafa: question... if I wanted to run a background process that runs every 15mins or so, would I be in the ballpark if I used atoms

17:02 ?

17:03 Chouser: tashafa: what's the result of the process? Some side effects, or updating a value.

17:03 actually, either way atom is probably wrong. More likely you want an agent.

17:03 tashafa: hmm... updating a database, i guess that would be a sideeffect

17:03 yeah ii was just looking at it

17:04 the book im reading calls for agents

17:04 Chouser: or maybe even just a Timer

17:04 hiredman: ugh

17:05 don't use a Timer

17:05 tashafa: too Java?

17:05 powr-toc: Using a ScheduledThreadPoolExecutor directly might be a good option

17:05 hiredman: yes

17:05 ~jdoc ScheduledThreadPoolExecutor

17:05 er

17:05 that is not right

17:06 powr-toc: http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html

17:06 hiredman: yeah

17:07 Chouser: danlei: even if you don't read all of the group, I'd recommend this higher signal/noise ratio subset: http://tinyurl.com/bntq4v

17:08 danlei: Chouser: thanks for the tip, bookmarked

17:08 jbondeson: Chouser: in my ever continuing xml saga, do you know if there is a reason that rich had clojure.xml/emit println rather than create a string?

17:09 Chouser: I don't for sure, but my guess is that when printing to disk or network, you wouldn't have to hold the whole thing in memory before you began sending.

17:09 jbondeson: you should be able to rebind *out* if you want it to go to disk or a socket instead of stdout

17:09 or use 'with-out-str' if you want it in a string.

17:09 jbondeson: already on it

17:09 Chouser: ok

17:09 Bracki: I still have those namespace problems.

17:10 lisppaste8: Bracki pasted "Namespace issues" at http://paste.lisp.org/display/76172

17:12 * danlei wishes google groups allowed nntp access

17:12 hiredman: Bracki: you have your namespace reversed

17:13 if the namespace is urkle.test the fil should be urkle/test.clj

17:13 if the filename is test/urkle.clj the namespace should be test.urkle

17:14 Bracki: That doesn't change anything unfortunately.

17:15 Can the files be in a different namespace but in the same path?

17:15 Or is this just like Java packages?

17:15 hiredman: a namespace is a java package

17:16 Chouser: a namespace is like a java package, but is also a java class.

17:17 Bracki: Hm, I just don't get it.

17:18 drewr: danlei++

17:18 Bracki: I have ./urkle.clj and test/urkle.clj, I want to use urkle and urkle.test as namespaces. What's wrong here.

17:18 Is that a classpath issue?

17:19 Chouser: to use a .clj as a lib, it must be at least one dir down.

17:19 hiredman: is test/urkle.clj in the same directory as ./urkle.clj?

17:19 Bracki: yes.

17:20 Chouser: bracki/urkle.clj and bracki/urkle/test.clj

17:20 jbondeson: oy... and that still won't work because i have embedded quotes in the xml now.

17:20 Chouser: they should start with the ns macro declaring bracki.urkle and bracki.urkle.test respectively.

17:20 jbondeson: looks like i'm rewriting emit

17:20 Chouser: jbondeson: use clojure.contrib.lazy-xml/emit

17:21 jbondeson: that should work even if you used clojure.xml to parse

17:22 jbondeson: Chouser: that uses println also

17:22 Chouser: yes, but it escapes quotes and such correctly.

17:23 jbondeson: is there something wrong with 'with-out-str'?

17:23 oh, sorry

17:23 it's the newlines that are bothering you?

17:23 jbondeson: Chouser: no, what i mean is that the resulting string looks like this: "\"<?xml version='1.0' encoding='UTF-8'?>\"\n

17:23 which is invalid xml

17:24 every call to print adds a beginning quote and ending quote, which both with-out-str and manual binding

17:25 Chouser: that's not right

17:25 hiredman: uh

17:27 jbondeson: Chouser: would using *print-dup* potentially cauase any issues?

17:27 when persisting that is

17:27 Bracki: It still doesn't work. I'm doing it just like technomancy. http://github.com/technomancy/mire/tree/master

17:28 hiredman: ,(binding [*print-dup* true] (println "foo"))

17:28 clojurebot: "foo"

17:28 hiredman: ,(binding [*print-dup* false] (println "foo"))

17:28 clojurebot: foo

17:28 hiredman: I guess so

17:28 Chouser: jbondeson: ah! yes it would.

17:29 kotarak: hoeck: pushed a fix (hopefully). Works here with and without assert-if-lazy-seq, though.

17:30 hoeck: ok. And maybe I'm too stupid to the flag. Just a sec.

17:30 jbondeson: now i just need to nuke all these '\n's

17:30 Bracki: Moved everything to src. So now I have src/urkle.clj and src/urkle/test.clj.

17:31 Shouldnt java -cp /path/clojure.jar:src/ clojure.main src/urkle.clj work?

17:32 hiredman: Bracki: depends on the namespaces declared in urkle.clj and test.clj

17:32 Chouser: Bracki: I'm pretty sure a lib with no dot in its name is not valid.

17:32 hiredman: *namespace

17:32 Chouser: that's why I suggested bracki/urkle.clj for the ns bracki.urkle

17:33 kotarak: hoeck: No. It's ok. Seems to work now. :) Please let me know any more problems. :) Gotta go now, though. I'm around here from time to time or via the email in the README.

17:34 lisppaste8: Bracki annotated #76172 "namespace" at http://paste.lisp.org/display/76172#1

17:35 hiredman: ugh

17:35 Bracki: your namespaces are still all wrong

17:35 fix them.

17:37 clojurebot: namespaces?

17:37 clojurebot: excusez-moi

17:37 Bracki: Sorry for being a dunce. But what is all wrong?

17:37 Chouser: Bracki: I'm pretty sure a lib with no dot in its name is not valid.

17:38 that's why I suggested bracki/urkle.clj for the ns bracki.urkle

17:38 Bracki: But why does the stuff work I posted.

17:38 Because of that awful (add-classpath) sutff?

17:38 Chouser: oh, you got it working?

17:39 Bracki: No, but my layout is the same as in technomancy's mire. He also has a single ns without any dots.

17:39 hiredman: clojurebot: namespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it

17:39 clojurebot: Ik begrijp

17:40 hiredman: Bracki: well, technomancy is doing it wrong, so you will have to ask him how he got "doing it wrong" to work

17:41 Chouser: the "at least one dot" rule may only apply when you try to compile to bytecode, I'm not sure.

17:41 hiredman: which branch of mire are you looking at?

17:41 Bracki: The latest.

17:42 hiredman: Chouser: feel free to alter clojurebot's brain

17:42 Bracki: http://github.com/technomancy/mire/tree/master

17:42 hiredman: Bracki: mire is developed in several steps, which are shown in the branches

17:43 Bracki: The master branch has everything.

17:43 hiredman: ;urkle/test.clj

17:43 (ns urkle.test

17:43 whoops

17:43 Chouser: hiredman: either way. nobody wants to find out they have to rename everything just to get it to compile.

17:47 Bracki: Inside a namespace do I have to :use myself?

17:48 Chouser: no

17:49 Bracki: well that's causing the bloody problem.

17:50 danlei: ok, having read the thread, i still feel that "next" connotates returning an item, and would have preferred something like "rest", but that's just words. i'll get used to it.

17:52 oops s/rest/more/

18:00 lisppaste8: Bracki annotated #76172 "So close." at http://paste.lisp.org/display/76172#2

18:00 Bracki: OK, I nearly have it.

18:01 So how do I include a package that's on the same level? As in test.clj.

18:04 hiredman: if you are in the urkle directory, the classpath should not contain "\urkle\"

18:04 just "\."

18:04 Bracki: No I have urkle\urkle.

18:06 Chouser: try "urkle" instead of "\urkle" perhaps?

18:07 hiredman: if you are remove back-slashes I would just remove the leading one

18:08 Bracki: Could that be a Windows issue?

18:08 How do I print the classpath from the repl?

18:11 hiredman: (System/getProperty "java.class.path")

18:11 Bracki: Yippie. It works.

18:12 The correct classpath is: java -cp ..\path\clojure.jar;..\path\clojure-contrib.jar;. <--- Notice the dot after the semicolon.

18:13 hiredman: 15:03 hiredman : if you are in the urkle directory, the classpath should not contain "\urkle\"

18:13 Bracki: hiredman: Yeah, well said.

18:13 Thanks and sorry for bothering you guys.

18:17 When using clojure.main to run a file, what do I need to do exit back to the shell?

18:18 drewr: Bracki: It'll exit when -main returns.

18:19 hiredman: java clojure.main --help

18:19 it has a list of different options

18:19 do you mean just kill the repl and exit the jvm?

18:19 (System/exit)

18:19 or Ctr-Z on windows?

18:22 Bracki: Yes. (System/exit)

18:25 tashafa: xml question... how do i get the content of every tag with a name into a seq?

18:25 i have a fn that does this but there should be an easier way

18:26 e.g. every 'link' content in an atom feed

18:26 Bracki: ,(doc xml/parse)

18:26 clojurebot: java.lang.Exception: Unable to resolve var: xml/parse in this context

18:26 Bracki: ,(doc clojure.xml/parse)

18:26 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"

18:28 tashafa: Bracki: yes, but do i have to walk each hash-set filtering out the results?

18:28 hiredman: tashafa: how else would you do it?

18:29 tashafa: hiredman: well i thought there would be some easier way in clojur.contrib

18:30 Chouser: tashafa: you might look at clojure.contrib.zip-filter.xml

18:30 tashafa: i wish clojure.contrib had an api documentation on the web

18:30 as cool

18:30 ah cool*

18:30 thanks

18:32 Bracki: Any code coverage tools for clojure yet?

18:34 tashafa: Chouser: exactly what i was looking for, even authored by you... you are the man

18:37 westajay: ok.. heading home...

18:37 byeeeee.

18:38 sorry.. wrong channel.. :-)

18:42 tashafa: hmm.. any idea on why its called 'zip'

18:42 hiredman: it uses zippers

18:42 powr-toc: just looking through the implementation of agents... am I right in thinking that watchers only fire, if the state is set to a different object? i.e. if you were to wrap a java.util.HashMap in an agent, and modify the map with the function you pass to the agent, the watchers wouldn't be notified?

18:42 tashafa: hahaha

18:42 hiredman: no

18:42 for real

18:42 clojure.zip

18:43 tashafa: yeah im looking at it now

18:43 hierarchical zipper

18:43 hiredman: they are way cool

18:43 Chouser: powr-toc: that's right. Clojure's reference types generally assume you're using immutable data.

18:44 powr-toc: Chouser: yeah, I knew that was the default... and it makes sense; just something to be aware of i.e. that the test is an identity test, not an equality one

18:45 tashafa: so much to learn, so little time

18:45 Chouser: oh, I see what you were asking.

18:45 tashafa: yeah -- I don't have a tutorial for zip-filter yet.

18:46 tashafa: but hopefully the examples in the comment there are enough for you to make it work, even if you don't know exactly what's going on underneath.

18:46 powr-toc: I'm loving being able to quickly dig through the implementation source code, clojure's source is way more accessible than almost any other language I know of

18:46 tashafa: Chaouser: problem solved... the tests in zip-filter.xml is enought

18:46 Chouser: tashafa: ah, good.

18:46 tashafa: were enough*

18:47 Chouser: great, so if you wouldn't mind writing up a tutorial...

18:47 tashafa: everything just works as advertised and you can write and test your whole application in the repl

18:48 i'm in programming heaven

18:49 hmm.. write a tutorial? on just contrib.zip-filter?

18:49 Chouser: sure, if you'd like.

18:49 I was joking a bit of course, by any such documentation would be welcom.e

18:50 tashafa: ha

18:50 Chouser: man, I can't type.

18:50 tashafa: a tutorial would be nice though... but i think the tests are enough

18:50 Chouser: "but any such documentation would be welcome"

18:53 tashafa: all i think we need are the docs of the functions of clojure.contrib in an indexable format... the tests and fns are succint enough to grasp how they work

18:56 for now

18:56 documentation will be needed later down the road when the dust settles

19:25 clojurebot: svn rev 1307; added type

19:26 * durka42 was using clojure's fraction reducing to help w/ math hw yesterday

19:26 durka42: but then sometimes i get annoyed when i type (/ 783 25) at the repl "783/25 is what i typed! i want to know what that is!"

19:28 is that svn change for custom print-methoding?

20:18 Raynes: http://paste.pocoo.org/show/105483/ Completely irrelevant, but entertaining either way. The main developer of SharpE (which is the channel I was in.) (he's also a Delphi programmer) agreed with her and I eventually got banned for calling her a bitch.

20:21 danlarkin: we're not here to justify your bigotry :)

20:21 Raynes: Mind you, she insulted me 5 times before hand just for trying to explain it to her.

20:21 cooldude127: lol

20:22 Raynes: I don't believe it's bigotry, as I have about 25 people on hand right now to agree with me. A command line and a text editor, and knowledge to use them are essential tools for every programmer.

20:23 90% of you use Emacs for Clojure.

20:23 cooldude127: yes we do

20:23 Raynes: I use an Netbeans.

20:23 See my point?

20:23 ._.

20:24 * cooldude127 can't stand any of the ide's for one reason or another

20:24 Raynes: I /could/ use emacs and a command line for Clojure, but I choose not too because Enclojure exists.

20:24 * cooldude127 wants to write a decent java environment for emacs (and will probably never finish)

20:25 * cooldude127 loves SLIME and wants to marry it

20:25 gnuvince: haha

20:25 * cooldude127 needs to use a little less /me

20:25 Raynes: That's true nerdism right there.

20:25 Embrace the nerd.

20:25 cooldude127: lol

20:26 danlarkin: ok I've got some actual clojure content to talk about for once... I need some help writing the following functionality in a functional style

20:26 gnuvince: The difference between choosing Emacs or choosing Eclipse/Neatbeans/etc. is whether you want/need something that you can configure completely like you want it or just a package that works well enough

20:26 cooldude127: danlarkin: i love these probleems

20:27 danlarkin: it's for my django clone/rewrite/whatever, it's for applying middleware,

20:27 so there's this function that takes a request-map and returns an response-map

20:28 and inside this function it examines the URL and then calls another function, a "view" to handle it, depending on the url

20:28 cooldude127: danlarkin: paste it :)

20:28 danlarkin: and it also applies "middleware" functions to the request and response at different points

20:29 so a middleware can define itself to be called before the view runs, after the view runs, etc

20:29 a few places

20:29 cooldude127: PASTE

20:30 :)

20:30 danlarkin: so the way I've got it now (which is wrong) is (merge (map call-middleware list-of-middlewares))

20:30 fiiiiine

20:30 cooldude127: lol

20:30 danlarkin: this sounds like, without seeing it, a problem for reduce

20:31 rather than map

20:31 danlarkin: well

20:31 I haven't gotten to the problem yet

20:32 lisppaste8: url

20:32 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

20:32 cooldude127: i love lisppaste.el

20:33 lisppaste8: danlarkin pasted "middleware" at http://paste.lisp.org/display/76179

20:33 gnuvince: cooldude127: link?

20:34 cooldude127: http://www.ph.ed.ac.uk/~s0198183/lisppaste.el

20:34 danlarkin: ok, so that's the main dispatch function or whatever

20:34 Chouser: durka42: I do believe you're right.

20:34 durka42: should be useful

20:35 danlarkin: the problem, though, is if I want a middleware to be able to return a response

20:35 instead of just modifying the request

20:36 if I want a middleware that short-circuts all requests for an URL with an "e" in it (whatever), it needs to be able to just return a response, straight up

20:38 cooldude127: danlarkin: this still seems like you need to do a reduce-like loop/recur, where you check for a certain sentinel value

20:39 danlarkin: seems like a good way would be a list of before-middleware functions, the view function, and then after-middleware functions

20:40 that all get a request and response and do their stuff with that

20:40 but as part of a response, they can signal they are done

20:40 it's basically a pipeline

20:41 so instead of that merge call, you just start the loop with that data in the response, and then the pipeline does as it pleases

20:42 * cooldude127 would like somebody to tell him if he's carried away or has lost anyone involved

20:42 danlarkin: I'm thinking it over

20:43 cooldude127: each middleware becomes a pure function that takes a request and response and returns modified versions of both/either of them. the response has an attribute that tells if it's done. the loop checks this

20:44 you could just use reduce if you didn't need to short-circuit, but because you do, loop/recur is a good way

20:46 danlarkin: yes, originally I was using reduce, but I realized it was unnecessary, since merge takes & args

20:46 but yes, I'm going to try to riff on this and I'll get back to you, thanks

20:46 cooldude127: danlarkin: k cool :)

21:17 powr-toc: Presumably watchers run in the calling thread when used with refs?

21:18 Chouser: not currently

21:19 powr-toc: ahh of course... they have to be agents

21:19 Chouser: watchers are currently agents

21:19 right

21:19 But that will change soon, I believe

21:19 rhickey: right

21:19 powr-toc: is it known what the change will be?

21:20 Chouser: powr-toc: this is what I know: http://code.google.com/p/clojure/issues/detail?id=80

21:20 powr-toc: yeah, you showed me that the other day :-)

21:20 Chouser: well, there you go then.

21:21 powr-toc: I was having the same thoughts, when rewriting code from the previous implementation

21:23 Chouser: yeah, my one real use of watchs was much simpler than when I rewrote to use watchers.

21:24 I await the new API with anticipation.

21:24 powr-toc: me too :-)

21:30 hiredman: (doc lazy-seq)

21:30 clojurebot: Takes a body of expressions that returns an ISeq or nil, and yields a Seqable object that will invoke the body only the first time seq is called, and will cache the result and return it on all subsequent seq calls. Any closed over locals will be cleared prior to the tail call of body.; arglists ([& body])

21:31 hiredman: clojurebot: where is your brain?

21:31 clojurebot: No entiendo

21:31 hiredman: clojurebot: brain dump?

21:31 clojurebot: brain dump is http://clj.thelastcitadel.com/clojurebot

21:37 durka42: clojurebot: it's too late to apologize

21:37 clojurebot: Pardon?

21:37 durka42: clojurebot: apologize for me, i don't feel like it

21:37 clojurebot: mea culpa!

21:39 danlarkin: heh, where are the docs on destructuring? I can't seem to find them ATM :-[

21:40 Chouser: http://clojure.org/special_forms#let

21:40 hiredman: clojurebot: destructuring?

21:40 clojurebot: Gabh mo leithsc�al?

21:40 hiredman: clojurebot: destructuring is http://clojure.org/special_forms#let

21:40 clojurebot: In Ordnung

21:41 danlarkin: thanks :)

21:42 * danlarkin can never remember the syntax for destructuring maps

21:42 hiredman: huh

21:43 java.lang.management

21:50 Chouser: durka42: apparently it's not meant for custom printing, but it'll do

21:50 durka42: what is it meant for?

21:50 Chouser: ,(.addMethod print-method :foo (fn [o w] (doto w (.write "#<foo: ") (.write (:x o)) (.write ">"))))

21:50 clojurebot: #<MultiFn clojure.lang.MultiFn@1137792>

21:50 Chouser: ,#^{:type :foo} {:x "whee"}

21:50 clojurebot: {:x "whee"}

21:50 Chouser: fail.

21:51 durka42: bot might not be updated

21:51 Chouser: oh, of course

21:51 durka42: http://groups.google.com/group/clojure/msg/a378004f6d7419b8

21:56 cmvkk: i want something where you can write a function that takes a single integer argument, then you can use it like you would a vector, like with get or seq or map.

21:56 you'd have to change java stuff to implement something like that right?

21:56 Chouser: you can probably do it with proxy, but I'm not quite sure what you want.

21:58 cmvkk: well like i mean you could write (defn foo [x] (+ x 2)) and then do (get foo 3)

21:58 or (map #(* % 3) foo)

21:59 powr-toc: cmvkk: I'm guessing you could use a proxy to implement ISeq, and that'd give you everything except special reader syntax for vectors...

22:00 cmvkk: oh yeah proxy. but it definitely would involve implementing ISeq.

22:01 hiredman: ~def get

22:02 Chouser: ,(let [z (proxy [clojure.lang.Associative] [] (seq [] '(4 5 6)) (valAt [n] (+ 3 n)))] (prn (get z 5)) (prn (map #(* % 3) z)))

22:02 clojurebot: java.security.AccessControlException: access denied (java.lang.RuntimePermission accessDeclaredMembers)

22:03 hiredman: :)

22:03 cmvkk: heh

22:04 Chouser: no proxy, eh?

22:04 hiredman: I guess

22:05 * hiredman doesn't want to dig into the jvm permissions stuff

22:05 cmvkk: i guess ignoring get, i could just write a function that takes a function like that and returns a lazy seq, which is good enough for map and stuff.

22:05 Chouser: so, you may not need to implement ISeq, just a seq method that returns an ISeq

22:06 cmvkk: (defn fnseq ([x] (fnseq x 0 nil)) ([x s e] (map #(x %) (range s e)))) or something

22:10 stuhood: is there an equivalent of (contains?) for lists/vectors?

22:10 Chouser: if you're doing that kind of operation, a set or map might work better.

22:11 stuhood: i suppose... its for the arguments to a script

22:11 Chouser: you can do a linear scan of the seq if you really want to.

22:11 durka42: those could be positional

22:11 i.e. not a set

22:12 Chouser: ,(some #{'c} '(a b c d e))

22:12 clojurebot: c

22:12 stuhood: well, it seems reasonable to have something like that in the standard library... understanding that it would be O(n) of course

22:13 Chouser: ,(.contains '(a b c d e) 'c)

22:13 clojurebot: true

22:13 Chouser: hard to get much simpler than those.

22:13 stuhood: oh, that works too

22:13 i forgot clojure collections implement Collection

22:14 Chouser: thanks!

22:15 Chouser: ,('c (set '(a b c d e)))

22:15 clojurebot: c

22:15 Chouser: sure

22:50 danlarkin: cooldude127: okay, looks like I've got it worked out. It's a lot uglier, but it works

23:18 stuhood: ~defn pmap

23:18 clojurebot: Excuse me?

23:19 stuhood: phooey... what was that command

23:19 durka42: ~source pmap

23:28 hiredman: ouch

23:35 stuhood: durka42: thanks!

23:51 icey: Who has the best setup docs for setting up a new machine for developing with clojure? Is it still Bill Clementson's?

23:52 arohner: icey: probably

23:53 icey: arohner: thanks!

Logging service provided by n01se.net