#clojure log - Jan 01 2010

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

0:01 chouser: Happy new year!

0:02 piccolino: Happy new year, Mr. East Coaster!

0:02 chouser: :-)

0:02 dandersen: Happy New Year =]

0:42 replaca: Happy new year, #clojure. Looking forward to 2010!

1:54 optimizer: what's a good resource for java gui's with clojure?

1:54 pdk: the java_interop page on the clojure site illustrates using swing with clojure

1:55 optimizer: url?

1:55 pdk: remember that you can call java code directly within clojure so you can just pick whatever you want that already works with java and use it in a very similar way in clojure

1:55 optimizer: yeah; but I don't know java; lol

1:55 pdk: http://clojure.org/jvm_hosted

1:55 a little example of how swing code in clojure looks basically the same as in java

1:56 optimizer: i heard bad things about awt/swing

1:56 what gui library should I ue?

1:56 *use*

1:56 pdk: java comes with awt and swing out of the box for gui programming, you should be able to find plenty of tutorials

1:56 optimizer: my background is c/c++/scheme /opengl

1:56 pdk: we'll have to know what sort of things you want out of your gui library, what sort of application you expect to write with it etc

1:57 what sort of things in a widget toolkit are important for the program youre writing, things like native look and feel, speed, portability etc

1:57 optimizer: is there a central refernce that lists the options & tradeoffs?

1:57 i want to write a text editor that supports wysiwyg math rendering

1:57 kinda like texmacs / lyx

1:57 but in clojure

1:57 piccolino: Well, I'm pretty sure you can knock AWT right off the list.

1:58 optimizer: piccolino: why?

1:58 pdk: as far as i know the most well-known alternative to awt/swing is SWT

1:58 piccolino: It's not really adequate for anything.

1:58 optimizer: pdk: the one by eclipse/ibm?

1:58 pdk: eclipse for example is entirely swt based

1:58 yeah

1:58 and i assume there'd be a wxwidgets binding

1:58 optimizer: eclipse looks pretty nice

1:58 piccolino: Have they packaged SWT up so it's easy to use on it's own yet?

1:59 pdk: there's a slashdot post discussing swing vs swt in the comments

1:59 http://developers.slashdot.org/article.pl?sid=06/02/25/2110220&from=rss

1:59 optimizer: you know what? if it's good enough for eclipse; it's good enough for me

1:59 but I will read the link; thanks

1:59 pdk: here's a java binding to wxwidgets http://jwx.sourceforge.net/

2:00 optimizer: pdk: you realize this is irc and not a $$$/hr consulting job right? :-D

2:00 pdk: if you want native look and feel on every platform you're delivering the program for then yes you'll want swt or wxwidgets

2:00 well you want to make picking up clojure not painful :p

2:01 swing has its own look and feel so it's the same on every platform but doesn't really mesh with any of them

2:01 optimizer: favorite comment:

2:01 Buoy [sourceforge.net] is your friend. It's built on top of Swing, but it's actually sanely usable. I recommend it on the grounds that it is the only Java GUI toolkit I have ever used that did not leave me longing for the sweet embrace of death. Developing an application using Buoy is substantially less painful then stabbing yourself in the eye with a fork. In the world of Java GUI development, this is high praise indeed.

2:01 pdk: except for probably solaris or something

2:01 optimizer: man; reading this makes me want to juse use jogl :-)

2:02 pdk: provided you're up for writing your own widgets :p

2:02 piccolino: I suspect you'll wind up on wxwidgets.

2:02 pdk: actually iirc there should be little windowing libraries for lwjgl

2:02 just as there were for pygame

2:03 in terms of running fast swt and wxwidgets will probably trump swing

2:03 though swt might not have the kitchen sink or be as concise in code

2:10 optimizer: http://www.dragmath.bham.ac.uk/index.html#Download

2:10 hmm; looks like someone already invnted it

2:11 pdk: it can be a language learning exercise at least

2:15 optimizer: is enclojure written in clojure?

2:15 pdk: that's its claim to fame

2:16 oh wait

2:16 i thought you meant compojure there, i'd assume enclojure would be a mix of java/clojure as it's a netbeans module

2:16 optimizer: wait; this is weird; i see a clojure-1.1.0.zip that is uplaoded in may 2009 ... but i recall reading the changelog for 1.1 just today

2:16 pdk: compojure is a clojure based web server

2:16 the older one would most likely be a poorly labeled release candidate

2:17 hiredman: framework

2:17 pdk: well web server framework

2:17 optimizer: http://code.google.com/p/clojure/downloads/list

2:17 where do I get the latest?

2:17 oh

2:17 hiredman: pdk: nope

2:17 optimizer: i see the 17 hours ago one

2:17 okay

2:17 pdk: but yes you'll want the most recently dated 1.1.0

2:17 that one looks like 1.0.0 to me :p

2:18 optimizer: yeah; perhaps i need new glasse

2:18 hmm, i just built clojure with ant

2:18 is there no 'ant install' ?

2:19 pdk: http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started this part talks about installing clojure through ant

2:19 and git

2:20 optimizer: The state of the art in using Vim to edit Clojure code is the VimClojure plugin (recently merged with the Gorilla plugin, and depends on having a Ruby-enabled Vim (A Windows build of vim including Ruby support can be found here)).

2:20 that sounds like such a hack

2:20 pdk: one thing you learn from it all is

2:20 lispers love emacs :p

2:21 optimizer: too bad emacs love elisp

2:24 defn: elisp is a lisp

2:24 what's not to like?

2:25 elisp is the ruby to my clojure

2:32 optimizer: does clojure run on java 7? (i use xmonad; and apparently xmonad dislikes java gui's on java 6)

2:34 pdk: it runs on at least 6

2:34 if i recall possibly 5 to

2:34 too

2:34 though i wasn't aware of a 7 haha

2:40 hiredman: defn: lack of lexical scoping

5:59 LauJensen: Morning team

6:24 Mec: How might I make a sequence that is the running total of another sequence? ex [1 2 3 4 5] -> [1 3 6 10 15]

6:30 cark: ,(doc reductions)

6:30 clojurebot: "([f coll] [f init coll]); Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with init."

6:31 Mec: is that in contrib?

6:32 hoeck: Mec: in clojure.contrib.seq-utils

6:33 Mec: thanks

6:48 LauJensen: clojurebot: source reductions

6:48 Beautiful

6:56 Mec: wow i have no idea what thats doing

6:57 it seems like you should be able to use reduce to do that

7:05 cark: ,(reductions + [1 2 3 4 5])

7:05 clojurebot: (1 3 6 10 15)

7:06 cark: sorry i had to go afk and couldn't follow up

7:23 Mec: ,(reduce #(conj %1 (+ (last %1) %2)) [1] [2 3 4 5])

7:23 clojurebot: [1 3 6 10 15]

7:23 Mec: but that would be really inefficient i think

7:38 is for expanded upon anywhere besides the api docs?

7:39 cark: why wouldn't you use reductions ?

7:40 you can check the source

7:40 clojurebot: source for

7:40 or use macroexpand

7:41 Mec: I can't get clojurebox to load contrib

7:42 cark: you need to make sure that clojure-contrib is in your classpath

7:42 Mec: and for some reason that link wont load past line 1908

7:42 cark: i'm not using clojurebox so i can't help on that

7:43 hum the link is working for me !

7:43 for is a very complex macro anyways

7:43 Mec: humm

7:44 i remember reading something before saying like you cant use :while and :when in the same one, but i cant find that now

7:46 cark: ,(for [i [1 2 3 4 5 6 7 8] :when (odd? i) :while (< i 4) ] i)

7:46 clojurebot: (1 3)

7:46 cark: i don't know, looks like it's working =P

7:46 Mec: hmm im also useing :let ;p

7:47 cark: i think when you have an hardcore for, it might be bad smell

7:47 Mec: ,(for [i [1 2 3 4 5 6 7] :let [j (inc i)] :when (odd? j) :while (< j 5)] [i j])

7:47 clojurebot: ([2 3])

7:49 Mec: weird, that works for me too, gotta be something else

7:49 does the order of when and while matter?

7:50 Chousuke: probably :P

7:50 cark: well it wouldn't be very nice if it did

7:51 Mec: bah infix error strikes again

7:51 i had a :when (total = 200)

7:51 Chousuke: ,(for [i (range 10) :when (even? i) :while (odd? i)] i)

7:51 clojurebot: ()

7:52 Chousuke: ,(for [i (range 10) :while (odd? i) :when (even? i)] i)

7:52 clojurebot: ()

7:52 guru: does anybody know sth like assert, which returns expr, if its not nil and throws an exception otherwise?

7:53 Chousuke: (or expr (throw ...))? :)

7:53 guru: (assert-ret '(1 2)) -> (1 2)

7:53 Mec: (and exp (throw)

7:53 bah

7:53 too slow

7:53 guru: yo

7:53 i prefer or

7:53 Mec: err ya or

7:53 Chousuke: it also fails if expr is false though

7:53 guru: the assert exception would be the same as (throw .Exception)?

7:54 Chousuke: assert throws AssertionError actually

7:54 guru: ,(println "test")

7:54 clojurebot: test

7:54 guru: (println "test")

7:54 metvop: mec, re: clojurebox:i had the same issue with not loading contrib. I put a freshly built clojure 1.1 jar and contrib jar in their respective directories in the Clojurebox dir and it seems to work fine now. *shrugs*.

7:55 guru: test (println "test")

7:55 Mec: my clojurebox has them in the /lib folder, is that where you put yours?

7:57 metvop: Mec, mine hasC:\Program Files\Clojure Box\clojure and

7:57 [07:56] <guru> ,(println "test")

7:57 [07:56] <clojurebot> test

7:57 guru: ok

7:57 metvop: oops

7:57 guru: ,(println "test")

7:57 clojurebot: test

7:57 guru: ah cool

7:58 Mec: metvop: do you know if you're using clojurebox v1.1.0 or a different one?

7:58 metvop: Mec, mine hasC:\Program Files\Clojure Box\clojure and C:\Program Files\Clojure Box\clojure-contrib I see no lib folder anywhere

7:59 Mec: actually thats not even the one i'm using, that was built yesterday

8:00 metvop: Mec, mine is from october. it had 1.0 clojure default..

8:11 Mec: I'll give this new version a try, and if that doesnt work i'll go to 1.0

8:16 how do i properly import something form contrib to see if it'll load

8:27 hoeck: Mec: (use 'clojure.contrib.seq-utils), or (require ...)

8:27 Mec: sucess!

8:30 That leaves one last problem with clojurebox. Any idea why M-. takes me to the middle of a jar file instead of source code?

8:59 hoeck: Mec: probably the source is not located on the classpath, only a jar with AOT compiled namespaces

9:21 Mec: is there a way to get the numerator/denominator of a ratio

9:26 hoeck: Mec: almost literally: (.numerator 1/3)

9:27 Mec:

9:27 ,(.denominator 1/4)

9:27 clojurebot: 4

9:27 Mec: hey thats useful

9:28 is that kind of thing documented anywhere?

9:50 hoeck: Mec: no, I only found them after looking at the clojure.lang.Ratio source

9:50 Mec: but the other numeric functions are documented properly on clojure.org/data_structures

9:51 guru: is there a macro to print the source of clojure.lang.Ratio?

9:51 source doesnt work

9:51 Chousuke: ~def c.l.Ratio

9:52 will that do? :P

9:52 guru: hm, actually no :-D

9:52 i was looking for sth for the repl

9:57 chouser: guru: java source code is generally not available via classpath from a JVM

9:57 guru: ok, ty

9:57 chouser: you can use (show clojure.lang.Repl) to see the public fields and methods of the class.

9:58 guru: ,(show clojure.lang.Repl)

9:58 clojurebot: java.lang.Exception: Unable to resolve symbol: show in this context

9:58 guru: works in my Repl though

9:58 chouser: and 'javadoc' to launch a browser looking at the javadocs for the class

9:58 guru: that helped, thx

9:58 chouser: I don't know why I said Repl. :-P Ratio of course...

9:59 guru: hehe :-)

10:07 chouser: I suppose there could be something that pulls up github pages for clojure's own sources, like javadoc does for sun's docs.

10:11 guru: ~def c.l.PersistentVector

10:21 Mec_: if I call count on a lazy-seq will it put the whole seq in memory?

10:21 Chousuke: ,(count (range 10000000))

10:22 clojurebot: 10000000

10:22 Chousuke: apparently not

10:22 chouser: Mec_: yes

10:22 Chousuke: it will realise the entire seq though.

10:22 so if you hold the head, you will have the whole thing in memory

10:22 chouser: hm.

10:22 Chousuke's right.

10:23 Mec_: excellent, thanks

10:25 devlinsf: chouser: Hello

10:25 Mec_: so count a filter, or reduce with a counter

10:25 chouser: so (if (< (count my-lazy-seq) 100) my-lazy-seq ...) will realize the entirety of my-lazy-seq.

10:40 devlinsf: hi

10:40 devlinsf: chouser: Got a sec for visitors?

10:40 chouser: sure

10:41 devlinsf: Okay, did you get my note about "same"?

10:44 chouser: ah, yes.

10:44 I think I had some reactions. Let me see if I can remember them. :-)

10:45 oh, my comment about 'empty' came from that email I think.

10:45 devlinsf: What's the date?

10:45 chouser: and it's all fixed now in core.clj now, so did you use it?

10:45 devlinsf: Yeah, in a big way

10:46 chouser: See the one 12/24?

10:49 chouser: yeah, that's what I've got up.

10:50 devlinsf: chouser: That's the one I want to push forward. Is this heading the right direction, or am I nuts?

10:51 chouser: Check out the test script

10:52 chouser: oh!

10:52 devlinsf: Yeah

10:52 chouser: I'm sorry, I'm not sure I'd read this one. hang on.

10:53 devlinsf: It's cool. Each of those tests pass, btw

10:57 chouser: sorry, I'm a bit distracted at the moment.

10:58 Ok, I'd read this but haven't looked at your implementation.

10:58 * chouser does that now.

11:00 * devlinsf pushed more use cases

11:09 chouser: the implementation you're proposing is the one in your core.clj?

11:09 devlinsf: Yeah

11:09 At least to start with

11:10 same, same-dispatch, hof-args and hof-target are the interesting fns

11:11 hof-args & hof-target handle the optional index stuff

11:12 chouser: I don't really like the arg-index stuff, but I don't yet have a better suggestion.

11:12 devlinsf: It's the only comprise I could think of

11:13 especially w/ the concat example I gave in the email

11:26 chouser: devlinsf: do you have use cases that are themselves polymorphic?

11:26 devlinsf: chouser: Like where I don't know the input?

11:27 chouser: right

11:27 well, the type of the input.

11:27 devlinsf: Yeah, if I add symbols & keywords

11:27 joining a list of maps, database style

11:28 the keys might be a keyword or string

11:28 and there could a collision between the two keyspaces

11:29 so you call something like (inner-join left-table right-table)

11:29 and if a collision is detected, you pre-pend left and right

11:29 i.e. :left.key :right.key

11:29 This way the info is preserves, classic SQL

11:30 (I need to update my table lib to do this)

11:30 chouser: hmm.

11:30 devlinsf: but it might be "left.key" "right.key"

11:30 As the lib designer, I don't know if it's strings or keywords

11:31 but if I want it to be useful, I have to support both

11:31 chouser: but in that case, isn't it likely the user would want to be able to provide their own "combining" function?

11:32 devlinsf: Yeah, probably. But providing a left-prefix & right prefix works for 99% of use cases

11:33 Mec: is there a way to do like a threaded partial?

11:38 chouser: Mec: perhaps with 'future'?

11:40 Mec: err not that kind of thread, i mean like #(somefunc % n) wherewas (partial somefunc n) would be #(somefunc n %)

11:40 chouser: Mec: ah. I suppose you could write such a thing. But normally I just use #() directly.

11:41 that's what it's there for.

11:41 Mec: true, its not particularly shorter

11:42 chouser: devlinsf: I think this requires more thought. Using a number to refer to an argument by index is awkward, and I wonder if this is an indication that 'same' is trying to do too much in one function.

11:43 devlinsf: chouser: Yeah, I know. It defaults to last, and that works for 90%

11:43 chouser: For example, both the concat examples you provide can be done more easily without using 'same' at all.

11:43 vy: How do you guys spot memory leaks (probably caused by lazy evaluation forced caching, etc.) in your Clojure programs? Which tools do you use?

11:44 devlinsf: true

11:44 It's for str that I'd want to use the indexing

11:45 Maybe #() will work better

11:46 Licenser: what about something like (partial function :value 42 :value :value "bla") where it works like #(function %1 42 %2 %3 "bla") - of cause :value isn't very well choosen

11:46 chouser: devlinsf: I do think you're on to something with a multimethod that defaults to something like (into (empty c) (f args c))

11:46 devlinsf: So bring it up on the dev list?

11:47 chouser: vy: jvisualvm makes it easy to spot what kinds of objects are consuming the most memory.

11:48 Licenser: that ties you pretty tightly to 'function's argument order.

11:48 devlinsf: you don't need my permission for that! :-)

11:48 devlinsf: I know, but I'm gonna need support

11:48 Anyway

11:48 Licenser: chouser: of cause, but isn't that a good thing too, I mean for later understanding of the code? 

11:49 chouser: devlinsf: when clojure starts using protocols for native abstractions, it's reasonable to think (into "" ...) will be able to do the right thing.

11:50 Licenser: at least I could read that better then something like (partial function {2 42, 5 "bla"})

11:50 chouser: at which point it may not even need to be a multimethod. Though I guess a multimethod still wouldn't hurt much.

11:51 devlinsf: chouser: There will always be corner cases

11:51 Okay, time to write something up

11:51 chouser: but with protocols, you could extend your own types to work with 'into' and 'empty'

11:51 devlinsf: Hmmm... true

11:52 chouser: but again, a multimethod still wouldn't hurt much. Especially when such use of protocols is still theoretical. :-)

11:52 devlinsf: The only two real use casas for the multimethod are String & Lazyseq

11:52 Licenser: hmm is there any good explenation of how rotocils will work and what they will do exactly?

11:53 devlinsf: Eh, and you know what? The multimethod works now. It can always be upgraded later

11:53 chouser: right

11:54 I'm a little nervous about the auto-sensing lazy-seq though too. It might be a great idea, but it's not done elsewhere in Clojure yet I think.

11:55 devlinsf: Is it needed elsewhere?

11:55 chouser: right now, any given function either returns a lazy seq or it doesn't.

11:55 gcv: quick question about writing custom error handlers: c.c.error-kit vs c.c.condition. I'm leaning towards c.c.error-kit because it doesn't require AOT compilation, but was wondering about prevailing opinion here.

11:56 devlinsf: chouser: If I get a lazy-seq, I can't recreate the original type

11:56 chouser: to choose between them implicitly might either be really nice or a source of confusion.

11:56 devlinsf: Eh, let's see what happens

11:58 chouser: gcv: only contrib needs to be AOT compiled, not your own code.

11:59 gcv: chouser: thanks, I didn't realize that

12:01 chouser: That's for c.c.condition of course.

12:03 gcv: I assume you use error-kit since you wrote it? :)

12:03 chouser: heh. you'd think.

12:05 error-kit tries to do too much. If you don't need the continue or continue-with features, I'd avoid error-kit

12:09 gcv: chouser: thanks for the advice

13:46 cmbntr: hi, is there a shortcut to (first (remove nil? s))

13:53 devlinsf: (some identity s)

13:57 Licenser: the full disclojure videos are briliant

13:57 very very nice!

13:58 cmbntr: devlinsf: thanks

14:00 devlinsf: Licenser: Thank for

14:00 err, you

14:00 * devlinsf can't type

14:00 Licenser: devlinsf: you're welcome

14:00 so may I add an idea/wish

14:00 devlinsf: Yeah, shoot

14:01 Licenser: So I love them but I took the time to work myself into clojure and claim to be at least a somewhat versed coder. What would be really cool too, would be something like full disclojure for compleat newcommers - hence I know only about 1 person who would even have heared something like s-expression before .

14:02 devlinsf: That's exactly where I want to go

14:02 Licenser: Ah very nice :D

14:02 devlinsf: The goal is an "intermediate developer"

14:03 You need to be able to do (+ 2 2), (map #(* 2 %) [1 2 3])

14:03 etc

14:03 (That material is better covered elsewhere)

14:03 Licenser: I don't mean it as critique of the existing videos, they are great, just that I would love ot have something that nice to show people who wish to start with clojure without reading an entire book on it :P

14:03 devlinsf: Stay tuned the next few weeks then

14:04 Licenser: I will ;)

14:04 Anniepoo: anybody had any luck getting enclojure's repl to work with the head RC?

14:04 Licenser: hmm also something like a emacs-clojure quick howto video would be cool :P

14:04 every source that I found about that expects you to be proficient with EMACS

14:06 devlinsf: Licenser: If I was qualified to write about emacs, I would

14:06 Did you check out LauJensen's stuff?

14:06 Licenser: That is the exact problem, people who are qualified make it too complicated :P

14:07 not that I'd know of, is it about EMACS and Clojure?

14:07 devlinsf: It's mostly Clojure, with some emacs

14:08 He also shows different stuff, worth checking out

14:08 Licenser: let's ask Mr. G about it ^^

14:09 hah okay I managed to subscribe to your cahnnel :P

14:11 ah very nice thank you devlinsf!

14:29 gnaw

14:30 things seem so easy when they work :P

14:31 guru: i want to create a state 'object' that can have itself as next state

14:31 like:

14:32 { :date "bla" next-states [ self ] }

14:33 is this were promises shine?

14:34 stuartsierra: sounds like a lazy sequence to me

14:35 guru: atom is rather funny, didnt try refs

14:36 ,(let [a (atom 0)] (swap! a (fn [_] a)))

14:36 clojurebot: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Atom@ac86bb: #<Ato

14:37 guru: i dunno how a lazy seq comes into play here

14:37 ill think about it

14:38 chouser: guru: each item of a lazy seq can be thought of as a "state", where the sequence as a whole represents the succession of states.

14:38 ,(iterate inc 1) ; here the state starts as 1, next state computed by applying 'inc' to the old state.

14:38 clojurebot: Eval-in-box threw an exception:java.lang.OutOfMemoryError: Java heap space

14:39 chouser: ,(take 10 (iterate inc 1))

14:39 clojurebot: (1 2 3 4 5 6 7 8 9 10)

14:39 guru: yes

14:39 my problem might still be different

14:39 let me think a sec

14:41 chouser: the benefit of a lazy-seq over atoms or refs transitioning through a series of values is a lazy seq like this can stay purely functional, while updating reference objects is mutating shared state.

14:41 guru: yep

14:43 ok, a tiny example: i have a map of states, a state is a list of possible follow-up states:

14:43 {:loop-state [:loop-state :some-other-state] :some-other-state []}

14:44 i want to transfrom that map into sth like:

14:46 ok, bad example, again: {:loop-state [:loop-state :some-other-state] :some-other-state [:1 :2]}

14:47 should become {:loop-state [[[...]] [next-states of :1, next-states of :2]}

14:48 ok, basically i want to create a seq which contains itself

14:48 chouser: hm. why? the first way seems good -- what the reason for the transform?

14:49 guru: i would have to do a map lookup, each time a make a transition

14:49 plus i have to pass that map to my functions

14:50 chouser: hm.

14:50 guru: where reason 2 is worse for me

14:50 promise seems to do the job really well here

14:51 chouser: promise is usually for flow-control -- deref blocks.

14:52 I guess it could work, as could atom.

14:53 rrc7cz: why does "(map #(array-map % (char %)) (range 1 10))" work, but "(map #({% (char %)}) (range 1 10))" fails with IllegalArgumentException: Wrong number of args passed to: PersistentArrayMap?

14:54 chouser: you want current-state and the list of next-states to be a single object?

14:55 rrc7cz: #(foo) is (fn [] (foo)) ... #() eliminates the need for one set of parens, but therefore always expands to a form that starts with "(" (not "{" or "[")

14:55 Licenser: nice

14:57 rrc7cz: chouser: okay that makes sense

15:00 guru: whats the reasoning behind assert not returning a value in case it evals to logical true?

15:00 chouser: asserts can disappear if compiled with *assert* false

15:01 guru: yes, but the code inside doesnt have to

15:01 (defmacro assert-ret

15:01 "Evaluates expr and returns it if it evaluates to logical true,

15:01 throws an exception otherwise."

15:01 [x]

15:01 (if *assert*

15:01 `(if ~x

15:01 ~x

15:01 (throw (new Exception (str "Assert failed: " (pr-str '~x)))))

15:01 x))

15:01 is the version i use

15:06 maybe sth like that already exists, being able to provide an optional message would be even nicer and still shorter than if...throw (.Exception...

15:08 chouser: I think people generally want the code inside the assert to disappear as well. It's often doing work just for the assert.

15:09 though the need for manual use of assert has gone way down with :pre and :post

15:10 guru: ok, i guess its the whole point of assert, to make some maybe expensive calculations, and in case *assert* is false, this code should just disappear

15:10 chouser: I think that's the common usage, yes.

15:11 I can see that there might be times that you'd like to sprinkle asserts inside nested, working code, but I guess that's been somewhat less common.

15:11 guru: ok, thx

15:35 lazy1: is *command-line-args* still the best way to check if we're imported or being run as main script?

15:38 chouser: hm -- you can't tell whether you're being run as a script or being 'require'd by something that's being rung as a script

15:39 lazy1: OK, thanks

16:25 tolstoy: I keep getting: java.lang.IllegalArgumentException: No matching method found: println for class swank.util.io.proxy$java.io.StringWriter$0

16:25 The clojars version of swank hasn't been updated in a while.

16:25 Is there something I can do with that stuff?

16:26 the-kenny: tolstoy: When you require something?

16:26 s/something/something from your project)

16:27 tolstoy: the-kenny: Mainly when I get errors using derby. Or some sort of errors.

16:28 the-kenny: tolstoy: I have a very strange error involving this class too

16:28 (swank.util.io.proxy$java.io.StringWriter$0)

16:28 Looks like something there is really broken

16:29 rrc7cz: can anyone imagine why (take 5 (p29))

16:29 (4.0 4.0 8.0 9.0 16.0)

16:29 the-kenny: rrc7cz: What's "p29"?

16:30 rrc7cz: oops, sorry - output got scred up. why (take 5 (p29)) -> (4.0 4.0 8.0 9.0 16.0) but (take 5 (set (p29))) -> (8.589934592E9 3.6893488147419103E19 1.5845632502852868E29 6.805647338418769E38 5.391989333430128E67)

16:31 p29 is the start of some Euler solution: (defn p29 [] (flatten (let [vals (range 2 101)] (for [a vals b vals] [(Math/pow a b) (Math/pow b a)]))))

16:31 hiredman: sets are not sorted, so the order going into a set is not the same as coming out

16:31 rrc7cz: I can switch to sorted-set, but it's not the order I care about; the values are changed

16:32 hiredman: how do you know?

16:32 rrc7cz: hiredman: (4.0 4.0 8.0 9.0 16.0) vs. (8.589934592E9 3.6893488147419103E19 1.5845632502852868E29 6.805647338418769E38 5.391989333430128E67)

16:33 oh

16:33 wait

16:33 I'm stupid

16:33 well

16:33 hiredman: i get it now what you mean about sorted

16:33 hiredman: since I'm taking only 5, it could be a different 5 each time

16:34 but all values _should_ be whole numbers since I'm only doing powers of ints

16:34 Chousuke: pow returns floats though, doesn't it?

16:34 they are imprecise.

16:34 rrc7cz: Chousuke: it does, but I'd expect all X.0, Y.0. Z.0, etc

16:34 aha, you're right

16:35 I should use BigInt instead

16:35 defn: http://www.devinwalters.com/admin/posts/24 -- Can anyone think of anything to add to this? I'm sure there's a lot more to talk about, just curious if anyone has any opinions...

16:35 the-kenny: defn: Username/Password? ;)

16:36 defn: oh wrong URL :)

16:36 http://www.devinwalters.com/posts/24

16:40 http://www.paulgraham.com/rootsoflisp.html

16:42 tolstoy: the-kenny: That "No matching method found: println for class swank.util.io.proxy$java.io.StringWriter$0" error is, I think, a clojure-mode/slime prob, not in swank. Don't get it when running from a straight-ahead repl.

16:42 the-kenny: tolstoy: No, I don't get the same error, but a similar. Some casting-error

16:43 defn: oh no the-kenny not this problem again

16:43 this is still persisting?

16:43 the-kenny: defn: Not again

16:43 defn: so you fixed it?

16:43 the-kenny: No

16:43 Ist persists, it never disappeared

16:43 ;)

16:44 defn: ugh!

16:44 the-kenny: I'm requiring my code in the *inferior lisp* buffer now.. ugly workaround

16:44 defn: you're on OSX you said?

16:44 the-kenny: Yes

16:44 defn: 10.6?

16:44 not that it matters really, just curious

16:44 the-kenny: Yes, 10.6

16:45 It must be something wrong with one of the dependencies here.. I wonder why no one here has the same problem

16:46 I wonder if it's the same if I use a self-built swank-clojure...

16:46 defn: dude i have tried to replicate it

16:47 i blew away my elpa and tried again, but it works perfectly

16:47 technomancy: wdouglas: do you have a copy of slime-fuzzy.el that's been modified to work as an elpa package?

16:48 defn: technomancy: did that go up on elpa?

16:49 technomancy: defn: not yet

16:49 defn: will adding the slime-fuzzy.el to my elpa/slime/ dir make it so i can't update the slime package

16:49 ordnungswidrig: hny!

16:50 technomancy: defn: it shouldn't, but slime-fuzzy.el still needs a few tweaks before it's really made into a proper package

16:50 the-kenny: technomancy: Any idea why this happens? http://gist.github.com/267270 A stacktrace goes down onto call-on-flush-stream.

16:51 technomancy: the-kenny: no, never seen that; sorry

16:51 the-kenny: :(

16:52 I'm the only person where this is happening as far as I know.. I already tried a complete fresh slime, elpa and swank setup

16:52 technomancy: what JVM?

16:52 tolstoy: the-kenny: I think I've seen something similar along the way.

16:54 the-kenny: technomancy: java version "1.6.0_17" 32 or 64bit, doesn't matter

16:54 tolstoy: Really?

16:54 tolstoy: I think I also get my version of that issue when derby prints straight to stderr or stdout or something.

16:55 Ah, I don't know. Best thing would be to create a tiny test case that causes it.

16:56 the-kenny: tolstoy: It's wasy: Create a project with leiningen, pull the deps from elpa, start a repl with swank-clojure-project and (require yourns.yourpackage)

16:56 This happens in every project I have here

16:57 Here is one with a stacktrace: http://gist.github.com/267278

17:01 technomancy: the-kenny: sun's JVM, openjdk, or some other one?

17:02 the-kenny: technomancy: Should be sun. The default one on osx

17:02 I never had any problems.. this just started some days ago

17:02 congreve: /?

17:02 technomancy: doesn't Apple ship their own modifications?

17:03 the-kenny: technomancy: Yes, but it worked without any problem for a long time.

17:03 I don't remember any java-update or something similiar which could have broken it

17:04 technomancy: dunno; sorry. I can't do much without a repro-case.

17:04 defn: the-kenny: maybe try getting java from macports

17:04 the-kenny: hm.. ok, thanks anyway

17:05 tolstoy: the-kenny: I just run swank stand-alone (with all my jars on the cp), then use slime-connect to reach it. A lot fewer problems that way.

17:05 defn: sudo port install openjdk6

17:07 the-kenny: I'm almost sure I've tried that

17:08 tolstoy: yes.. that works

17:09 That all doesn't make sense for me

17:10 technomancy: the average function length in swank_fuzzy.clj makes my stomach churn

17:10 what a mess

17:12 at least there are a few tests

17:15 course a test that just tells me "hey, there is a null pointer exception somewhere in this 100+LOC function" is not a lot of help

17:16 * hiredman responds to a proposal with code with a counter proposal with no code

17:18 hiredman: clojurebot: problem?

17:18 clojurebot: People have a problem and think "Hey! I'll use a regular expression!". Now they have two problems....

17:19 hiredman: clojurebot: problem?

17:19 clojurebot: People have a problem and think "Hey! I'll use a regular expression!". Now they have two problems....

17:19 hiredman: bah

17:21 arohner: hrm, jswat is not highlighting lines for

17:21 for me

17:22 has anyone else had that problem with jswat 4.5? it doesn't highlight the lines with breakpoints, nor show the current line

17:22 the-kenny: technomancy: Should I use [org.clojure/swank-clojure "1.0"] or [swank-clojure "1.1.0-SNAPSHOT"]?

17:27 arohner: ah, jswat behaves normally when viewing .java files, but not .clj

17:28 is there some configuration I have to do?

17:32 the-kenny: I just don't get this...

17:32 It also breaks if I evaluate a (ns)-declaration

17:33 where I import something from my project

17:33 It works if I just import things from other projects

17:40 Can someone please zip me a simple project with some files where he uses swank-clojure-project with leiningen successfully?

17:42 (with all dependencies please)

17:46 Weeee

17:46 Looks like it's a configuration issue

17:48 That can't be..

17:49 defn: Interested in the source of the problem?

17:51 technomancy: I found the problem - Really strange.. should I write some instructions to reproduce it?

17:52 It's really simple.. but I don't get why it throws such a strange exception

18:06 How to break swank-clojure: http://gist.github.com/267299 :)

18:06 I had these three lines in an init-file to customize my repl.. these three lines were the source of all problems

18:13 ordnungswidrig: the-kenny: interesting.

18:13 however, I'll take a nap now.

19:53 lazy1: Is there a way for me to check if an object supports an interface?

19:53 (Java object)

19:54 cark: ,(doc isa?)

19:54 clojurebot: "([child parent] [h child parent]); 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"

19:54 kotarak: ,(doc instanceß)

19:54 clojurebot: excusez-moi

19:54 kotarak: ,(doc instance?)

19:54 clojurebot: "([c x]); Evaluates x and tests if it is an instance of the class c. Returns true or false"

19:54 kotarak: ,(instance? CharSequence "foo")

19:54 clojurebot: true

19:54 kotarak: Is that an interface?

19:55 lazy1: thanks

19:56 kotarak: ,(isa? (type "foo") CharSequence)

19:56 clojurebot: true

20:53 chouser: anyone here know enlive?

21:07 replaca: chouser: yeah, some

21:08 chouser: I'm trying to add an attribute to all tags of a given name

21:08 the value of the attribute will depend on the content of the tag element.

21:09 replaca: by name do you mean the tag name (like <a>) or an id or class?

21:12 chouser: right, tag name

21:12 it looks like I want sniptest, but it appears to be gone?

21:12 so I'm starting with 'at' for now, though that looks like it'll return maps of some kind that need to be converted back to strings

21:13 (at (first (xml-resource ..a..)) [:para] ..b..)

21:13 I think I've got ..a.. right, but I'm still trying to figure out what to put for ..b.

21:17 replaca: you should be able to do something like (fn [n] (apply (set-attr :attr-name (transform (:content n))) n))

21:18 I'm not sure I got the indirection right just there - the idea is that you're trying to get a function that will act on each of the selected nodes)

21:19 "transform" would be your func that looks at the content and derives the value for the attribute

21:19 chouser: ok thanks

21:20 replaca: set-attr itself returns a func which is what makes some of these things tricky

21:23 chouser: any idea how to get from what 'at' returns back to a string?

21:23 or something better to use instead of 'at'?

21:23 replaca: well, if you know the file at compile time, you can use deftemplate

21:24 that's alot faster if you're doing it a bunch

21:24 chouser: There's no file. The xml is built at runtime into a string.

21:24 replaca: then at is probably what you want

21:25 hang on, I think I found a ref for you.

21:25 (while I'm chasing that out...)

21:27 use (apply str (at ...)) to get a whole regular string

21:28 at least that works on deftemplate and I think it works on at too

21:28 chouser: no, at returns a seq of hashes

21:28 hash-maps, that is.

21:28 oh, they're string clojure.xml things

21:28 I should be able to use emit

21:29 replaca: yup, that should be right

21:29 chouser: emit is not public

21:30 replaca: use emit*

21:31 it's public and it's what's used in the def of deftemplate

21:31 chouser: ok, looks good.

21:33 replaca: for the (apply (at ...)) thing look at http://github.com/tomfaulhaber/autodoc/blob/master/src/autodoc/build_html.clj#L74

21:34 chouser: ohhhh... I see.

21:34 replaca: I'm adding a prefix (like ../../) to hrefs there to make up for putting pages in subdirectories

21:36 (That's actually my own version of deftemplate that memoizes instead of working at compile time)

21:36 but the syntax is otherwise the same

21:37 chouser: ok! I've got it sketched out now.

21:37 replaca: cool. glad to hear it

21:37 chouser: Thanks, I'm sure you just saved me at least a couple of frustrating hours. :-)

21:38 replaca: gotta run now, but I should be back later if you have more q's

21:38 chouser: great, thanks.

21:38 replaca: (well I already spent those frustrating hours so you don't have to :-))

21:38 chouser: :-)

23:33 any way to "or" a bunch of tags in an enlive selector?

23:33 I have [:para] and I want something like [(or :para :sect1 :sect2)]

23:42 replaca: chouser: the readme shows using a set as working -> #{selector1, selector2}

23:42 where each selector is itself a vector, as usual

23:44 I don't use that technique myself anywhere, though

23:47 chouser: ah, thanks.

Logging service provided by n01se.net