#clojure log - Sep 28 2009

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

0:17 tomoj: I'm having trouble making an executable jar

0:18 I've got a foo.main namespace with a main function, but no foo/main.class gets compiled, just stuff like foo/main__init.class, foo/main$main_8.class

0:19 hiredman: do you have a (:gen-class) in side the namespace declaration?

0:20 tomoj: no, I'll look into that

0:20 clojure/main.clj doesn't have one of those.. confusing

0:21 hiredman: main.clj is not what is called by java -cp clojure.jar clojure.main

0:21 tomoj: oh

0:21 hiredman: check src/jvm/clojure/main.java

0:21 tomoj: well now a main.class is getting created, but it doesn't work

0:22 hiredman: ~compile

0:22 clojurebot: the unit of compilation in clojure is the namespace. namespaces are compiled (not files). to compile a namspace the namespace needs to be on the classpath and so does ./classes/ (and the directory needs to exist) because clojure writes the class files to that directory. http://clojure.org/compilation

0:22 tomoj: something wrong with my build.xml probably

0:23 keep getting "could not find the main class: jboselpli.main" even though the jar contains jboselpli/main.class

0:45 woot it works

0:45 I needed a zipgroupfileset to pull in the classes from clojure.jar and clojure-contrib.jar

0:46 now I have a 4.6mb jar that just prints "foo" :D

1:33 sfuentes: is there such a thing as raw strings in clojure?

1:34 Makoryu: "Raw?"

1:40 sfuentes: so i can have a string like "\/"

1:41 hiredman: ,"\\/"

1:41 clojurebot: "\\/"

1:41 hiredman: ,(print "\\/")

1:41 clojurebot: \/

1:43 sfuentes: is there a way to do that without prefixing \?

1:43 Makoryu: sfuentes: Nope.

1:44 sfuentes: ok. thank you.

1:44 hiredman: it's called "escaping"

1:47 konr: ,(:foo {:foo [0 1] :bar [1 0]}

1:47 clojurebot: EOF while reading

1:47 konr: ,(:foo {:foo [0 1] :bar [1 0]})

1:47 clojurebot: [0 1]

1:48 konr: Hmmm, shouldn't this always work?

1:48 hiredman: this? work?

1:48 konr: hiredman: the (:foo {:foo [0 1] :bar [1 0]})

1:48 hiredman: what about it?

1:49 konr: shouldn't it always return [0 1], or there is some catch?

1:49 hiredman: in that exact case, I can say yes

1:49 but I doubt you are using exactly that code

1:50 most likely you are doing something like (x {:foo 1 :bar 2}) where x is a variable and you are passing in something other than a keyword

1:52 konr: hmmm

2:09 oh, of course

2:56 licoresse: ,(doc ->>)

2:56 clojurebot: excusez-moi

3:18 sfuentes: i'm trying to use slurp but i'm having trouble using the correct file path when using a jar deployment. anyone know what the correct path may be?

3:22 cgrand: sfuentes: I don't think slurp is the right tool for this job

3:23 sfuentes: why is that?

3:23 cgrand: slurp* in c.c.duck-streams should be better

3:24 sfuentes: that's what i'm using

3:25 cgrand: then what does your current attempt look like?

3:26 sfuentes: it works fine when i use an absolute path without using a jar file ... but when i try to package it inside a jar, it seems to loose track of the file location

3:27 I get: Exception in thread "main" java.io.FileNotFoundException

3:27 cgrand: are you loading the file through a FileSomething or through a classloader?

3:27 or directly as a path ?

3:27 sfuentes: directly

3:27 Fossi: hi

3:30 cgrand: sfuentes: what does (-> (RT/baseLoader) (getResourceAsStream "your/path/relative/to/the/jar/root")) returns?

4:08 AWizzArd: ~max people

4:08 clojurebot: max people is 178

4:08 Fossi: still

4:10 AWizzArd: we will get 200+ this year

4:10 Fossi: happy with the election results? :)

4:13 Hi LauJensen1.

4:38 pixelman: I'm writing a macro which uses a function not in the current namespace (but which is imported in), when the macro expands it tries to find the function in the current namespace and fails. how can make the macro not add the current namespace?

4:43 Chousuke: hm

4:43 ,flatten ;test

4:43 clojurebot: #<seq_utils$flatten__3 clojure.contrib.seq_utils$flatten__3@1c6fed0>

4:43 Chousuke: ,`flatten

4:43 clojurebot: clojure.contrib.seq-utils/flatten

4:43 Chousuke: pixelman: it should work like that.

4:44 ,`foo

4:44 clojurebot: sandbox/foo

4:44 Chousuke: pixelman: so what is your problem exactly?

4:45 pixelman: Chousuke: I am trying to write a macro that lies on top of the GET macro in compojure

4:45 Chousuke: ~macro help

4:45 clojurebot: macro help is http://clojure-log.n01se.net/macro.html

4:45 pixelman: I want to do something with request first (log some stuff) and then execute the action.

4:46 ah, great, I'll try the macro helper!

4:47 Chousuke: if the function is only imported by require, then you might need to manually type out the whole qualified name

4:55 pixelman: Hm. I think I got it wrong, the problem isn't that it's a a function, it's a variable that's in the scope of the underlying macro because of a macro called with-request-bindings

4:55 so I cannot say "request" there because it doesn't exist yet

4:56 I tried the paste bot but got proxy error

4:57 here's a simple oneliner of the macro I am trying to do: (defmacro FOO_GET [path action] `(GET ~path (~@action params request)))

4:57 params and request only exist when GET is expanded?

5:00 Chousuke: ah, so they are variables that GET introduces?

5:01 pixelman: yep

5:01 Chousuke: then you need to override the namespace expansion with ~'params and ~'request

5:01 konr: Is anybody using swing here? I've created a very simple 10-line hello-world program, yet one component (the label) doesn't show up. Any idea why that could be so? http://pastebin.com/m7a50dcc4

5:03 LauJensen2: konr: It shows here

5:04 konr: LauJensen2: hmmm... interesting... Are you using OpenJDK? Should I avoid it?

5:05 pixelman: Chousuke: thank you! worked perfectly!

5:05 arbscht: konr: works for me, openjdk 6

5:06 LauJensen2: konr: Take the same precautions towards OpenJDK as you would the plaguage

5:06 plague

5:07 I had an image processing problem once, that was killing me, I just couldn't work out where the image was getting a bad color profile, nuked openJDK, problem solved :)

5:21 eevar2: ^^ openjdk is great

5:21 just avoid gcj

5:22 and you'll be fine

5:22 (which has nothing to do with openjdk)

5:24 konr: haha, it's also not showing up using SunJDK

5:24 I'm going to blame Xmonad

5:26 arbscht: konr: what do you see?

5:29 konr: arbscht: just an empty canvas

5:30 j3ff: hey

5:31 anyone here

5:31 arbscht: konr: so there is a visible frame of the correct size, but no label?

5:32 konr: arbscht: yes

5:33 haha: The Java gui toolkit has a hardcoded list of so-called "non-reparenting" window managers. xmonad is not on this list (nor are many of the newer window managers). Attempts to run Java applications may result in `grey blobs' where windows should be, as the Java gui code gets confused.

5:34 j3ff: hey so i have this vector full of sorted strings, but i want to make the vector hold vectors of each group of identical strings, anyone know how i'd go about doing that?

5:38 kind of like: ["alpha" "alpha" "alpha" "beta" "beta"] and i want [["alpha" "alpha" "alpha"]["beta" "beta"]]

5:39 anyone? :(

5:39 LauJensen: repeat?

5:41 jdz: j3ff: write a function that does what you want?

5:42 j3ff: yeah im trying to write the function but havent come up with much

5:45 arbscht: ,(doc group-by)

5:45 clojurebot: "([f coll]); Returns a sorted map of the elements of coll keyed by the result of f on each element. The value at each key will be a vector of the corresponding elements, in the order they appeared in coll."

5:45 arbscht: ,(doc partition-by)

5:45 clojurebot: "([f coll]); Applies f to each value in coll, splitting it each time f returns a new value. Returns a lazy seq of lazy seqs."

5:45 arbscht: ,(group-by identity ["alpha" "alpha" "alpha" "beta" "beta"])

5:45 clojurebot: {"alpha" ["alpha" "alpha" "alpha"], "beta" ["beta" "beta"]}

5:46 arbscht: ,(partition-by identity ["alpha" "alpha" "alpha" "beta" "beta"])

5:46 clojurebot: (("alpha" "alpha" "alpha") ("beta" "beta"))

5:46 arbscht: they're in clojure.contrib.seq-utils

5:46 j3ff: wow thanks!

5:46 those weren't in the clojure book lol

5:50 arbscht you rock!!

6:21 LauJensen: Its true arbscht, you do :)

6:35 pixelman: ,(reduce #(str %1 %2) (re-seq #"[0-9]+" "320423-234-234-2341234"))

6:35 clojurebot: "3204232342342341234"

6:36 pixelman: can I evaluate that lazy sequence without using the big gun reduce?

6:37 arbscht: ,(apply str (re-seq #"[0-9]+" "320423-234-234-2341234"))

6:37 clojurebot: "3204232342342341234"

6:38 pixelman: thanks!

6:53 LauJensen: Lets say I have s = [23 24 25 26 26 27 28] and I want to pull out the first 26, because it's value is repeated. Do we have an idiomatic thing for that?

6:58 arbscht: hm

6:58 what do you want returned?

6:59 LauJensen: 26

7:03 arbscht: ,(filter (complement nil?) (map second (partition-by identity [23 24 25 26 26 27 28])))

7:03 clojurebot: (26)

7:03 arbscht: ,(find-first (complement nil?) (map second (partition-by identity [23 24 25 26 26 27 28])))

7:03 clojurebot: 26

7:05 LauJensen: ah nice

7:05 thanks

7:22 ,(reduce #(cond (integer? %1) %1 (= 1 (%1 %2)) %2 :else (assoc %1 %2 1)) {} [23 24 25 25 26 27])

7:22 clojurebot: 25

7:23 LauJensen: That would be very nice, except that can never be lazy ?

7:23 arbscht: ?

7:46 arbscht: LauJensen: that is also verging on unreadability ;)

7:49 ,(ffirst (drop-while (comp nil? second) (partition-by identity [23 24 25 26 26 27 28])))

7:49 clojurebot: 26

7:49 Fossi: Chouser, anybody: got a more elaborate error-kit example? the link in the twitter message (http://tinyurl.com/nhvd5l) seems to be broken

7:50 also: would you recommend using them over java exceptions?

7:52 ah, the link is not broken, just didn't find the pdf

8:11 pixelman: is there something like map but that just return nil?

8:13 hoeck1: pixelman: (dorun (map ...)) or doseq

8:14 pixelman: hoeck1: thanx!

9:15 andysp_: morning Greg

9:16 LauJensen: arbscht: The thing is, I don't like partition-by :)

9:19 arbscht: LauJensen: why?

9:19 Chouser: there is some room for improvement: http://is.gd/3HpUs

9:20 LauJensen: Its not in my core arbscht

9:21 arbscht: Chouser: ugh, those plots are inscrutable to the (partially) colourblind. how does clojure fare?

9:21 Chouser: arbscht: no visible line

9:21 arbscht: ah

9:22 Chouser: top line is php, then python, then ruby. Near zero are groovy then scala.

9:23 * ambient is happy that he knows Python

9:24 * rsynnott suspects 'groovy' may be misleading; people will put the word in job ads not meaning the language

9:24 ambient: three things trouble me in py though: performance, packaging and binary incompatibilities

9:24 rsynnott: also python, but to a much lesser extent :)

9:26 jdz: Chouser: add Java to the list :)

9:27 LauJensen: ambient: I wrote a Python vs Clojure post actually, but concluded that Python viewed in the light of Clojure was just plain cruel, so I let it go :)

9:27 ambient: python is easier than clojure, but that's about it

9:27 but in the long run clojure seems easier

9:28 python has better development environmant

9:28 LauJensen: not true

9:28 ambient: wider choice and easier installation to windows

9:28 LauJensen: also not true

9:28 ambient: hmm, well apparently you know something i dont

9:29 LauJensen: true

9:29 ;)

9:30 ambient: pypy guys seem to have done a jit that accelerates python by a factor of 5

9:31 arbscht: this is somewhat interesting http://ur1.ca/cjoy

9:31 ambient: python is also self contained, clojure depends on java and jvm

9:31 arbscht: (pardon the randomly-generated pun in the url)

9:33 LauJensen: ambient: I think you're looking for #python :)

9:34 ambient: LauJensen nah, we were discussing about the merits of Python vs. Clojure so it's on topic afaict

9:40 raek: so, vars can have thread local bindings, right?

9:40 can agents have their own local bindings too?

9:41 rsynnott: ambient: _one implementation_ of python is self-contained :)

9:41 Chouser: raek: vars: yes. agents: no.

9:43 raek: is there any simple way to isolate access to mutable java objects, so that only an agent can use them?

9:44 I was thinking about swing objects, which i've heard are not thread safe

9:45 Chouser: raek: swing wants nearly everything to be done in its own thread. It provides methods to send tasks to that thread.

9:49 raek: Chouser: thanks, I'll look into that way of doing it

9:51 LauJensen: Do we have a trick to round a double to 10 decimals ?

9:54 duck1123: LauJensen: Would format work for you?

9:54 LauJensen: duck1123: Yes, if you explain how I define the precious :)

9:54 hehe, golllum again... the precision!

9:59 rhickey: Clojure is the featured project this week on Assembla: http://www.assembla.com/community

10:00 LauJensen: nice rhickey, this place is going to start growing

10:00 stuarthalloway: awesome

10:01 is it ok if I apply Howard's patch to contrib? (Not sure about the process, but I know it is blocking him)

10:01 https://www.assembla.com/spaces/clojure-contrib/tickets/22-clojure-contrib-str-utils2-is-not-AOT-compiled

10:02 rhickey: stuarthalloway: oh please yes, especially if you understand what it does :) I had some round trips with him just to get it in order but really can't evaluate it

10:02 stuarthalloway: I don't understand yet, but he reached out to me so I will run it down tonight

10:02 rhickey: stuarthalloway: thanks

10:07 LauJensen: JVM Summit talks up yet ?

10:07 * eevar2 just can't wait for a 100-man indian php+mysql shop to pick up clojure and join this channel

10:08 eevar2: ^^ no offense to indians, just ot php and/or mysql users ;)

10:09 * arbscht is all of the above

10:09 eevar2: hehe. poor fellow :)

10:10 LauJensen: come now friends - isn't there an easy way to round a double to 10 digits?

10:10 somebody got one of those old obscure unreadable tricks from the good ol' C days? :)

10:11 duck1123: LauJensen: I found http://java.sun.com/j2se/1.4.2/docs/api/java/text/DecimalFormat.html but I'm not sure if it'll do what you want

10:11 stuarthalloway: are you opposed to using BigDecimal's round?

10:11 tmountain: LauJensen: in C, wouldn't you just sprintf?

10:11 LauJensen: stuarthalloway: no

10:11 stuarthalloway: you'll have to create a MathContext (Java cruft)

10:12 tmountain: LauJensen: can you use java.text.DecimalFormat ?

10:12 LauJensen: I'm looking at the options now

10:12 Thanks guys - I might complain again in 5 minutes :)

10:12 tmountain: it uses half-even rounding

10:13 stuarthalloway: use the string constructor for MathContext -- more literate

10:13 Chouser: ,(with-precision 10 (* 1 (BigDecimal. (double 30/7))))

10:13 clojurebot: 4.285714286M

10:15 duck1123: why do you have to multiply it by 1?

10:16 Chouser: I think the precision setting only applies to an operation on a BigDecimal

10:18 LauJensen: Chouser, this might be my danish-english tripping me up again, but does this look as one would expect

10:19 (let [herons (map heron (range 10000 100000))]

10:19 (with-precision 10 (BigDecimal. (double (/ (apply + herons) (count herons))))))

10:19 3.13846666666666695988396895700134336948394775390625M

10:19 because I was hoping for this: 3.2102888889

10:19 clojurebot: for is not a loop

10:19 LauJensen: clojurebot: forget for

10:19 clojurebot: I forgot for

10:21 duck1123: LauJensen: you're not doing anything with the decimal

10:22 Chouser: ,(let [herons (map #(/ % 7) (range 10))] (with-precision 10 (/ (BigDecimal. (double (apply + herons))) (count herons))))

10:22 clojurebot: 0.6428571429M

10:22 LauJensen: ah ok, I got it

10:22 thanks

10:39 Thanks Chouser

11:18 Chouser: poking around the #clojure logs, found this...

11:18 rhickey takes Chouser to school: http://tinyurl.com/y8v9ean

11:26 ambient: that definition of zip is interesting :)

11:47 cemerick: Chouser: a great blog would be a series of those logs. You could call it "Rich Hickey p0wned me in #clojure" or something.

11:47 Chouser: heh

11:48 it hasn't happened *that* often...

11:48 * Chouser applies selective memory.

11:48 cemerick: Chouser: right, no, it would feature various people being p0wned :-D

11:48 I'd be a featured guest at least weekly.

11:49 * cemerick can't type "p0wned" anymore without thinking of south park

12:20 drewr: I love albino's entry at the end of that

12:24 arohner: is there a preferred way to implement java classes. i.e. if proxy works for me, should I use it?

12:24 Chousuke: yes? :)

12:25 as far as I can tell, you should only use gen-class when you *need* to

12:26 arohner: Chousuke: that's kind of what I was assuming, thanks

12:27 Chouser: proxy is so much more pleasant.

12:40 cgrand: Did you see my comment on ticket #173?

12:43 cgrand: Chouser: yes, but I thought you were asking Rich for approval

12:45 Chouser: ah. Well, he already approved it, so he must not care too much.

12:45 If you don't think its worth changing, I can just commit it as-is.

12:46 cgrand: I can resubmit a patch but which names would you pick for the args?

12:46 rhickey: Chouser: I am not with you on complete avoidance of core names as locals in fns

12:47 Chouser: really?

12:47 rhickey: really

12:47 especially short ones

12:48 Chouser: short names or short fns?

12:48 rhickey: short fns

12:48 :)

12:49 Chouser: you've never had to rename a local because you realized you now needed to call 'map' on your 'map'?

12:49 or perhaps that's just an acceptible cost.

12:50 rhickey: Chouser: I have, but most often for 'name', but that's still not a reason for making up awkward replacements. I think as long as the resulting code is clear it is fine

12:51 Chouser: ok. *shrug* It's your core.clj. :-)

12:52 rhickey: CL programmers frequently trot out a straw man function using list (local) and list (function)as why Lisp-2 is superior vs the confusion in an equivalent Scheme function, which has to use lst

12:52 opqdonut: indeed

12:52 Makoryu: Pssssh, just call it xs

12:53 Chouser: huh. I would think having the name list mean two different things in the same block would actually be an argument *against* lisp-2

12:53 rhickey: but in practice it is not as much of a problem. Certainly 'map' can be dangerous, OTOH, if the arg is just passed along why not call it map?

12:53 cemerick: I've actually only had a naming collision once in 1.5 years *shrug*

12:53 rhickey: Chouser: the argument is based upon wanting to use the name that makes the most sense, and being precluded from doing that by Lisp-1 and having to make up bad-looking replacements

12:54 Makoryu: rhickey: The real Lisp-1 vs. Lisp-2 argument concerns macros... But you've got that covered

12:54 Chouser: cemerick: is that unrelated to me yelling at you all the time to stop using core names? ;-)

12:55 cemerick: Chouser: oh, see, I thought we had moved on from that :-D

12:55 rhickey: Makoryu: yes, there are real arguments, I'm talking about a less valid one, but if we rename every local every time there's a new core fn then we are making that argument true

12:55 Chousuke: I'm still not sure how having two namespaces affects writing macros. :/

12:56 rhickey: cemerick: right, I think it is a non-problem in general, given short functions

12:57 Chousuke: hmm... I suppose it might be a problem if a macro introduces a name that shadows a function.

12:57 Makoryu: Chousuke: Exactly

12:57 Chousuke: Or more specifically, if a macro is expanded in a scope where a function used by the macro is shadowed

12:57 rhickey: and something a little syntax highlighting could help you detect before running your program, i.e. if locals has a particular color, seeing that as a call could tip you off

12:57 or vice-versa

12:58 e.g. map calls are usually purple but this on isn't

12:58 this one

12:58 Makoryu: rhickey: Yeah, before the advent of free syntax highlighting, programmers had to rely on other visual cues

12:58 For Lisp, that was the head position in a form

12:59 rhickey: Makoryu: and #' when using a function as a value

12:59 which I would all find quite icky in Clojure

13:00 Chouser: yes indeed

13:01 manic12: i'm trying to think of an external representation for physical units to be attached to numbers which works well will clojure and/or lisp

13:04 compactness is a problem

13:05 Makoryu: ,[32'in]

13:05 clojurebot: [32 in]

13:05 Makoryu: ,[600'mm]

13:05 clojurebot: [600 mm]

13:07 manic12: [600 mm^2] isn't going to work

13:09 compound units are a problem

13:10 Makoryu: ,'mm^2

13:10 clojurebot: mm

13:10 Makoryu: Hmm

13:11 opqdonut: how about [600 [* mm mm]]?

13:11 or even [600 (sq 'mm)]

13:11 manic12: too bulky

13:12 non-standard

13:12 opqdonut: of course one could define aliases 'mm2 etc

13:14 manic12: [20 '(kg m / s2)] which is obviously 20 N, but not all compound units become derived units

13:15 still a bit bulky

13:17 arbscht: what's wrong with [20 "mm^2"]?

13:17 Makoryu: , '(foo . nil)

13:17 clojurebot: (foo . nil)

13:17 hiredman: {:value 20 :unit "mm^2"}

13:21 manic12: have < > been taken for the reader?

13:21 albino: drewr: what do you like about it? Shows my naivety?

13:21 hiredman: ,'<a>

13:21 clojurebot: <a>

13:22 manic12: maybe I could hijack >< for units

13:23 <20 ft/s2>

13:23 drewr: albino: the way it follows Chouser and rhickey's conversation it makes it look like you were accusing Chouser of being a newb from proggit :-)

13:23 albino: drewr: :) good timing then

13:23 drewr: well played

13:26 arbscht: manic12: the reader is not user extensible

13:28 manic12: it is if there is source code available :)

13:48 ambient: i wish it was a bit easier to install and use penumbra :/

14:07 LauJensen: ambient: how could it be any easier to install ?

14:07 copy 4 files, export a new LD-LIBRARY, thats it..

14:09 ambient: if you're using unix or something, yes

14:09 manic12: what's penumbra?

14:09 google says it's part of a shadow

14:09 ambient: http://github.com/ztellman/penumbra

14:10 * technomancy just wishes more clojure authors would take dependencies seriously

14:10 manic12: interesting

14:10 i just used jogl and called the java directly

14:13 LauJensen: ambient: For Unix and OSX it should be fairly simple, given that nothing is simple on Windows, I don't feel that we have to discuss that

14:13 But even so, is there more to it? He supplies native windows libs

14:14 manic12: it was easy to use jogl on windows with clojure

14:14 ambient: LauJensen I don't know, I'm trying to figure it out

14:14 atm figuring out how to use netbeans & penumbra

14:15 LauJensen: k

14:15 manic12: netbeans is evil

14:15 ambient: if somebody has info on how to do this then im all ears

14:15 i dont know enough emacs to easily add new stuff into java classpath

14:15 LauJensen: When I got his opengl version of ikeda, I got is running quite quickly, just following his wiki, which is basically the same as for Sofiaba

14:15 technomancy: ambient: you can't add new stuff at runtime

14:15 manic12: i fought with netbeans for days and finally switched back to slime and things just started working

14:16 technomancy: ambient: but if you use swank-clojure you should get all the jars in lib/ added to the classpath for you

14:16 ambient: technomancy but restarting slime will read the new classpath, right?

14:16 technomancy: ambient: yes

14:16 you should check out the M-x swank-clojure-project command I added recently

14:16 ambient: oh sweet

14:16 manic12: unless for some reason your fingers cannot do emacs keys i recommend emacs

14:18 ambient: emacs on windows is just pretty buggy

14:18 * Raynes never had problems with Emacs on Windows. :>

14:18 manic12: not really

14:19 ambient: for example, i have to apply color-scheme twice until it looks ok

14:25 manic12: I have had a problem with emacs that if i run a lisp in it for more than three or four weeks straight it starts acting funny, probably because of the huge buffer

14:25 (on windows)

14:25 Chousuke: I usually don't get that long emacs uptimes :P

14:26 manic12: i'm sure now that i said that my machine will blue screen

14:26 Chousuke: heh

14:27 I haven't had my computer crash in months, but I reboot it occasionally to install updates.

14:27 manic12: usually i only have a problem with my computer if the power goes out unexpectedly and i don't run a chkdsk after restarting

14:27 Chousuke: right now going at 17 days it seems.

14:28 manic12: what os? linux?

14:28 Chousuke: OS X

14:28 manic12: my next computer is going to be an apple

14:29 * technomancy suggests a ][gs

14:29 technomancy: they're very reliable

14:30 cemerick: up 27 days on an MBP here, though that's not super-impressive.

14:30 rsynnott: Windows has reasonably long uptimes these days, no?

14:30 manic12: i have a freebsd server that only gets rebooted when the power goes out

14:30 * rsynnott finds it's hard to get more than a month or so on my mac, because Apple tends to update the OS often :)

14:30 manic12: lasts months

14:30 Chousuke: heh

14:31 I had that too.

14:31 I got 200 days of uptime and then I decided to upgrade it :P

14:31 cemerick: rsynnott: that's true on windows servers, but seemingly minor patches cause Vista to want to reboot for me

14:31 Chousuke: right now the machine is running Debian though.

14:32 manic12: now if clojure (i mean java) could only dynamically link classes

14:32 Chousuke: it's a bit slow, and using ports with it is a pain...

14:32 * rsynnott has not had the pleasure of using Vista

14:32 rsynnott: the XP machine I use at work tends to not need to be rebooted too often

14:32 manic12: vista is not as bad as people try to make it seem

14:33 technomancy: that's the most positive thing I've ever heard anyone say about it. =)

14:33 manic12: i think it's ok though i will probably change to windows 7

14:34 so when is the jvm going to be able to dynamically link/relink classes?

14:34 (java classes)

14:35 rsynnott: would that even be practical?

14:35 manic12: yes

14:36 i'm a cad hacker and oo is a very good paradigm for that

14:37 plus i noticed my directories fill up with new versions of clojure-generated classes each time i compile

14:44 hiredman: stop compiling?

14:51 manic12: that's not practical if you need to use gen-class, eventually you might have to change a method signature

14:53 Makoryu: manic12: The JVM can dynamically load classes already, but IIRC it's not pretty

14:53 manic12: in CL that signals an error, but at least you can continue

14:53 Makoryu: And there might be some really strange caveats about memory usage

14:53 manic12: can it reload classes?

14:57 hiredman: manic12: that's why you make all your methods take a Map

14:57 :P

14:57 the signature never changes

14:58 manic12: if they are already predifined java interfaces that's not possible, unless you're talking about [& args] for everything

15:02 hiredman: manic12: well, you mentioned having to change the method signature, if you are using a predefined interface then what method signatures need to change?

15:03 manic12: because it took my a while to figure out what the signature looked like in clojure

15:04 Makoryu: , (length (range 0xffffffffffffffffffffffff))

15:04 clojurebot: java.lang.Exception: Unable to resolve symbol: length in this context

15:06 Makoryu: , (.length (range 0xffffffffffffffffffffffff))

15:06 clojurebot: java.lang.IllegalArgumentException: No matching field found: length for class clojure.lang.LazySeq

15:12 hiredman: ,(doc count)

15:12 clojurebot: "([coll]); Returns the number of items in the collection. (count nil) returns 0. Also works on strings, arrays, and Java Collections and Maps"

15:12 hiredman: clojurebot: length?

15:12 clojurebot: count

15:12 hiredman: clojurebot: botsnack

15:12 clojurebot: thanks; that was delicious. (nom nom nom)

15:14 cemerick: rhickey: I have clojure lib A that's been AOT-compiled, and clojure lib B depending on A. A generates a clojure.proxy.java.lang.Object$Foo as expected. B does not refer to Foo directly at all, but it is generating a clojure.proxy.java.lang.Object$Foo classfile as well, presumably because it is referring to the ns in A that proxies Foo. Is this expected?

15:15 Chouser: lib A and lib B have different root dirs?

15:15 cemerick: (the issue is that things break in odd ways when both A and B's resulting jar files are on an application classpath, as the proxy classfiles aren't the same)

15:15 Chouser: um, yes. They're different projects.

15:16 Chouser: I wonder why are the generated classfiles different. They ought to be identical.

15:17 cemerick: Chouser: yes, that's got us pretty confused too. diff reports them to be different, though their signatures via javap are identical AFAICT

15:18 Chouser: I'm sure you know that the classname of proxy-generated classes has changed recently.

15:18 cemerick: Chouser: I wasn't, but I'm still (very unfortunately) at v1 + selective patches.

15:18 pixelman: is there something like gotapi.com but for clojure?

15:19 Chouser: oh!

15:19 cemerick: sorry, I should have read your question more closely.

15:19 hiredman: http://clojure.org/api

15:21 benreesman: any experienced clojure developers have a moment to help me out?

15:21 pixelman: hiredman: I've used that but it's hard to navigate and search because it's just all functions on one page, though I like that there's a page about sequences and stuff.

15:22 basically I'm looking for a way to easily browse all string functions etc.

15:24 hiredman: ~jdoc String

15:25 I guess subs is a string function

15:26 there is a strutils in contrib which wraps string stuff

15:26 clojurebot: contrib?

15:26 clojurebot: contrib is http://github.com/richhickey/clojure-contrib/tree/master

15:27 hiredman: http://richhickey.github.com/clojure-contrib/

15:28 pixelman: maybe I should try clj-doc

15:30 stuartsierra: except for subs and the regex stuff, core Clojure has no string functions

15:31 pixelman: the regex stuff is mostly matching right? no transformation stuff?

15:32 hiredman: java's .replaceAll method on Strings takes a regex, just as a string

15:32 stuartsierra: correct

15:33 c.c.str-utils2 does transformations with regexes

15:35 pixelman: ok

15:36 milep: Hello, I have a noob question: is there some simple way to sort list of vectors by the vectors first item(integer)?

15:37 Chouser: vectors are comparable, so just sort them.

15:38 ,(sort '[[3 a] [2 b] [4 c] [1 d]])

15:38 clojurebot: ([1 d] [2 b] [3 a] [4 c])

15:38 milep: ah, thanks

15:41 hiredman: there is also sort-by

15:41 pixelman: why does the environment complain if I try to start swank in a .war file? no *3 or something like that

15:42 hiredman: *3 is bound to the third last result in the repl usually

15:42 dunno what swank's deal is

15:46 pixelman: Yep, I gave up. I like deploying a war file to tomcat -- I do that now, but I might change to deploying just the sources and doing some hackety hack with nohup or something, it would be pretty nice to speed up deployment.

15:47 ordnungswidrig: hi

15:47 is there a shorthand for (or (nil? x) x (f x))

15:48 hmm, sorry, I meant (if (nil? x) x (f x))

15:48 hiredman: there is -?> in contrib somewhere

15:48 ,(doc -?>)

15:48 clojurebot: "([x form] [x form & forms]); Same as clojure.core/-> but returns nil as soon as the threaded value is nil itself (thus short-circuiting any pending computation). Examples : (-?> \"foo\" .toUpperCase (.substring 1)) returns \"OO\" (-?> nil .toUpperCase (.substring 1)) returns nil "

15:48 pixelman: (when-not x ?

15:49 hiredman: ,(-?> nil .toUpper)

15:49 clojurebot: nil

15:49 hiredman: ,(-?> "foo" .toUpper)

15:49 clojurebot: java.lang.IllegalArgumentException: No matching field found: toUpper for class java.lang.String

15:49 hiredman: ,(-?> "foo" .toUpperCase)

15:49 clojurebot: "FOO"

15:51 benreesman: anybody succeeded in implementing org.apache.catalina.CometProcessor in clojure?

15:52 arohner: anyone have a link to the snippet of code to call apply on java methods?

15:53 Chouser: arohner: http://paste.lisp.org/display/67182 -- jcall and jfn

15:53 arohner: Chouser: thanks

15:53 that should be built-in, IMO

15:55 Chouser: arohner: http://clojure-log.n01se.net/date/2009-09-22.html#08:58

15:55 stuartsierra: It is:

15:55 ,(doc memfn)

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

15:56 dthomas: Yeah, jfn looks like memfn.

15:56 arohner: stuartsierra: thanks

15:56 stuartsierra: np

15:57 arohner: BTW, I'm pretty sure I'm using this correctly, this time :-)

15:58 the java fn I'm calling takes a java.lang.Object...values

15:59 based on the number of columns in the 2d dataset

16:00 grr, but memfn is a macro, and I need to apply

16:02 lisppaste8: spuz pasted "PE4" at http://paste.lisp.org/display/87854

16:03 Chousuke: you indent too much :)

16:03 Chouser: arohner: right. in order to use memfn, you have to know the number of args.

16:03 ,(apply (memfn compareTo x) [16 8])

16:03 spuz: Chousuke: oh yeah that would be eclipse converting to tabs

16:03 clojurebot: 1

16:04 spuz: I posted that code because I was wondering why the solution to this project euler problem was about 10x slower than the java solution

16:04 Chouser: memfn is an older way to do some #() things, not a sufficient replacement for jcall

16:04 ,(apply #(.compareTo %1 %2) [16 8])

16:04 clojurebot: 1

16:05 spuz: Adding a type hint to my palindrome function helps a lot, but I'm not sure how to find out where the rest of the time is being spent. Anyone have any ideas?

16:06 Chousuke: that code can't even work. you can't have and contain recur :/

16:06 and if you're using plain recursion, that would explain it.

16:07 spuz: Chousuke: well it does work, I'm pretty sure the recur is working. It's guaranteed not to use the stack. If it couldn't loop, it wouldn't compile.

16:08 Chousuke: wait, hm

16:08 never mind, I lied ;P

16:09 I thought of 'and as if it were a regular function. :/

16:09 spuz: ah right

16:09 Actually, thinking about it, in my java solution, I'm not creating substrings, that is probably the cause of the difference

16:10 Chousuke: hmm

16:10 ,(== \a \a)

16:10 clojurebot: false

16:10 Chousuke: right, no == for characters :/

16:10 (it's a faster way to compare numbers)

16:11 hiredman: ,(== (int \a) (int \a))

16:11 clojurebot: true

16:11 Chousuke: that's cheating :)

16:13 spuz: hehe

16:14 Even replacing the recur with a direct recursive call does not add that much extra time. With recur it is about 380ms, with a recursive call to palindrome? it is about 420ms. A recursive implementation in java however is about 38ms.

16:19 actually with multiple timings, recur and the direct call are both around 400ms

16:23 somnium: any idea what would cause "no matching method found intern"?

16:23 serp_: hello. I get errors when building clojure-contrib such as "Could not locate clojure/stacktrace__init.class or clojure/stacktrace.clj on classpath". what can I do to fix this?

16:24 Chouser: serp_: is it possible you're using mismatched versions of clojure and contrib?

16:24 hiredman: somnium: no matching method usually means there is no method defined for some dispatch value, and the last thing in the message is usually the offending value

16:24 serp_: both are the latest

16:25 somnium: is intern used by some clojure datastructures internally?

16:25 hiredman: not that I am aware of

16:25 somnium: Ive run into it a few times now at the beginning of macros

16:25 hiredman: lisppaste8: url

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

16:25 hiredman: somnium: that is not a datastructure thing

16:25 there is a function named in intern

16:25 Chouser: serp_: have you built older versions of contrib in that same directory? you might try "ant clean"

16:26 serp_: no luck... I just downloaded clojure and clojure-contrib for the first time yesterday

16:26 hiredman: serp_: from were?

16:27 serp_: http://clojure.googlecode.com/svn/trunk and git://github.com/richhickey/clojure-contrib.git

16:28 Chouser: googlecode strikes again. :-(

16:28 hiredman:

16:28 ~github

16:28 Chouser: serp_: latest clojure is on github too

16:28 clojurebot: http://github.com/richhickey/clojure/tree/master

16:28 LauJensen: Seriously, why don't somebody shut down that outdated svn repo ?

16:28 Chouser: LauJensen: BDFL said no

16:28 LauJensen: rhickey: Explain yourself

16:29 serp_: oh... let me try with clojure from github :)

16:30 technomancy: I thought he was going to check in a readme with a deprecation notice

16:32 arohner: if I have a java method with the signature "addColumns(java.util.Collection<ColumnDescription> columnsToAdd)", can I call that directly with a clojure vector?

16:34 hiredman: (.addColumns someobject somevector)

16:34 lisppaste8: somnium pasted "untitled" at http://paste.lisp.org/display/87857

16:34 Chouser: ,(instance? java.util.Collection [1 2 3])

16:34 clojurebot: true

16:34 hiredman: ,(filter (partial = java.util.Collection) (ancestors (class [])))

16:34 clojurebot: (java.util.Collection)

16:35 arohner: I knew vectors implemented j.u.Collection, wasn't sure how that interacted with Generics

16:35 hiredman: generics do not exist at runtime

16:37 somnium: damn pasted a typo

16:38 arohner: ah, so they're just sugar like variadic methods?

16:39 lisppaste8: somnium annotated #87857 "untitled" at http://paste.lisp.org/display/87857#1

16:39 stuartsierra: not entirely; they're used by the Java compielr to do automatic casting

16:39 but they're not part of the actual type signature of methods/objects

16:40 kinda like Clojure type hints, actually

16:41 arohner: stuartsierra: cool, thanks

16:46 raek: my first useful piece of clojure: http://paste.lisp.org/display/87859

16:46 (def r (ref {:a 1 :b 2}))

16:47 (watcher-frame/watch r)

16:47 and a window pops up, showing the value of the ref

16:47 that changes when the ref changes

16:47 funkenblatt: ,(doc ns)

16:47 clojurebot: "([name & references]); Sets *ns* to the namespace named by name (unevaluated), creating it if needed. references can be zero or more of: (:refer-clojure ...) (:require ...) (:use ...) (:import ...) (:load ...) (:gen-class) with the syntax of refer-clojure/require/use/import/load/gen-class respectively, except the arguments are unevaluated and need not be quoted. (:gen-class ...), when supplied, defaults to :name correspo

16:48 raek: which way is the preferred way to use include and use?

16:48 Chouser: raek: cool! I think add-watch may be even easier to use in this case than add-watcher.

16:49 hiredman: there is no include

16:50 raek: i'm really a clojure n00b

16:50 so I don't know how to make libraries properly

16:50 arohner: raek: you'll want an ns declaration at the top of your file

16:50 Chouser: raek: destructuring, agent, watcher -- you're not doing too bad.

16:50 raek: Chouser: yes, you're right.

16:51 arohner: raek: then use :include, :use, :require in the ns declaration

16:51 hiredman: arohner: there is no :include

16:52 raek: am I doing the :include/:use/:require thingy wrong? and how should I do it?

16:52 funkenblatt: lol

16:52 arohner: sorry, import

16:52 Chouser: raek: the ns form you've got in that paste is fine except for the namespace name

16:52 hiredman: there is no :include!

16:52 raek: what should I write?

16:53 Chouser: raek: you must have at least two levels, but it's recommended to use the java package naming style

16:53 that is, something like com.your-site.watcher-frame

16:54 raek: ah

16:54 Chouser: then put your code in a file named something like src/com/yout_site/watcher_frame.clj

16:55 then people can put your src dir in their classpath and do: (use 'com.your-site.watcher-frame) and they're good to go.

16:55 raek: ah, I see

16:55 somnium: I found out what no method found intern means... calling keyword on something that can't be made into a keyword...

16:56 lisppaste8: mtm annotated #87854 "numeric version of palindrome?" at http://paste.lisp.org/display/87854#1

17:32 technomancy: anyone else think the "fixtures" feature of clojure.test is oddly named

17:35 Chouser: I assumed it was some kind of normal testing culture terminology.

17:35 technomancy: it is, but it means something else. =)

17:35 * technomancy has only seen it used to mean test data, fwiw

17:41 cemerick: technomancy: the usage in clojure.test is non-idomatic?

17:41 I thought it was just about right, insofar as we're generally working with immutable objects.

17:41 technomancy: cemerick: possibly it's used that way in other circles

17:41 but I've never seen that usage myself.

17:42 cemerick: I guess I don't really know the formal definition, but I wasn't suprised by the term's usage. *shrug*

17:42 spuz: mtm: thanks for adding that contribution. I was thinking whether it might be the string conversion that takes time in the palindrome? function. Either way, I'd like to know what clojure is doing under the hood and why there is this discrepancy with java

17:43 technomancy: cemerick: where have you heard it before?

17:43 I'd call it setup/teardown, but I guess I don't know of a single term that encompasses both those words.

17:43 cemerick: associated with junit and such. Generally meaning "anything you want to put together in setup()"

17:44 right -- how's that different from clojure.test fixtures?

17:44 technomancy: well I'd say you construct/initialize your fixtures in your setup.

17:45 they aren't executable themselves... though maybe this is just one of those "code is data" moments...

17:46 it's a nitpick; I was just wondering if I was missing something

17:46 cemerick: oh, well, yeah, you need to provide replacement for the setup method in xunit frameworks, etc.

17:47 you could just set up whatever data you want as a top-level in the namespace, which is a whole lot simpler.

17:47 But that's not appropriate for some usages.

17:50 lisppaste8: spuz annotated #87854 "2x faster function" at http://paste.lisp.org/display/87854#2

17:51 spuz: Anyone know why the 'for + :when' is about 2x faster than 'filter' in the above pasted code?

17:56 Chouser: spuz: you're sure you're letting the JVM warm up enough, averaging multiple runs, etc?

17:56 spuz: Chouser: yeah, I'm running multiple timed runs

17:56 using dotimes and time

18:05 Chousuke: spuz: well, using filter you have one extra layer of laziness and an extra function call. maybe it makes the JVM optimisations less effective

18:18 raek: when naming namespaces/packages in clojure/java the first two levels should be one's domain, right?

18:19 so, having the domain "raek.se", my namespace should begin with se.raek?

18:19 I've only seen examples woth .com and .org...

18:20 arohner: raek: the only real requirement is that it be unique. java says to use domains if you have them, because those are already guaranteed to be unique

18:22 * hiredman has been using hiredman.*

18:23 raek: arohner: ok, that makes sense

18:24 technomancy: raek: no need to use a domain name

18:24 that's for Java programmers that get paid by the directory

18:24 raek: hehe

18:24 technomancy: raek: hopefully you've already searched to make sure your project name is unique; if it is, then you will never have a problem just using your project's name as the namespace.

18:37 arohner: are there any projects yet to generate or template javascript from clojure?

18:38 hiredman: there was(is?) clojurescript of course

18:39 arohner: I'd like to avoid a 500k? client download. All I need to do is generate javascript function call literals

18:39 just a few steps above a JSON encoder

18:40 oh, and clojurescript.n01se.net crashed my firefox

18:42 hiredman: I can't imagine it would be that hard to do a very simplistic clojure fn => javascript function compiler

18:43 arohner: yeah. I might work on that

18:43 rboyd: I want an as3 compiler

18:43 cemerick: is there any reason to think the clojure compiler is non-deterministic the classfiles it generates?

18:43 e.g. given the same source, it should produce exactly the same output, right?

18:44 hiredman: cemerick: do you proxy the same bases in file B as you do in file A at anytime?

18:45 cemerick: hiredman: you're referring to my earlier question, I assume?

18:45 hiredman: yes

18:45 cemerick: B never proxies Foo at all, it only refers to a ns in A that does

18:45 yet the compiler generates a proxy classfile in B's output dir

18:45 hiredman: hmmm

18:47 I have no idea

18:47 cemerick: heh, yeah, me neither :-)

18:47 add to the strangeness, that behaviour *appears* to be nondeterministic

18:47 thus, my second question

18:49 I wonder if one needs those AOT-compiled proxy classfiles anyway -- aren't such things generated at runtime as necessary, anyway?

18:50 hiredman: proxy is an odd duck

18:50 cemerick: well, AOT compiling would be pointless if it it just left everything to runtime

18:51 proxy generates a class for every set of bases I believe

18:51 cemerick: hiredman: right -- but the proxy classfiles are particularly empty -- no impl in them at all, and no backreferences to where they're used

18:51 they *should* be identical for any particular combination of bases

18:52 hiredman: cemerick: possible use of gensyms for name stubs of something or other?

18:52 egads, core_proxy.clj is gnarly

18:54 cemerick: I may just push back our delivery and upgrade to clojure HEAD to see if this funniness just goes away.

18:54 dhaza: hi...why doesn't ns take a number of forms to add to the particular namespace

18:54 as opposed to setting some read-time(?) variable with what ns the forms should be added to

18:54 hiredman: cemerick: at least try it out and see what happens with the proxy namechange stuff

18:55 cemerick: I'm assuming there's going to be breakage. If we're going to make the move, we're just going to do it top to bottom.

18:55 we wanted to be there a month ago anyway

18:55 hiredman: dhaza: def picks up the value of *ns* at readtime/compile time anyway

18:56 dhaza: hiredman: http://pastebin.com/m45b1aa5a

18:56 cemerick: actually, we should be able to just replace our proxy usages with reify, no?

18:56 dhaza: i think i understand how it works...im just wondering why it was chosen to be that way and not in the style of what i pasted below

18:56 cemerick: or is proxy sticking around in HEAD for a reason?

18:57 hiredman: cemerick: you can update proxy's mapping of fns at runtime

18:57 cemerick: ah

18:58 hiredman: is that proxy's only advantage at this point?

18:59 hiredman: cemerick: dunno, that was just off the top of my head

18:59 I don't think I've ever used that

19:01 Chouser: reify's not in master

19:01 cemerick: heh, I would have discovered that eventually :-/

19:01 hiredman: dhaza: since namespaces roughly map to a file, nesting everything in another pair of parens doesn't make much sense

19:02 dhaza: hiredman, thats kind of what i assumed. i just wanted to make sure there wasn't some obvious reason i was missing out on

19:02 thanks for the info

19:03 hiredman: I mean, I don't know, but that seems logical

19:41 technomancy: is use-fixtures idempotent?

19:42 ah, looks like yes

20:12 arohner: wow, I need to read the clojure compiler source more often. Didn't realize that local variables are a var to a clojure map

20:30 timothypratley: If I want to check (instance? XXX (make-array Boolean/TYPE 2)), what is XXX?

20:32 hiredman: ,(class (make-array Boolean/TYPE 2))

20:32 clojurebot: [Z

20:32 hiredman: ,(Class/forName "[Z")

20:32 clojurebot: [Z

20:32 timothypratley: thankyou!

20:32 rhickey_: ,(instance? (Class/forName "[Z") (make-array Boolean/TYPE 2))

20:32 clojurebot: true

20:32 timothypratley: :)

20:36 konr: How can I connect to my (already running) nailgun server, evaluate a file and return the output to be used by another shell utility? What I want to do is something like `for x in $(nailgun-client ~/src/generate_links.clj); do wget $x; done` in bash

20:38 hiredman: ng clojure.main ~/src/generate_links.clj

20:38 savanni: identify thg,ttg

20:39 hiredman: whoops

20:39 savanni: Wow.

20:39 Yep. Oops. Now I have to figure out how to change that.

20:40 first I've done that in four years...

Logging service provided by n01se.net