#clojure log - Dec 08 2009

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

1:20 konr: Does you swing code look like a giant block of code with minor functions? I think something is wrong with mine.

1:22 arbscht: konr: I can't imagine how to interpret that description. can you paste an example instead?

1:38 twbray: Profiler tells me I'm spending all my time in java.lang.reflect.Array.get ... hmm...

1:39 dnolen: twbray: sounds like a missing type hint, you dereferencing a multi-dim array by chance?

1:39 hiredman: have you seen cgrand's post on arrays?

1:40 twbray: I suspect (let [ ... [client _ _ _ _ _ uri bstring status _ ref] (. #" " split line) ]

1:40 hiredman: Nope, but I think google just found it for me

1:40 hiredman: http://clj-me.cgrand.net/2009/08/06/what-warn-on-reflection-doesnt-tell-you-about-arrays/

1:40 you google faster than me

1:41 twbray: I've also been getting good results with hints

1:43 hiredman: oh

1:43 I see the destructuring let

1:43 twbray: #<CompilerException java.lang.Exception: Name conflict, can't def *warn-on-reflection* because namespace: user refers to:#'clojure.core/*warn-on-reflection* (NO_SOURCE_FILE:9)>

1:44 hiredman: set!

1:44 * twbray still hasn't really figured out namespaces

1:44 hiredman: ,(set! *warn-on-reflection* true)

1:44 clojurebot: java.lang.IllegalStateException: Can't change/establish root binding of: *warn-on-reflection* with set

1:44 hiredman: anyway, it will work at the repl

1:44 dnolen: twbray: wow, I didn't know that you could destructure a java array into a vector, I suspect you're right there's reflection happening there tho.

1:45 hiredman: the repl is run inside a binding where bindings for a bunch of stuff are setup so you can set! them

1:45 destructuring is actually a pretty complex macro

1:45 it's neat, but I would not bet the farm on it

1:46 twbray: Previously I was doing (let [ fields (. #" " split line) client (get fields 0) uri (get fields 6) etc ] changing to destruct had no effect on profiler output. Digging

1:46 hiredman: huh

1:46 twbray: 40% of all CPU going into java.lang.reflect.Array.get, snicker

1:46 hiredman: no effect is good I guess...

1:47 I think you'd use aget + a type hint instead of get

1:48 * twbray hadn't previously heard of aget.

1:48 hiredman: now you … half the … etc

1:49 twbray: OK, will wire in aget, brb

1:52 dnolen: twbray: http://gist.github.com/251463

1:53 on my machine destructure is considerably slower, ~250ms vs ~150ms for that microbenchmark

1:53 twbray: dnolen: thanks

1:53 dnolen: because that's a java method call to split the string you don't need to type hint

1:55 twbray: When you get reflection perf hogs, it's usually pretty obvious int he -Xprof output

1:56 Hah, switching to aget made java.lang.reflect.Array.get go away :) ...

1:56 hiredman: :D

1:56 magic

1:56 twbray: ... but bought me a reflection problem, java.lang.Class.forName0 all over the -Xprof :(

1:56 Need to find the right type hing

1:56 hint

1:56 Shouldn't be too hard

2:00 _ato: IIRC you need to hint both the array and the index

2:00 like (aget #^objects my-array (int i))

2:01 hiredman: magic

2:01 er

2:01 _ato: the array is in a local and is the result of a java call, so the array type will propagate

2:02 _ato: ah cool.

2:08 twbray: hiredman: not sure... I just decorated all those aget values with type-hints and it made a big difference

2:08 e.g. #^String uri (aget fields 6)

2:14 hiredman: twbray: ok

2:17 dnolen: twbray: hiredman: is mostly right, types do flow down let bindings, the issue is the boxing of values returned from functions.

2:17 that is the return value of aget is boxed, and needs to be type hinted if you want to do something fast with that return value

2:18 twbray: dnolen: OK. Not pretending I understand why that needs to be the case.

2:19 dnolen: twbray: simple rule, java methods return type to a let binding. Clojure functions won't. aget is a clojure function whereas (. #" " split ...) is a java method.

2:20 thus you don't need to typehint the return value of (. #" " split ...), but you have to type hint aget

2:20 the return value of aget.

2:20 twbray: dnolen: That's a little surprising since aget exists specifically to reach into Java arrays

2:22 _ato: but isn't aget inlined?

2:22 dnolen: twbray: it is, aget is a weird, it's an "inline" fn, not sure I really understand it all that well myself. but what I've described is the basic mental model for type-hinting.

2:22 _ato: :inline (fn [a i] `(. clojure.lang.RT (aget ~a ~i))

2:23 hiredman: hmmm

2:23 _ato: you think it could at least typehint it's second argument as an int

2:23 :/

2:23 twbray: Also btw *warn-on-reflection* didn't

2:25 dnolen: order of magnitude difference: http://gist.github.com/251483

2:25 _ato: I guess it's not warning on reflection because of this: static public Object aget(Object xs, int i){ return Reflector.prepRet(Array.get(xs, i)); }

2:25 hiredman: twbray: yes, as cgrand mentioned in his post, *warn-on-reflection* doesn't catch array reflection

2:26 twbray: btw, thanks for the cgrand pointer; hadn't noticed him previously

2:26 * hiredman totally is reading RT.java in emacs

2:26 dnolen: cgrand == crazy clojure hacker

2:26 hiredman: pitty about the font

2:27 twbray: Emacs is good for lots of things but not my fave for reading Java

2:28 hiredman: this is the second time I've installed emacs

2:28 twbray: hiredman: you on a mac? Aquamacs ftw

2:28 hiredman: the first time I just sort of stared at the empty editor for a while and then went back to vim

2:28 freebsd

2:29 a few clicks on emacswiki seems to indicate changing the font to dejavu sans mono is going to be a big deal

2:29 slyrus: twbray: the nextstep build isn't bad either

2:31 twbray: A line of output from "top" on one of those Sun multicore boxes, when Clojure's running hot:

2:31 26278 twbray 130 40 0 5195M 5164M cpu 380:40 2815% java

2:32 hiredman: :D

2:32 man, I want one of those

2:32 twbray: well, they're a little weird to work with. But when you get the code tuned, they can grind through an *amazing* amount of work. Good I/O too.

2:40 _ato: hiredman: btw add this to your emacs configuration: (set-default-font "DejaVu Sans Mono-11")

2:41 (assuming you're using emacs 23, older versions probably need that awful font syntax with all the dashes in it)

2:41 twbray: recent WF run, reasonably well-tuned CLojure code right now, 24 minutes elapsed, 10+ hours of CPU time.

2:42 _ato: -*-dejavu sans mono-*-*-*-*-*-*-*-*-*-*-*-* or whatever it is

2:42 hiredman: _ato: .emacs.el or .emacs or ...?

2:42 twbray: hiredman: ~/.emacs

2:42 _ato: hiredman: .emacs if you're not using the emacs starter kit

2:43 hiredman: my pinky is already killing me

2:43 what a rough life

2:43 _ato: yeah, most emacs users swap ctrl and caps-lock

2:44 JAS415: really?

2:44 twbray: On the mac, you can set caps-lock=>ctrl globally for all apps. Very helpful.

2:44 * twbray wonders why computers still have a caps-lock key

2:44 polypus: yeah or just leave ctrl as ctrl and change caps

2:45 JAS415: IN CASE YOU GET ANGRY :-)

2:45 hiredman: _ato: just did that

2:45 I had capslock mapped to compose

2:45 JAS415: or for writing really old lisp code

2:45 hiredman: so I could make accented i's

2:46 clojurebot: emacs?

2:46 clojurebot: emacs is best configured for Clojure with instructions at http://technomancy.us/126

2:48 hiredman: C-j is eval elisp?

2:48 _ato: only in *scratch*, I use C-x C-e as that works when editing .el files and such

2:49 and C-x C-e is eval clojure code in a .clj file as well

2:50 actually maybe not even in scratch

2:50 C-j is newline for me

2:51 ah.. looks like in a fresh install C-j is eval and insert the output into the buffer

2:54 polypus: you can also C-c v for eval buffer as elisp. i set slime C-c v to slime-eval-lisp as well

2:54 hiredman: hmmm

2:55 JAS415: you can also bind it however you want

2:55 polypus: sure

2:58 _ato: I'm totally useless when it comes to using other people's PCs these days. I keep hitting Capslock-a instead of Home and such.

3:02 hiredman: ugh, paste inserts where the mouse is

3:02 (middle button paste in X)

3:04 _ato: I usually use the keyboard to paste (C-y)

3:04 you might need: (setq x-select-enable-clipboard t)

3:04 to make it paste stuff that's been selected

3:06 hiredman: looks like (setq mouse-yank-at-point t) might do the trick

3:06 that makes the middle-mouse paste at the cursor location

3:06 instead of the mouse pointer location

3:08 hiredman: I see

3:08 C-j seems to somehow be bound to both newline and eval elisp

3:09 doesn't work out well

3:09 _ato: you can check what function a key press is bound to with: C-h k <keypress>

3:10 so like C-h k C-j

3:11 hiredman: M-:

3:11 excellent

3:12 says newline-and-indent, but in the scratch buffer it also does eval

3:12 * hiredman is getting handy with C-x 0

3:13 hiredman: yay! color-theme

3:32 triyo: I have a leiningen project.clj file where my project name is nutrifact and my version is ""0.1.0-SNAPSHOT". When I run "lein jar" or "lein uberjar" it builds a nutrifact.jar instead of the desired snapshot ver as per my project.clj. Am I issing something?

3:33 so should be nutrifact-0.1.0-SNAPSHOT.jar

3:34 hiredman: hmmm

3:34 is there rainbow parens for emacs?

3:37 _ato: not built-in as far as I know. There's this: http://nschum.de/src/emacs/highlight-parentheses/

3:38 eevar2: do you get rainbow parens for anything but emacs?

3:41 hiredman: vimclojure

3:41 _ato: triyo: you can do "lein jar whatever-you-like.jar" to call the jar something different if you want

3:42 by default lein just calls it project-name.jar

3:42 ls

3:42 hiredman: _ato: close

3:42 I guess that is close enough :/

3:43 triyo: _ato: do you run the stable ver of leiningen or latest from master repo?

3:45 _ato: triyo: I run with master because I code on leiningen a fair bit

3:46 hamza: guys, is there a repeat like function that will execute a function repeatedly?

3:47 _ato: ,(take 10 (repeatedly rand))

3:47 clojurebot: (0.8813602039501953 0.3653268991300669 0.6732810028855468 0.3679588982322579 0.6001436027276109 0.6081804356412707 0.7722853209560046 0.6811660555016636 0.18603216492432617 0.7955644218452835)

3:48 hamza: lol, so the answer was in my question, :) thanks...

5:21 adityo: ,'(nil 1 2 nil)

5:21 clojurebot: (nil 1 2 nil)

5:21 adityo: how do i remove the nils from this list

5:22 _ato: ,(remove nil? '(nil 1 2 nil))

5:22 clojurebot: (1 2)

5:23 adityo: damn, how did i miss nil?

5:23 thanks _ato

5:51 scellus: adityo: you missed it because it was removed? :)

5:54 adityo: :)

6:10 LauJensen: Anybody here running Mac OSX who can spend 25 secs with me in priv? :)

6:16 AWizzArd: github down?

6:17 _ato: github's up for me

6:17 defn: How do I add compojure's jar and deps/*.jar to my classpath in my REPL?

6:18 AWizzArd: defn: you want to add it while the jvm is already running?

6:19 _ato: thx for checking

6:21 _ato: I'd create a directory for your project, copy all the jars you need (including swank-clojure and clojure.jar and contrib) into project/lib and then use M-x swank-clojure-project

6:21 defn: i have a swank-clojure-import

6:21 _ato: ah, you must have a pre 1.0 version of swank-clojure then

6:22 if you're using java 6 then adding ".../compojure.jar" and "deps/*" to swank-clojure-extra-classpaths should work

6:22 defn: do you run jochu's?

6:23 i had trouble with technomancy's vers. with my current config so i switched back to jochu's

6:23 _ato: I run technomancy's with no config

6:24 defn: but that forces you to run it on projects right?

6:24 do you have it via elpa?

6:24 hoeck1: defn: have you restarted emacs?

6:24 defn: hoeck1: no, i opened a new REPL, d'oh, one sec

6:25 hoeck1: jochu's swank-clojure only builds the classpath on an emacs restart

6:25 _ato: it doesn't force you to run it on projects, you can use M-x slime as well

6:25 defn: hoeck1: that fixed it thanks

6:25 _ato: did you get it via elpa?

6:26 _ato: I think so

6:26 I've tried both ways

6:26 I think I'm currently with ELPA

6:38 defn: bah wtf

6:38 i removed the init.el entry for my clojure.el stuff -- installed swank-clojure, clojure-mode, etc. via ELPA

6:39 and now it complains when i start emacs that it cannot load swank-clojure, cant find it

6:39 Debugger entered--Lisp error: (file-error "Searching for program" "No such file or directory" "lisp")

6:39 LauJensen: defn, sounds like you need (setq swank-clojure-binary "/some/shell/script.sh") ?

6:41 defn: LauJensen: i dont even get that far

6:41 it wont load swank

6:43 _ato: stupid ELPA

6:43 make sure you have nothing to do with swank-clojure in your init.el (no requires or anything)

6:44 defn: yeah im pretty sure i dont, maybe this is cached from loaddefs.el or something?

6:44 LauJensen: defn, I posted a 'get started with clojure' link on my blog once, want me to dig it up ?

6:44 _ato: :/

6:45 defn: heh this is embarrassing

6:45 LauJensen: oh, youre not a noob? :) Sorry

6:45 defn: i think i fixed it

6:45 _ato: I guess have a poke in ~/.emacs.d/elpa/swank-clojure-1.0 and make sure the files are there

6:45 ah, cool

6:45 defn: i think i just needed slime-repl from ELPA

6:45 i figured that'd be a dependency or something

6:45 _ato: yeah it should have been

6:45 strange

6:46 defn: swank-clojure-project still seems broken

6:47 _ato: what does it do?

6:47 defn: just keeps polling on the project dir

6:47 until i have to abort with slime-abort-connection

6:48 _ato: you copied in clojure.jar clojure-contrib.jar and swank-clojure.jar right?

6:48 defn: i thought it copied those automatically for you

6:48 _ato: nah

6:48 causes you might want to use different versions

6:49 defn: right, just thought if it couldnt find them that it'd give you something to work with

6:49 _ato: if you want to use the versions it downloaded they're in ~/.swank-clojure

6:49 defn: but ok

6:49 thanks :)

6:50 _ato: that worked?

6:50 yeah it'd be nice if it did do it for you if they aren't there, but I guess it can't reliably detect if they're there or not, cause they could be named something different

6:52 LauJensen: I thought it was possible just to install clojure-mode via Elpa, and then M-x clojure-mode-install, which would pull down everything, build and configure?

6:52 adityo: LauJensen: whats the link for your blog

6:52 LauJensen: http://www.bestinclass.dk

6:52 Link the right-most pane named 'blog'

6:53 In this context, link means click :)

6:54 _ato: I think clojure-mode-install is now deprecated in favor of ELPA

6:54 somnium: I got the latest version to install itself only after putting in a clean .emacs.d and removing my .clojure dir. It works great now.

6:55 _ato: is it possible to use clojure-new as a dep with lein/clojars?

6:55 adityo: yes i can confirm from technomancy's blog post that clojure-install is deprecated

6:56 LauJensen: Ah ok

6:56 Wonder why, I've seen it work quite well on both Linux and *sigh* Windows :)

6:56 adityo: http://technomancy.us/126

7:02 defn: that's awesome (leiningen)

7:02 _ato: he's just using the compojure jar I uploaded, that's why it's org.clojars.ato/compojure

7:02 defn: omg so glad i went through the minor headache of switching to technomancy's version

7:02 _ato: and yes leiningen is pretty nice

7:02 defn: actually being able to tab complete clojure.contrib.* stuff

7:03 _ato: :)

7:03 micampe: oh gosh. every time I come here I learn a new tool I should learn.

7:05 so, since I always hated ant and maven, I think I'm going to look at leiningen now

7:05 defn: no need to copy all of the stuff i need by hand, I can just setup package.clj and hit `lein deps`

7:10 Chousuke: hm, the font at clojars.org is huge

7:10 maybe my resolution is a bit too small :P

7:10 But it's a refreshing change. Usually I get to complain about the font being too small.

7:10 _ato: yeah I made it huge on purpose

7:11 though maybe it's too huge, probably some of the longer package names will go off the edge of the page

7:14 Chousuke: _ato: at 80% zoom the font size looks fine to me. Hmm.

7:23 interferon: anyone know of good clojure blogs?

7:25 liebke: interferon: a good place to start is http://disclojure.org/ and then check its blogroll

7:32 interferon: thanks

8:40 fliebel: How can I find out if the function supplied to a macro is really a function?

8:40 ,(fn? (first '(print "hi")))

8:40 clojurebot: false

8:40 _fogus_: ,(fn? (first `(print "hi")))

8:40 clojurebot: false

8:41 _fogus_: hmm

8:41 fliebel: I tried symbol, but that returns true, even for jerhlaf, or skdjbl.

8:42 Are there by chance Clojure functions named like that? :D

8:44 arbscht: ,(fn? (var-get (resolve (first '(print "hi")))))

8:44 clojurebot: true

8:44 _fogus_: D'oh!! Of course.

8:44 Chousuke: fliebel: unless it's a function defined with def though, you can't.

8:44 also, var-get = deref = @ :)

8:45 fliebel: thanks

8:45 and resolve?

8:45 Chousuke: resolve resolves a symbol to a var

8:45 arbscht: ,(doc resolve)

8:45 clojurebot: "([sym]); same as (ns-resolve *ns* symbol)"

8:45 arbscht: ...

8:46 ,(doc ns-resolve)

8:46 clojurebot: "([ns sym]); Returns the var or Class to which a symbol will be resolved in the namespace, else nil. Note that if the symbol is fully qualified, the var/Class to which it resolves need not be present in the namespace."

8:47 fliebel: so what you are doing is tracing down and following all the references until you find the actual fn.

8:47 What if the user supplied a #function?

8:47 Chousuke: then it won't work

8:47 macros have no access to runtime data.

8:48 fliebel: ah, ok

8:49 How suitable it a Scheme mode in my editor for editing Clojure? It does not support CL or Clojure.

8:49 Chousuke: which editor?

8:49 arbscht: Chousuke: macros?

8:49 fliebel: I tried Netbeans, but that did not work for me, I'm using Komodo Edit.

8:50 Chousuke: arbscht: yes?

8:50 arbscht: Chousuke: I don't see any macros

8:50 _fogus_: http://home.pipeline.com/~hbaker1/

8:51 Chousuke: arbscht: the original question was how to tell if a macro was passed a function

8:51 arbscht: oh!

8:51 :-)

8:51 Chousuke: which is not possible in the general case because macros operate with symbols and lists, not functions :/

8:53 arbscht: fliebel: I would not expect it to be suitable. it won't know conventional indentation rules, for example

8:57 cp2: mornin'

8:57 clojurebot: good morning ^_^

8:57 clojurebot: Gabh mo leithscéal?

9:00 fliebel: Are there other Mac editors suitable for editing Clojure except emacs and Netbeans?

9:01 cp2: vim :D

9:01 eclipse has an alright clojure plugin, intellij has a nicer clojure plugin and there is a free/open source version now

9:02 although ive found that you really dont need a java ide for writing clojure, and that the overhead is unnecessary because of the lack of features of the plugins

9:03 my advice is stick with vim or emacs, and get really good at using them

9:05 er, them being the one you choose of course

9:05 cemerick: man, two editor discussions in two days :-/

9:05 cp2: cemerick: heh, im being careful to not say 'x is better than y'

9:05 chouser: people keep asking. *shrug*

9:06 I guess there could be a page we could just point to.

9:06 rhickey: how are people making out with latest new branch? (fine-grained locals clearing)

9:06 chouser: hey look, there is: http://stackoverflow.com/questions/257333/clojure-editor-ide-recommendations-on-os-x

9:06 cemerick: The best answer is almost always going to be "whatever you're using now for everything else"; besides that, it's all personal preference.

9:07 I've found SO to be a ghetto for the most part.

9:11 chouser: rhickey: have been using the latest 'new' branch for misc. light clojure activity -- nothing to report.

9:11 rhickey: chouser: no news is good news :)

9:12 chouser: exactly

9:12 I don't have much code sitting around that used to blow the heap to try out now.

9:13 cp2: rhickey: but what if they shot the messenger?

9:13 rhickey: chouser: yeah, I have to go back through and find some old problem reports in the group

9:13 chouser: hm. thrilling.

9:14 rhickey: there was some destructuring thing

9:15 chouser: I think I have it

9:16 (defn loop-test [] (loop [[head & tail] (repeat 1)] (recur tail)))

9:16 rhickey: might have been something jdk 6 could figure out that 5 couldn't

9:16 chouser: yes, that's this one

9:17 somnium: is (:field my-type) still equivalent to (.field my-type)?

9:20 chouser: somnium: in the 'new' branch when my-type is a deftype instance, they should be equally fast once hotspot is done doing what it does.

9:20 somnium: have type with field 'then', (.then type) returns the value, (:then type) returns #<Type$__lookup__then ...>

9:20 chouser: I think. :-)

9:20 somnium: yeah, ^^ this odd behavior just now

9:20 chouser: somnium: are you sure you've got the latest 'new'?

9:21 somnium: a few days old I think

9:21 chouser: yeah, better upgrade. the edge bleeds, gotta keep moving.

9:22 somnium: I saw it seemed to break swank yesterday so Ive been holding off

9:22 can anyone confirm?

9:22 chouser: ah. I think that's been fixed now.

9:22 AWizzArd: is there a new behaviour in deftype? I upgraded today. Now I do: (deftype foo [a b]) and then (:b (foo 10 20)) ==> nil

9:22 chouser: somnium: hang on -- booting the computer that has 'new'...

9:23 somnium: AWizzArd: does (.b foo) work?

9:23 AWizzArd: yes

9:24 chouser: hmm

9:24 I'm seeing AWizzArd's bug.

9:24 AWizzArd: Now (.b (foo 10 20)) ==> 20, but I am very sure that (:b (foo 10 20)) ==> 20 also before

9:25 chouser: but not somnium's -- nil returns, not lookup methods.

9:26 somnium: you probably want version a3e95cf

9:26 somnium: at least once (:a foo) worked here, then suddenly seemed to break

9:26 chouser: somnium: yes, that was a bug that was fixed

9:26 rhickey: somnium: that's fixed, move on

9:26 somnium: thanks

9:27 AWizzArd: So, what is official now? Should I wait for an update so that (:b my-foo) ==> 20 again, or should I change my code to (.b my-foo) now?

9:27 chouser: AWizzArd: "official"? Is 1.0 :-)

9:27 AWizzArd: official for alpha I mean :-)

9:27 rhickey: AWizzArd: don't use (.b, I'm looking at your problem

9:28 AWizzArd: I want to use the New branch, because it is a) very helpful and b) I want to help by alpha testing it.

9:32 pjstadig: emacs question

9:32 M-x swank-clojure-project

9:32 the class path is missing clojure and swank-clojure

9:33 is this intended? or a bug?

9:35 AWizzArd: You should put swank on your classpath.

9:35 Some months ago this was not needed.

9:37 And the slime version that you use should not be too new.

9:37 pjstadig: i installed with elpa

9:37 clojurebot: elpa is a package manager for Emacs: http://tromey.com/elpa

9:37 pjstadig: thank you clojurebot, i knew that

9:37 :)

9:38 hipertracker: (+ (/ 1 3) (/ 1 2)) -> 5/6 zajebiste

9:38 pjstadig: everything works fine

9:38 AWizzArd: Currently there is a problem, the new slime does not work anymore. I think it has to do with names of symbols. Slime now uses symbols that begin with a digit, or it uses symbols that contain spaces, something like that.

9:38 And now there is the discussion who should care about that: slime or the clojure side ;)

9:38 (in swank-clojure)

9:39 pjstadig: i thought M-x swank-clojure-project would be cool, but it doesn't load slime or clojure which i guess is probably a better way of doing it

9:39 then you can control what version of clojure, etc. you use by putting them in lib

9:39 AWizzArd: It is also a bit unfortunate that the new slime needs an internet connection. People behind a firewall won't be able to install slime+clojure this way.

9:40 devlinsf: hipertracker: Let clojurebot do the work for you

9:41 ,(+ (/ 1 3) (/ 1 2))

9:41 clojurebot: 5/6

9:41 hipertracker: devlinsf: sorry, wrong window.

9:41 devlinsf: hipertracker: n/p

9:42 AWizzArd: ,(+ 1/3 1/2)

9:42 clojurebot: 5/6

9:43 chouser: ,1/3+1/2

9:43 clojurebot: Invalid number: 1/3+1/2

9:45 AWizzArd: i think symbol names must not start with digits

9:52 devlinsf: Hey, is there a way to force division to be a double through a binding? What I specifically want to AVOID is (double (/ 1 3))

9:52 nm - just answer my own question at the REPL

9:52 ,(/ 1.0 3)

9:52 clojurebot: 0.3333333333333333

9:54 AWizzArd: ,(let [a 2, b 3] [(class a) (class b) (/ a b)])

9:54 clojurebot: [java.lang.Integer java.lang.Integer 2/3]

9:54 AWizzArd: if it is a function parameter you should convert it at one point to a double or BigDecimal

9:54 fliebel: Why does Clojure not support 1+1 etc, but does support 3/2?

9:55 AWizzArd: because 3/2 is not a function call

9:55 it is the notation for rational numbers

9:55 cemerick: fliebel: because the former is an operation, the latter is a value

9:55 chouser: fliebel: 3/2 is a literal form of a Ratio instance. like "foo" is a String

9:55 _fogus_: fliebel: It's read: 3 over 2

9:56 AWizzArd: ,12E+2

9:56 clojurebot: 1200.0

9:56 fliebel: strange thing to make a "devision" a literal, although it might save some headaches.

9:57 AWizzArd: it is not a division

9:57 cemerick: it's not division

9:57 AWizzArd: it is the notation for a number

9:57 pjstadig: for an exact number

9:57 floating points aren't exact

9:57 cemerick: ,1/3

9:57 clojurebot: 1/3

9:57 cemerick: ,(float 1/3)

9:57 clojurebot: 0.33333334

9:57 AWizzArd: helpfull for us poor humans who can't work successfully with sequences of 0s and 1s

9:58 cemerick: the latter is division

9:58 devlinsf: Right, they're only good for a relative error of 1E-16

9:58 cemerick: or, it makes the division represented by the ratio concrete

9:58 fliebel: ,(* 22/7 2)

9:58 clojurebot: 44/7

9:58 devlinsf: ,pi

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

9:58 AWizzArd: ,Math/PI

9:58 clojurebot: 3.141592653589793

9:59 devlinsf: Ah

9:59 cemerick: which is defined as a double, I think.

9:59 devlinsf: ,(class Math/PI)

9:59 clojurebot: java.lang.Double

9:59 fliebel: Would be cool to have PI as a… something

9:59 devlinsf: A what?

9:59 cemerick: 22/7 is always just 22/7, unless you explicitly force it into a float or double

10:00 esj: 22/7 is not pi

10:00 AWizzArd: ,(rationalize Math/PI)

10:00 clojurebot: 3141592653589793/1000000000000000

10:00 fliebel: Well, something that is more precise...

10:00 esj: mathematical impossibility

10:00 cemerick: yeah, closer than Math/PI

10:00 devlinsf: Thank you esj

10:01 Please, Math/PI is great as a double

10:01 fliebel: I won't launch a rocket with double persoanly, but I guess it's okay in 99.9999% of the time.

10:02 AWizzArd: and ifs someone cares then he/she can have pi as a rational number, which will not be less exact

10:02 esj: i suppose using the series representation as a lazy sequence is possible

10:02 devlinsf: fliebel: Ever here of Apollo?

10:03 fliebel: devlinsf: Yea, I know they launched that with less computer power than in my iPod….

10:03 devlinsf: fliebel: study analog & digital controls sometime. You'll realize that the limits of double are nothing compared to the limits of the algorithms

10:03 AWizzArd: Just (def π 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067M)

10:03 devlinsf: Perfect!

10:03 AWizzArd: that's the first 100 digits, as a BigDecimal

10:04 devlinsf: Totally useless in production, buyt perfect

10:04 AWizzArd: ;-)

10:04 rhickey: AWizzArd: fixed

10:04 AWizzArd: wow rhickey, this is very nice thanks *handshaking*

10:05 rhickey: was actually a problem mwith case

10:05 * rhickey wishes for tests for deftype/reify/defprotocol/case

10:06 shr3kst3r: tests are a fine idea

10:07 _fogus_: fliebel: What does this mean? "compared to the limits of the algorithms"

10:07 devlinsf: _fogus_: right here

10:07 Licenser_: Oha odd thing, I've a server socket, created with create-server, now when I connect to it via telnet and type in stuff it works fine, connecting with a java.net.Socket and writing stuff to it works too but when the socket is closed the line seq created from the server crasehs with a runtime exception :/ (Exception in thread "Thread-1" java.lang.RuntimeException: java.lang.RuntimeException: java.net.SocketException: Software caused connection abort: recv fa

10:08 any ideas cause I am not entirely sure what to make from this

10:08 fliebel: _fogus_: no idea…

10:08 _fogus_: devlinsf: Sorry, clicked wrong name

10:08 devlinsf: *WARNING - MATH CONTENT*

10:08 _fogus_: devlinsf: Bring it on ;)

10:10 devlinsf: _fogus_: Forgive the following question. You've studied calculus before, right?

10:11 _fogus_: devlinsf: Once upon a time

10:12 devlinsf: devlinsf: Perfect. That will be enough. I will be using the process of integration as an example

10:12 _focus_: Sorry, wrong name :)

10:12 _fogus_ :Ah!

10:12 Licenser_: I knid of have tom think of fungus o.O

10:12 devlinsf: Okay, forget it

10:13 You have certain integrals that don't have a solution

10:13 but as an engineer one needs to solve them all the time

10:14 For example, consider the Gaussian function, (fn[x] (Math/exp (* -1 x x)))

10:14 angerman: how do I add custom jar's to leiningen?

10:14 devlinsf: def that as gauss

10:15 _fogus_: ,(def gauss (fn[x] (Math/exp (* -1 x x))))

10:15 clojurebot: DENIED

10:15 _fogus_: :(

10:15 AWizzArd: use let

10:15 devlinsf: ,(gauss -7)

10:15 clojurebot: java.lang.Exception: Unable to resolve symbol: gauss in this context

10:16 devlinsf: Have a REPL open?

10:16 You'll see that (gauss -7) is very close to 0

10:16 _fogus_: ,(let [gauss (fn[x] (Math/exp (* -1 x x)))] (gauss -7))

10:16 clojurebot: 5.242885663363464E-22

10:16 devlinsf: As is (guass 7)

10:17 _fogus_: sure

10:17 esj: to back up devlinsf - in addition, in getting stuff from the real world into the computer, the sensors that we use often less than double precision accuracy once you account for noise, so using greater precision in your maths is often (not always) unneccessary.

10:18 devlinsf: esj: Agreed - But I want to attack the problem mathematically, not as an engineer

10:18 esj: I'm an engineer myself, so I agree with you 110%

10:18 esj: devlinsf: sorry, just glanced over and wanted to comment, will sit back now :)

10:19 devlinsf: esj : :)

10:19 fliebel: devlinsf: why do you include −1 of both 7 and −1 return the same result?

10:20 devlinsf: Umm??

10:20 fliebel: of = if and the last 1 = 7

10:20 devlinsf: ,(let [gauss (fn[x] (Math/exp (* -1 x x)))] (gauss -1))

10:20 clojurebot: 0.36787944117144233

10:20 devlinsf: ,(let [gauss (fn[x] (Math/exp (* -1 x x)))] (gauss -7))

10:20 clojurebot: 5.242885663363464E-22

10:20 devlinsf: ,(let [gauss (fn[x] (Math/exp (* -1 x x)))] (gauss -1))

10:20 clojurebot: 0.36787944117144233

10:20 devlinsf: ,(let [gauss (fn[x] (Math/exp (* -1 x x)))] (gauss 7))

10:20 clojurebot: 5.242885663363464E-22

10:20 devlinsf: Sorry to spam

10:21 fliebel: could you clarify?

10:21 fliebel: ,(let [gauss (fn[x] (Math/exp (* -1 x x)))] (= (gauss 7) (gauss −7)))

10:21 clojurebot: java.lang.Exception: Unable to resolve symbol: −7 in this context

10:21 fliebel: well, both the result of 7 and −7 are 5.242885663363464E-22

10:21 devlinsf: Right

10:21 _fogus_: ,(let [gauss (fn[x] (Math/exp (* -1 x x)))] (= (gauss 7) (gauss -7)))

10:21 clojurebot: true

10:22 devlinsf: They should, it's an even fn

10:23 fliebel: so why do you include −1 in the function, this would only make −7 -> 7 and 7 -> −7 right?

10:23 devlinsf: because that's the definition of the gaussion

10:23 e^-(x^2)

10:23 *gaussian

10:24 fliebel: devlinfsL ok, fine, i never did so much math...

10:24 i'll sit back and listen

10:24 devlinsf: That's okay, questions are good

10:25 http://www.codersource.net/published/view/279/guassian_smoothing_in_csharp.aspx

10:25 There's a good graph of the function

10:26 Often, you need to find the area under the curve, starting at -infinity, to some value of x

10:27 Now, as we demonstrated, -7 is close to zero, so I'm gonna assume that the area to the left of 7 is zero

10:27 Or really reall really close

10:28 The first attempt to approximate the area is to create a lot of rectangles.

10:28 Let's start with a base width of 1

10:29 (let [gauss (fn[x] (Math/exp (* -1 x x)))] (map gauss (range -7 7))

10:29 ,(let [gauss (fn[x] (Math/exp (* -1 x x)))] (map gauss (range -7 7))

10:29 clojurebot: EOF while reading

10:29 Licenser_: FYI: My problem was the socket closing too fast and line-seq still wanting to read from it, having the client wait for a second before closing the socket fixed it - not nice but it works

10:29 devlinsf: ,(let [gauss (fn[x] (Math/exp (* -1 x x)))] (map gauss (range -7 7)))

10:29 clojurebot: (5.242885663363464E-22 2.3195228302435696E-16 1.3887943864964021E-11 1.1253517471925912E-7 1.2340980408667956E-4 0.01831563888873418 0.36787944117144233 1.0 0.36787944117144233 0.01831563888873418 1.2340980408667956E-4 1.1253517471925912E-7 1.3887943864964021E-11 2.3195228302435696E-16)

10:29 devlinsf: There

10:29 So, we know the height of the rectangle, and we know that it has a width of 1.

10:30 We can simply add up these values and get an approimation at each point.

10:31 Works for integers, but falls appart if we want to find the value everything less than say -.25

10:31 So, the obvious thing to due here is to use smaller rectangles

10:32 It turns out, that if you make your rectangles twice as small you get twice as good a result, etc.

10:32 But now we have to do twice as much work.

10:32 Boo :(

10:32 fliebel: you are trying to find the point where the gauss is 0?

10:32 devlinsf: Now, you trying to find the area under the curve to the left of a point x

10:32 I.E, and integral

10:33 *No

10:33 fliebel: oh, sorry… I should redo my math...

10:33 devlinsf: It's cool stuff, really.

10:33 Haskell will make more sense as you do... but i digress

10:34 So, as I change the width of my rectange (w), the error improves by (w)

10:34 Kinda sucks

10:34 There's a well know algoritm called Runge-Kutta

10:35 http://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods

10:35 fliebel: devlinfs: I liked it quite much until I came to sin and cos, which are fine, as long as you understand what is the point.

10:35 devlinsf: fliebel: sin & cos a great

10:35 *are

10:36 RK has an interesting property

10:37 As we change the size of our rectagle, our error goes down dramatically. Specically w/ RK4, a change in w results in an error size of w^4

10:37 So a 2x smaller rectangle is 16 times more accurate

10:37 fliebel: devlinsf: I agree… I tried my best to learn them, and I understand them to some extent now, but after that I kind of gave up.

10:38 devlinsf: fliebel: If you like physics, it'll be easier to understand

10:39 What is so interesting is that RK4 doesn't depend on a decimal apprimation. You could do all of you arithmatic exactly, and the same property would apply

10:41 Questions so far?

10:42 _fogus_: not yet

10:42 devlinsf: Okay, cool

10:43 fliebel: If I knew integrals, I'm sure I'd understand :D

10:44 devlinsf: So, the guass function is fairly straightforward

10:44 gauss

10:44 The real problem arrises when you move from simple integration to differential equations

10:45 esj: fliebel: its like zooming in on the answer, but where it takes time to zoom, so you can have a high a resolution as you want, but to get it takes unlimited time to get it.

10:45 fliebel: I kind of understood that, only failed to understand the goal and the means of doing so.

10:46 _fogus_: devlinsf: I think I see the point of your original statement

10:46 devlinsf: Okay

10:47 _fogus_: devlinsf: But by all means continue

10:47 devlinsf: There is this concept of stability with differential equations

10:47 cp2: is there a 'conventional' way of storing a seq (specifically a vector) in a db (via c.c.sql) ?

10:47 fliebel: I think even I do… You'd need incredible small squares to need more than a float.

10:47 esj: fliebel: yes, but it gets worse, watch !

10:47 devlinsf: What stability means is that "If I ask the same questions, do I get the same anser"

10:48 A stable equation behaves like you expect. If I use smaller rectangles, my answer gets better

10:48 fliebel: devlinfs: are there cases in math where you can get different answers without treads or random numbers?

10:49 devlinsf: An unstable equation is painful. The more rectangles you throw at it, the worse it gets

10:49 fliebel: show us :)

10:49 notallama: a gaussian doesn't have an antiderivative, right? maybe you could integrate the first n terms of the taylor series around 0. i dnno if that will help, though

10:50 devlinsf: boss

10:51 esj: i think I know where devlinsf may be going, so i'll have a go at continuing

10:51 if you want to land your rocket on the moon you need to solve some differential equations

10:52 which you do through the same technique of successively small rectangles

10:52 but if your recantangles are too big, your answer is inaccurate, as with the integral example

10:53 the problem now is, that if you make your recangles small, to get higher accuracy, your numerics blows up

10:53 its not just that it takes forever to get the answer, but you actually stop moving and cant.

10:53 devlinsf: Thanks esj

10:53 Gotta go, you got it

10:54 esj: devlinsf: np

10:54 fliebel: thanks! :)

10:54 _fogus_: devlinsf: Thanks for the run-down

10:54 esj: a lot of stuff that you want to calculate is like this

10:55 so having \pi greater than double is usually not useful

10:56 fliebel: calculating pi to be greater than float is fun though...

10:56 esj: you can calculate it as accurately as you like

10:56 angerman: does anyone know how to add a classpath element to the leiningen project.clj?

10:56 I want to add a .jar file that is not on clojars

10:56 notallama: you could keep a lazy seq of the digits of pi : p

10:57 esj: you could us this for instance to make a lazy sequence of pi to whatever accuracy you desired: http://en.wikipedia.org/wiki/Leibniz_formula_for_pi

10:57 fliebel: I must confess I rather like PI, and can name more than 10 decimals, without wikipedia :)

11:04 How can I compile or run a clj file? So far I only played with the REPL. Just entering a file to clj gives me an exception that --file.clj does not exist.

11:06 _fogus_: fliebel: What command are you using?

11:07 fliebel: clj test.clj

11:07 _fogus_: What is clj?

11:08 somnium: fliebel: clj is a bash script?

11:08 fliebel: may need to make sure it accepts arguments

11:09 micampe: fliebel: have you seen Darren Aronofsky movie Pi?

11:09 somnium: micampe: thats a great movie

11:09 micampe: indeed

11:10 I love the BW treatment

11:10 somnium: they even play go!

11:10 someone should write a go engine in clojure

11:10 esj: speaking of intractable algorithms... :P

11:11 somnium: :P

11:11 angerman: is anyone using lein-swank + emacs?

11:11 karmazilla: speaking of clj the bash script. My homebrew related e-mail from a couple of days back; I wonder if people have opinions or if I'm the only person caring :)

11:11 somnium: theyve gotten better than anyone thought they would already

11:12 angerman: when ever I hit C-c C-c it tries to fontify something and runs regexps pretty long

11:13 micampe: eh. I have enough problems wrapping my head around sockets in clojure, go would be a bit far a away at the moment.

11:14 somnium: micampe: I think its the only game left where humans still can regularly beat engines.

11:15 fliebel: somnium: I just thought about that yesterday, after trying to learn go.

11:15 micampe: I have not seen the movie I think.

11:15 micampe: fliebel: you should.

11:16 fliebel: domnium: I'll have a look at clj, it's just what macports istalled.

11:16 micampe: youtube?

11:16 somnium: Ive been struggling with nio but more due to lack of java familiarity than clojure

11:16 esj: its a similar-ish thing to our previous discussion. A computer playing chess knows all the possible "sure thing" endings an figures out all possible paths from the current state to one of those. But go is not like that, there are too many possibilities, so you need to guess... computers are not so good at that... yet.

11:17 micampe: fliebel: there are probably pieces of it on youtube. I have it on dvd.

11:18 esj: of course in emacs you just press C-C M-^ alt-cokebottle handbrake and it figures out how to win the game... but thats entirely something else

11:18 fliebel: esj: this kind of problem always make me think in force fields....

11:19 esj: fliebel: that is excellent intuition, and the guesses that are made are based exactly on that sort of idea.

11:20 fliebel: esj: I guess it's easier to write robocode bots :D

11:20 somnium: esj: I think table-bases only go to 6-pieces currently

11:20 fliebel: somnium: clj is a bash script full of nonsens....

11:20 somnium: I wonder how many terabytes it would take for all 20

11:21 esj: somnium: wow, that's pretty crazy.

11:21 somnium: er, 16 rather

11:22 32, ok I cant count

11:22 esj: :)

11:22 fliebel: somnium: (19) that makes me thing of my java book, where they represented a playing field by the pieces and their position rather than a 2d list.

11:27 somnium: fliebel: in some ways its unfortunate, I suspect the world champion probably has a negative score against his cell phone these days (chess)

11:27 polypus: esj: they are making great strides now with statistical methods in go

11:27 cp2: is there a 'conventional' way of storing a seq (specifically a vector) in a db (via c.c.sql) ?

11:28 polypus: i just read this "The var metadata can be used for application-specific purposes as well. Consider using namespace-qualified keys (e.g. :myns/foo) to avoid clashes." in the doc on def.

11:28 somnium: ,(str [1 2])

11:28 clojurebot: "[1 2]"

11:28 somnium: ,(read-string "[1 2]")

11:28 clojurebot: [1 2]

11:28 polypus: i don't get how this is namespace qualified?

11:29 cp2: ah

11:29 esj: polypus: thanks.

11:29 cp2: somnium: i didnt think of that, thanks

11:29 _fogus_: ,::foo

11:29 clojurebot: :sandbox/foo

11:30 _fogus_: sandbox is the ns

11:31 fliebel: what is the normal way of compiling or running a clj file? my clj script is not working and the getting started pages talk only about repl.

11:32 somnium: http://clojure.org/repl_and_main

11:33 pjstadig: is there a maven repo that contains clojure-contrib-1.0-compat.jar?

11:33 fliebel: somnium: and how about compiling to java?

11:33 somnium: fliebel: ^^ this is the bare minimum a clj script should need to do

11:34 hmm, probably leiningen is easiest

11:34 pjstadig: how is one supposed to setup lein to find clojure-contrib-1.0-compat? i don't see the jar in any of the default repos (central, clojure snapshots, clojars)

11:35 polypus: _fogus_: ty

11:41 fliebel: Am I really supposed to compile Clojure code to Java by running compile form the repl?

11:42 _fogus_: ,(doc compile)

11:42 clojurebot: "([lib]); Compiles the namespace named by the symbol lib into a set of classfiles. The source for the lib must be in a proper classpath-relative directory. The output files will go into the directory specified by *compile-path*, and that directory too must be in the classpath."

11:43 somnium: fliebel: the ant versions Ive seen just invoke clojure.main and pass "(compile ...)"

11:44 fliebel: thanks… kind of odd though.

11:49 lisppaste8: fogus pasted "Minimal Ant Clojure compile" at http://paste.lisp.org/display/91773

11:49 fliebel: does Clojure have these templates python has, like: "I eat $s apples every $s" % [2 "day"]

11:49 somnium: ,(doc format)

11:49 clojurebot: "([fmt & args]); Formats a string using java.lang.String.format, see java.util.Formatter for format string syntax"

11:49 stuartsierra: fliebel: there's a clojure.lang.Compile class that does that

11:50 fliebel: thanks

11:50 _fogus_: fliebel: L@@k my link above

11:51 fliebel: I noticed, thanks all for helping me out over and over and over etc… again.

11:55 _fogus_: fliebel: Not exactly the same as in ptyhon, but close

11:55 ,(format "I eat %d apples every %s" 2 'day)

11:55 clojurebot: "I eat 2 apples every day"

11:59 DeusExPikachu: when you run a concurrent clojure program on a cluster jvm, does it "just work"? In other words, is there anything special you have to do to get clojure code to work on a cluster?

12:01 esj: DeusExPikachu: I don't think clojure directly supports distributed processing, for that you'd want Erlang

12:02 chouser: or one of the many Java libs that helps support distributed processing

12:14 DeusExPikachu: so basically I need to find a cluster JVM that automatically distributes threads among nodes?

12:14 if I want to not have to make any code changes

12:16 esj: DeusExPikachu: I know nothing about this stuff, but there exists libraries such as http://www.terracotta.org/ that might be able to shed light on the state of the art.

12:18 tolstoy: When I 'require clojure.contrib.logging, I get: java.lang.Exception: Unable to find static field: TRACE in class org.apache.log4j.Level

12:18 Surely that can't be right.

12:22 angerman: technomancy: what's the advantage of starting lein with -client?

12:23 DeusExPikachu: as esj said, terracotta is waht you are looking for. There is a blog somewhere that discusses setting up clojure and terracotta. Google should be able to find it for you

12:23 tolstoy: Ah. Trace is in 1.2.12, and I've 1.2.7.

12:24 DeusExPikachu: yeah I've been reading the site as soon as I asked you guys, was hoping for some firsthand experience, thanks though

13:15 tcrayford: is there an easy way to test if two hash maps are equal?

13:15 (ie have exactly the same keys and vals)

13:16 = doesn't work

13:16 ,(= {:a 1 :b 2} {:a 1 :b 2 :c 3})

13:16 clojurebot: false

13:16 the-kenny: ,(== {:a 1 :b 2} {:a 1 :b 2 :c 3})

13:16 clojurebot: false

13:16 tcrayford: ooh

13:16 weird

13:17 the-kenny: Uhm, they aren't equal. There is one key more in the second

13:17 tcrayford: I want that to return false

13:17 need to go and rephrase my question methinks

13:18 I have a test which passes: (deftest test-new-message

13:18 (is (= (new-message "Tom" "foo")) (struct message "Toom" "foo" (long-now))))

13:18 where new-message is (defn new-message [user text]

13:18 (struct message user text (long-now)))

13:19 chouser: where the values are equal for the keys they have in common?

13:19 tcrayford: except I am calling "Toom" and "Tom"

13:19 and the test still passes

13:20 chouser: I don't get it. Does the test ever fail?

13:20 tcrayford: I don't think so

13:20 and it should

13:20 with different values

13:20 chouser: oh, you want it to fail in the example you gave?

13:20 tcrayford: c

13:20 I altered the example from the proper test

13:21 cheers for the help

13:22 weird, as

13:22 chouser: ,(let [m1 {:a 1, :b 2}, m2 {:a 1, :b 2, :c 3}] (= m1 (select-keys m2 (keys m1))))

13:22 clojurebot: true

13:22 tcrayford: ,(= {:a "Tom" :b 2} {:a "Toom" :b 3})

13:22 clojurebot: false

13:23 hiredman:

13:23 tcrayford: that (is ...) you pasted is not checking for equality

13:24 check the parens on =

13:24 tcrayford: hah

13:25 yeah confirm I was being dumb with parens

13:26 cheers hiredman

13:43 fliebel: What are the advantages of using an unstable version of Clojure?

13:44 slashus2: You get the try out new ideas?

13:44 konr: new (and not proved to be stable) features?

13:44 fliebel: How unstable is unstable?

13:46 konr: well, I'm always using them, and I've never had any problem with any development-version software, but perhaps I'm just lucky

13:48 fliebel: Hmmm, then my only concern is that devel ports in Macports do not get updates very often. What is worsen then using an old development version? That is like the worst of the 2 sides!

13:48 stuartsierra: fliebel: git master branch is pretty stable. git "new" branch is where new features go, it tends to be less stable and change more frequently.

13:49 fliebel: How old is 20091128? Wait… that looks to much like a date to me...

13:49 hiredman: jeez

13:49 ancient history :P

13:49 devlinsf: rhickey: Question for 1.1. Is juxt going to change name in the future, or is the name now fixed? Use (doc juxt) to see what I am refering to.

13:50 Chousuke: (doc juxt)

13:50 clojurebot: "([f] [f g] [f g h] [f g h & fs]); Alpha - name subject to change. Takes a set of functions and returns a fn that is the juxtaposition of those fns. The returned fn takes a variable number of args, and returns a vector containing the result of applying each fn to the args (left-to-right). ((juxt a b c) x) => [(a x) (b x) (c x)]"

13:51 devlinsf: *clojure-version*

13:51 ,*clojure-version*

13:51 clojurebot: {:interim true, :major 1, :minor 1, :incremental 0, :qualifier "alpha"}

13:53 rhickey: devlinsf: I don't know - I expected more complaints about juxt

13:54 devlinsf: rhickey: Any problem keeping the name?

13:55 fliebel: What is the difference between next and rest? From the doc it seems the only difference is the one possibly returns nil.

13:55 polypus: is there any emacs support for lein?

13:55 Chousuke: fliebel: next is less lazy :)

13:56 polypus: emacs integration is really what i mean

13:56 fliebel: chousuke: let's go for rest then, as long as I don't have to test it's content.

14:03 defn: bah no wonder s halloway's clojure talk at rubyconf 2009 isnt online yet

14:03 confreaks just told me they had a bunch of syncing issues

14:04 whoa holy shit

14:04 intel is buying invidia

14:04 nvidia

14:05 fliebel: So, finally Intel boards without GMA?

14:05 defn: it makes good sense

14:08 KirinDave_: I also imagine intel wants some of that go-juice for their new designs.

14:08 Micro-graphics-card as a parallel arithmetic assist. An altivec for the new millennium. :)

14:08 DeusExPikachu: link?

14:09 devlinsf: rhickey: My thought on juxt is that if it isn't mature enough to have a frozen name, it isn't mature enough to be in 1.1

14:09 rhickey: Conversely, if it is mature enough to be in 1.1, people must be used to the name

14:09 hiredman: defn: actually, or just cringley's speculation?

14:10 defn: speculation still i guess, but it wouldn't be a shock if it were true

14:11 fliebel: woa! Clojure got stuck…

14:12 ,(let (def t '(str "joi" "bla")) (keyword (name (first t)))

14:12 clojurebot: EOF while reading

14:12 fliebel: sorry :$

14:13 bjorkintosh: Xach> bjorkintosh: #clojure can give you a case for clojure.

14:13 is clojure anything like sbcl?

14:13 ... or such?

14:13 defn: it's a lisp...

14:13 the-kenny: bjorkintosh: Clojure is another lisp dialect. Like Common Lisp is one.

14:13 ohpauleez: that is particularly good at concurrent things

14:13 the-kenny: SBCL is an implementation of the common lisp spec.

14:13 defn: and uses the JVM

14:14 the-kenny: ...and runs in the jvm

14:14 bjorkintosh: ah ...

14:14 defn: :)

14:14 bjorkintosh: so clojure is more like erlang then?

14:14 hiredman: ~rationale

14:14 clojurebot: rationale is http://clojure.org/rationale

14:14 defn: no not really

14:14 polypus: not really like erlang

14:14 defn: there are hints of erlang in clojrue

14:14 clojure*

14:14 polypus: in process concurrency

14:14 bjorkintosh: hmm.

14:14 ohpauleez: it feels lightweight, it has a "hack as I think" feeling like python for me personally

14:14 polypus: but even w/o the concurrency stuff io it's the nicest lisp i've seen

14:15 s/io/imo

14:15 defn: it's my first lisp and im enjoying it

14:15 the-kenny: polypus: Yes, I think so too

14:15 bjorkintosh: so it isn't possible to harness all the computers at a lab to run a clojure program concurrently?

14:15 defn: learning some elisp in tandem and its been a good experienc

14:15 bjorkintosh: sure

14:15 bjorkintosh: it is?! cool!

14:15 ohpauleez: I was a die hard CL lover, and did most of my work and enjoyment project in Python

14:15 and Clojure is easily becoming my favorite language

14:15 bjorkintosh: that's what i meant by the erlang comparison.

14:16 gravity: bjorkintosh: You'd need to use something like hadoop to do it

14:16 the-kenny: bjorkintosh: Clojure isn't designed around this "My program can run on then tousand machines at once" like erlang is. But it's possible.

14:16 defn: bjorkintosh: clojure has agent-based concurrency

14:16 the-kenny: s/then//

14:16 pjstadig: I'm blowing stack and I don't know why

14:16 bjorkintosh: but how does the concurrent bit work?

14:16 is there something to read on that?

14:16 defn: better to read about it than have us explain it

14:16 slashus2: It isn't really about distributed concurrency as much as shared memory concurrency. There are java libraries that will allow you to do that though.

14:16 defn: http://clojure.org/concurrency

14:16 pjstadig: i have a collection of 7393 collections that i'm trying to concatenate together

14:16 defn: oops bad link

14:16 konr: Is there a way to make SLIME automatically add /foo/lib/*jar to the classpath, when editing some file from /foo/src/?

14:17 defn: http://clojure.org/refs, http://clojure.org/agents, http://clojure.org/agents

14:17 bjorkintosh: hmm. hadoop...

14:17 pjstadig: ,(reduce concat (map (constantly (vector 1 2 3)) (range 0 7393))

14:17 clojurebot: EOF while reading

14:17 bjorkintosh: okay.

14:17 pjstadig: ,(reduce concat (map (constantly (vector 1 2 3)) (range 0 7393)))

14:17 clojurebot: Eval-in-box threw an exception:java.lang.StackOverflowError

14:17 the-kenny: konr: Use leiningen or swank-clojure-project

14:17 DeusExPikachu: bjorkintosh: a big part of clojure over CL is first class datastructures besides the list

14:17 ohpauleez: pjstadig: is there a reason for not doing it lazily? Are calculating these things?

14:17 defn: konr: yeah listen to the-kenny, leiningen + clojars + swank-clojure = pure win

14:17 bjorkintosh: do hadoop and clojure play nicely together?

14:18 the-kenny: defn: Yes, exactly :)

14:18 defn: i believe someone wrote something to do hadoop stuff with clj

14:18 pjstadig: ,(reduce lazy-cat (map (constantly (vector 1 2 3)) (range 0 7393)))

14:18 clojurebot: java.lang.Exception: Can't take value of a macro: #'clojure.core/lazy-cat

14:18 slashus2: Clojure allows for wrapper free access to java libraries.

14:18 defn: bjorkintosh: http://github.com/stuartsierra/clojure-hadoop

14:18 pjstadig: ,(reduce #(lazy-cat %1 %2) (map (constantly (vector 1 2 3)) (range 0 7393)))

14:18 clojurebot: Eval-in-box threw an exception:java.lang.StackOverflowError

14:19 bjorkintosh: okay.

14:19 DeusExPikachu: its got great standardized reader macros too, makes code concise

14:19 * the-kenny thinks clojurebot is a bit annoying if there's a conversation going on

14:19 pjstadig: i guess i would be fine with a lazy sequence if I could figure out how to get it to work

14:19 defn: lazy-seq

14:19 pjstadig: besides it shouldn't blow stack doing a reduce should it?

14:19 DeusExPikachu: especially for coding macros

14:19 pjstadig: i would expect to maybe run out of memory

14:20 bjorkintosh: so are clojure and commonlisp close enough that the examples from the books i have on common lisp can be implemented in it?

14:20 the-kenny: bjorkintosh: Yes, except for reader macros

14:20 stuartsierra: bjorkintosh: no

14:20 bjorkintosh: reader macros. okay.

14:20 stuartsierra: I mean, you can implement all the same things, but the syntax and names will be different.

14:21 DeusExPikachu: bjorkintosh: I'd say so, coming from Pratical Common Lisp

14:21 pjstadig: defn: how would i use lazy-seq?

14:21 bjorkintosh: cool.

14:21 DeusExPikachu: if you need a reference, someone went ahead and ported the PCL code to clojure, just google it up

14:22 bjorkintosh: i'm apt-get-ing clojure right now.

14:22 the-kenny: bjorkintosh: The biggest difference is the persistence in data structures.. you can't change for example a map, but you'll get a copy of the back with the element added back from assoc. Like in Haskell

14:22 bjorkintosh: is there a nice IDE for it?

14:22 the-kenny: emacs + slime

14:22 (+ leiningen)

14:22 DeusExPikachu: I use slime, clojure-mode

14:22 bjorkintosh: oh. nothing vim-ey like?

14:22 (emacs makes me cry)

14:23 defn: and yet you use parentheses to explain your disgust

14:23 the-kenny: my experience is, that hacking lisp in vim is very painful

14:23 bjorkintosh: hehehe

14:23 gbt: there is vim-clojure, but I've not tried it

14:23 defn: i tried using vim with clojure, many people use it in here, but i found the swank-clojure stuff to be such an incredibly powerful tool that i learned emacs and havent looked back

14:24 DeusExPikachu: I can't live without paredit mode

14:24 bjorkintosh: i'm an agnostic, but i prefer to think the world was created in vi. (hides)

14:24 defn: paredit is very nice as well

14:24 bjorkintosh: tools are tools

14:24 fliebel: What does it mean when I get a java.lang.NullPointerException in Clojure?

14:24 defn: pick what you want and go for it, but personally emacs was made for lisp hacking

14:24 the-kenny: I've learned Emacs just for Common Lisp and now I use it for everything from LaTeX to ToDo-Management (org-mode ftw!)

14:24 defn: org-mode > *

14:24 bjorkintosh: *sigH*

14:24 defn: and yeah, latex is so nice

14:24 the-kenny: defn: Exactly :)

14:25 bjorkintosh: you poor things. tools are tools, as defn said.

14:25 defn: mobileorg is quite cool also :)

14:25 the-kenny: defn: I'm thinking about writing a parser for org-mode in clojure

14:25 defn: have you seen babel?

14:25 chouser: why is the frequency of editor conversations going up!?

14:25 bjorkintosh: okay.

14:25 the-kenny: defn: babel?

14:25 defn: it's in org-mode's contrib

14:25 fliebel: chouser: partly because of me....

14:25 bjorkintosh: so how does clojure talk to the jvm? i'm at the prompt... is that it?

14:26 chouser: bjorkintosh: depends on what you want to tell the JVM.

14:26 gravity: bjorkintosh: clojure is compiled to jvm bytecode

14:26 bjorkintosh: ah okay.

14:26 defn: the-kenny: http://orgmode.org/worg/org-contrib/babel/org-babel.php

14:26 there is support for clojure now :)

14:26 the-kenny: defn: Woah, cool :)

14:26 bjorkintosh: i think i'll use it for a while to see how it wears.

14:26 the-kenny: defn: But I was thinking about an external parser, written in clojure

14:26 fliebel: bjorkintosh: you can also do aot compiling and run scripts of course.

14:26 DeusExPikachu: the blip.tv talks are good too

14:27 defn: the-kenny: sure, different story, but i just thought id pass that along since it seemed sort of related

14:27 the-kenny: defn: Yeah, maybe it's helpful :)

14:27 Thanks

14:27 defn: the-kenny: i was thinking something like a little blogging platform similar to jekyll that runs on clojure and org-mode

14:27 pjstadig: ,*clojure-version*

14:28 clojurebot: {:interim true, :major 1, :minor 1, :incremental 0, :qualifier "alpha"}

14:28 fliebel: defn: Woa, I wanted to do just that… not sure about the org-mode though. But at least something liek Jekyll

14:28 defn: fliebel: got a repo?

14:28 pjstadig: am I wrong in thinking that reduce shouldn't blow stack?

14:29 fliebel: defn: nope, I'm trying to learn Clojure first.

14:29 defn: im thinking compojure + lein

14:29 the-kenny: hm.. I'm just learning Markdown for blog-posts and such things

14:29 defn: fliebel: cool well, buzz me if you're working on anything

14:29 and ill do the same

14:29 fliebel: sure :)

14:29 defn: i started a repo last night to do some compojure stuff, my first experience with lein + clojars

14:29 pretty awesome

14:30 somnium`: ! google chrome for linux released

14:30 defn: pjstadig: i dont think you're wrong, but that code doesn't seem "right" to me for some reason

14:30 fliebel: defn: I have been trying to make my own template language for ages now… but I'd possible use the one in contrib for the final thing.

14:30 somnium: now for the mac version...

14:30 defn: fliebel: the html templating stuff?

14:31 like (html-tree [:h1 "hello"]) ?

14:31 fliebel: defn: yea, that one...

14:31 defn: yeah thats what im playing with

14:32 fliebel: defn: I made something like that in Python a while back.

14:32 http://metapep.wordpress.com/2009/10/04/pymlpython-markup-language-template-engine/

14:33 Then I decided to learn Clojure and make my CMS with that instead.

14:33 defn: It's pretty neat: I was just messing with some really basic stuff last night: (defn default-layout [title, content-tree] (html-tree [:html [:head [:title title] [:body content-tree]]]))

14:33 someting like that

14:34 and then you can (html (default-layout "home" [:h1 "Home"]))

14:34 or somesuch

14:34 fliebel: Is that instantly converted to a string, or more in the lazy and editable way?

14:34 chouser: pjstadig: generally, reduce should not blow the stack, at least not by itself.

14:34 defn: fliebel: i believe it's converted to a string right away, but i dont really know that much about it yet tbh

14:34 ,(html-tree [:h1 "abc")

14:35 clojurebot: Unmatched delimiter: )

14:35 defn: oops

14:35 ,(html-tree [:h1 "abc])

14:35 clojurebot: EOF while reading string

14:35 defn: bahhh!

14:35 ,(html-tree [:h1 "abc"])

14:35 clojurebot: java.lang.Exception: Unable to resolve symbol: html-tree in this context

14:35 pjstadig: chouser: so i think this is a general case, does this mean its a bug?

14:35 defn: i give up on life

14:35 fliebel: defn: That is one of the key points for me. make a template, fiddle with it and then print it.

14:35 defn: ,(use 'compojure)

14:35 clojurebot: java.io.FileNotFoundException: Could not locate compojure__init.class or compojure.clj on classpath:

14:36 defn: fliebel: yeah it's easy enough, pretty easy to template with

14:36 chouser: pjstadig: you have a small test case we can look at?

14:36 fliebel: defn: I even had basic xpath in my Python lib.

14:36 defn: cool

14:36 pjstadig: ,(reduce concat (map (constantly (vector 1 2 3)) (range 0 7393))

14:36 clojurebot: EOF while reading

14:36 pjstadig: ,(reduce concat (map (constantly (vector 1 2 3)) (range 0 7393)))

14:36 clojurebot: Eval-in-box threw an exception:java.lang.StackOverflowError

14:37 defn: i get an awfully weird stack trace when i run that code pjstadig

14:37 pjstadig: may depend on the JVM config, but you can bump the range down to 1900

14:37 chouser: ,(let [x (reduce concat (map (constantly (vector 1 2 3)) (range 0 7393)))])

14:37 clojurebot: nil

14:37 pjstadig: ,(reduce concat (map (constantly (vector 1 2 3)) (range 0 1900)))

14:37 clojurebot: Eval-in-box threw an exception:java.lang.StackOverflowError

14:38 chouser: pjstadig: reduce is not blowing the stack.

14:38 pjstadig: ,(let [x (reduce concat (map (constantly (vector 1 2 3)) (range 0 1900)))])

14:38 clojurebot: nil

14:38 pjstadig: ,(let [x (reduce concat (map (constantly (vector 1 2 3)) (range 0 1900)))] x)

14:38 clojurebot: Eval-in-box threw an exception:java.lang.StackOverflowError

14:38 konr: the-kenny: I installed lein, moved my .jar to /project/lib/, and started swank-clojure-project on /project/, yet /project/myjar.jar is not on the classpath - do I need to add it somehow to project.clj?

14:38 fliebel: defn: In Python objects have a string representation, which allowed me to build the template as some complicated list and then the whole thing shows up as html when printed. Does Clojure objects have a editable representation?

14:38 konr: *project/lib/myjar.jar

14:38 pjstadig: it's blowing stack when it tries to print i guess

14:38 Chousuke: I suspect it's the concats

14:38 since concat is lazy.

14:38 chouser: pjstadig: the lazy structure being produced by concat blows the stack when you try to get the first element.

14:39 Chousuke: you're generating a whole lot of chunks.

14:39 er.

14:39 thunks

14:39 hiredman: concat is :(

14:39 chouser: ,(reduce concat (map #(list %) (range 1e4)))

14:39 clojurebot: Eval-in-box threw an exception:java.lang.StackOverflowError

14:39 pjstadig: so it blows stack trying to realize the lazy seq

14:40 chouser: try (apply concat ...) instead

14:40 pjstadig: ,(apply concat (map (constantly (vector 1 2 3)) (range 0 1900)))

14:40 clojurebot: (1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2 3 1 2

14:40 pjstadig: k

14:41 the-kenny: konr: hm... should work. Maybe ask the author of swank-clojure-project?

14:41 defn: (def fooseq (lazy-seq (repeat (vector 1 2 3)))

14:41 does that work at all?

14:41 the-kenny: s/-project//

14:41 defn: or are we stuck with the same problem

14:41 Chousuke: defn: the lazy-seq there is redundant

14:41 chouser: defn: doesn't produce the same output.

14:42 fliebel: What does it mean in Clojure if I get a java.lang.NullPointerException?

14:42 hiredman: ,(.foo nil)

14:42 the-kenny: konr: You can also check the contents of (get (System/getProperties) "java.class.path")

14:42 clojurebot: java.lang.NullPointerException

14:42 the-kenny: (That'll get you the classpath of the running clojure instance)

14:42 Chousuke: fliebel: exactly what it means in java :)

14:43 fliebel: nil is java null

14:43 fliebel: chousuke: So I did a function call somewhere without a proper argument?

14:43 Chousuke: fliebel: yeah. or a method call.

14:43 hiredman: always a method a call

14:44 fliebel: what si the difference between function and method?

14:44 hiredman: at the bottom an NPE means you called a method on null

14:44 konr: the-kenny: It's strange... perhaps my swank is not configured right. Thanks!

14:44 Chousuke: fliebel: functions mean clojure functions, methods are java methods (interop)

14:44 _fogus_: ,(+ 1 nil)

14:44 clojurebot: java.lang.NullPointerException

14:44 defn: chouser: that does produce the same output

14:44 the-kenny: konr: Where do you get the not-in-classpath-thing in clojure?

14:45 _fogus_: nil could also be an argument

14:45 Chousuke: fliebel: behind the scenes though a function call is also a method call but that's an implemetation detail :)

14:45 defn: (= (apply concat (map (constantly (vector 1 2 3)) (range 0 1900))) (reduce concat (take 1900 fooseq)))

14:45 =>true

14:45 fliebel: chousuke: http://pastebin.com/m7ee2fd0

14:46 chouser: ,(first (lazy-seq (repeat (vector 1 2 3)))

14:46 fliebel: I think it's line 11

14:46 clojurebot: EOF while reading

14:46 chouser: ,(first (lazy-seq (repeat (vector 1 2 3))))

14:46 clojurebot: [1 2 3]

14:46 hiredman: _fogus_: I think if you follow + down the call chain you will find a method being called on nil

14:46 Chousuke: fliebel: resolve is returning nil

14:46 chouser: defn: the lazy-seq/repeat example returns a list of vectors. The apply and reduce concat examples return a list of numbers.

14:47 konr: the-kenny: Well, my library is not in java.class.path, and I get a class not found exception when I try to use one of its classes

14:47 Chousuke: fliebel: you don't have an "a" fucntion

14:47 defn: chouser: ah, ok, thanks

14:47 fliebel: chousuke: that is supposed to tigger the else case...

14:47 defn: what are all the bit twiddling forms in clojure?

14:48 Chousuke: ,(fn? nil[D[D[D[C[C[C[C[C[C[C[C[C  [A[B[A   [A[B[A[A  )

14:48 clojurebot: Unmatched delimiter: )

14:48 Chousuke: eh

14:48 _fogus_: hiredman: I think in that case the nil is an argument to an Integer ctor

14:48 Chousuke: ,(fn? nil)

14:48 clojurebot: false

14:48 Chousuke: ,(fn? @nil)

14:48 clojurebot: java.lang.NullPointerException

14:48 Chousuke: there

14:49 hiredman: _fogus_: basically a method call :P

14:49 Chousuke: can't deref nil

14:49 fliebel: chousuke: so, how do I do a proper test for an existing function?

14:49 Chousuke: fliebel: check whether resolve returns nil

14:49 _fogus_: hiredman: If you want me to say you're right, then OK. You're right. ;)

14:50 fliebel: chousuke: I don't even know how to make an && in clojure :$

14:50 Chousuke: (doc and)

14:50 clojurebot: "([] [x] [x & next]); Evaluates exprs one at a time, from left to right. If a form returns logical false (nil or false), and returns that value and doesn't evaluate any of the other expressions, otherwise it returns the value of the last expr. (and) returns true."

14:50 jasapp: defn: (doc-find "bit") ?

14:50 defn: jasapp: i found it, thanks :)

14:50 jasapp: oops

14:51 (find-doc ...

14:51 defn: i just got Hacker's Delight so I'm gearing up for bit twiddling fun with clj

14:51 fliebel: thanks! once you learn to think the lisp way everything becomes so obvious.

14:51 stuartsierra: defn: be aware, bit twiddling in Clojure is slow compared to Java

14:51 jasapp: really, how come?

14:51 defn: stuartsierra: is that a permanent fact, or the temporary situation?

14:52 Chousuke: defn: hopefully temporary.

14:52 defn: what's the reasoning behind it?

14:52 out of curiosity

14:53 and by slower, how much?

14:53 Chousuke: defn: boxing probably.

14:54 fliebel: chousuke: This is how far I can get… (if (and (resolve (first func)) (fn? @(resolve (first func))))

14:54 Chousuke: fliebel: that should do it.

14:55 fliebel: chousuke: Caused by: java.lang.IllegalArgumentException: Don't know how to create ISeq from: Character

14:56 Chousuke: fliebel: you have an error someplace else I guess.

14:56 because that looks just fine to me.

14:56 fliebel: you see what I mean by unhelpful error messages?

14:56 Chousuke: fliebel: you can't map html btw

14:56 it's a mcro.

14:56 macro*

14:56 fliebel: ah… :(

14:57 defn: so this is my first experience with bit twiddling: the following formula can be used to test if an unsigned integer is of the form 2^n - 1: x & (x + 1)

14:57 how would you implement this in clojure?

14:57 stuartsierra: defn: temporary, I hope

14:58 fliebel: chousuke: thanks for saving me again :P

14:58 Chousuke: (bit-and x (inc x))? /

14:59 defn: lol duh, i tried a couple tests and it didnt look like it was working, but it is

14:59 thanks Chousuke

15:00 fliebel: Is there something like recursive macros?

15:00 defn: (recur) ?

15:00 oh, macros, hmm, i dont know

15:01 Chousuke: fliebel: yes.

15:01 ~def ->

15:01 fliebel: like (macro (some-other-macro))

15:01 defn: did (->) come before (..) or was it vice versa?

15:01 somnium`: ,(macroexpand (->> (range 5) (map inc) (map dec)))

15:01 clojurebot: (0 1 2 3 4)

15:01 somnium`: ,(macroexpand '(->> (range 5) (map inc) (map dec)))

15:01 clojurebot: (map dec (clojure.core/->> (range 5) (map inc)))

15:05 fliebel: I try to make this recursive: http://pastebin.com/m2f9cba4b (so that "boe" can be another expression that is treaded just like func)

15:06 But I guess it's time to sleep *yawn*

15:06 Oh, one more thing: Because strings are immutable, does that mean string concatenation is slow?

15:10 cark: fliebel : yes, use a StringBuilder when you need speed

15:10 fliebel: cark: what is that?

15:11 cark: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/StringBuilder.html

15:11 chouser: (apply str ...) uses a StringBuilder internally

15:11 cark: or (apply str my-seq-of-strings)

15:12 Chousuke: there's usually no need to use stringbuilder explicitly.

15:12 since str uses it.

15:13 fliebel: ok, thanks :) I'm off to my bed… Bye!

15:15 polypus: are namespaces on clojure anything like package names in java where there a.b.c maps to a directory hierarchy a/b/c?

15:16 jasapp: is using StringBuilder really faster than concat?

15:16 http://pastebin.com/m50c24ade

15:16 or is my test case not big enough to see advantages?

15:17 stuartsierra: polypus: yes

15:17 jasapp: concat is for sequences, not strings

15:17 ,(concat "foo" "bar")

15:18 clojurebot: (\f \o \o \b \a \r)

15:18 polypus: stuart: ty. so why does lein set the top level ns to <project-name>.core? why isn't it just <project-name>

15:19 shr3kst3r: ,(str "foo" "bar")

15:19 clojurebot: "foobar"

15:19 stuartsierra: polypus: I guess lein assumes multiple namespaces in a project

15:19 don't know about lein

15:19 jasapp: ahh

15:20 the-kenny: polypus: technomancy is the guy you want to talk with :)

15:22 polypus: i'm not a java hacker so i'm a bit confused about how i should be naming my namespaces. lwt's say i have a project foo. with directory structure foo, foo/src, foo/src/foo.clj, foo/src/foo/bar.clj. are there any conventions that i should be following with respect to namespace names in foo.clj & bar.clj?

15:23 s/lwt/let

15:23 the-kenny: src/foo/bar.clj is (ns foo.bar)

15:23 chouser: polypus: it's normal, if a bit inconvenient, to use a globally unique name for your namespace and/or java package name

15:24 so perhaps org.polypus.foo

15:24 the definition for such a namespace foo should be in a file org/polypus/foo.clj

15:25 you might stick that in a src dir, so perhaps foo/src/org/polypus/foo.clj

15:25 then you can add foo/src to your classpath and (require 'org.polypus.foo) to load your namespace.

15:26 polypus: chouser: ty

15:27 chouser: np

15:28 technomancy: polypus: it uses foo.core since you can't AOT single-segment namespaces

15:29 polypus: so under this scheme my bar.clj file would be under foo/src/org/polypus/foo/bar.clj and have namespace org.polypus.foo.bar?

15:29 technomancy: ty

15:30 lisppaste8: dakrone pasted "I thought multiple definitions were allowed?" at http://paste.lisp.org/display/91782

15:31 dakrone: are multiple arg# definitions not allowed (like what I pasted?)

15:31 ska2342: dakrone: I think you're missing an extra pair of parens

15:32 defn: im new to building packaged applications and such, im using leiningen right now, but basically i have src/dejure/ and src/dejure.clj, im working on a compojure project -- where would i put something like say...an images/ folder or a public/ folder?

15:32 does that stuff all go in the project root?

15:32 dakrone: ska2342: do I need a paren-thize (?) both definitions, or each individually?

15:32 technomancy: polypus: there's no need in Clojure to use something like org.polypus

15:32 polypus: dakrone: (defn f ([...] ...) ([...] ...))

15:32 technomancy: that's a java convention you see carried over, but it's not helpful

15:33 ska2342: dakrone: take a look at the example on http://clojure.org/special_forms where fn is described

15:33 technomancy: polypus: and it can be very annoying if you try to hand off maintainership of a project

15:33 dakrone: polypus & ska2342 okay, that was my problem, thanks guys/girls

15:33 technomancy: oh hah; here I am directly contradicting chouser.

15:33 * the-kenny uses projectname.something

15:33 _fogus_: What?!? There are girls here?

15:33 technomancy: obviously there is no consensus about this

15:33 the-kenny: (something = the file, the module of the project)

15:33 s/the/one/

15:34 technomancy: but I feel that the domain-name-as-namespace convention is an annoyance

15:34 anyway, if your project name is not enough to make your namespace unique then you have bigger problems to deal with

15:34 like finding a better project name

15:34 chouser: hm

15:34 ska2342: (count (filter is-girl people-in-hash-clojure))

15:34 defn: technomancy: is there a good place to learn the basics of structuring lein projects past the initial configuration.. i ran lein new myprojname, im trying to figure out where to place things like a public directory, stylesheets, images, etc. for a compojure project

15:35 does that stuff go in src/, or in the proj. root?

15:35 technomancy: defn: put it in resources/

15:35 the-kenny: defn: Look at the readme :)

15:35 technomancy: that was added right before the 1.0 release

15:35 defn: oh cool, thanks

15:36 lisppaste8: dakrone pasted "why is abs randomly not available?" at http://paste.lisp.org/display/91783

15:36 technomancy: polypus: maybe since chouser is writing a book called "idiomatic Clojure" you should listen to him instead of me; dunno. =)

15:36 polypus: :)

15:37 dakrone: can anyone tell me why the call to Math/abs is resolving sometimes, but not others?

15:37 the-kenny: dakrone: Could you show us the code?

15:37 dakrone: the-kenny: sure

15:37 lisppaste8: dakrone annotated #91783 "the whole code" at http://paste.lisp.org/display/91783#1

15:38 polypus: technomancy: i'm still a bit confused. you have <proj>.core but the directory structure does not mirror this. why can you get away with this?

15:38 the-kenny: dakrone: ah, got it. Add a type-annotation

15:38 dakrone: the-kenny: oh okay, so it's the duck-typing that's confusing it?

15:39 the-kenny: It calls abs with reflection and it looks like the type of one argument on a call is changing and there isn't an abs for this type of args defined

15:39 dakrone: I think so. Just try it

15:39 And (set! *warn-on-reflection true), so you'll get warnings if some java-call goes through reflection :)

15:39 s/ion/ion*/

15:40 dakrone: the-kenny: I replaced the line with (/ (reduce + (map (fn [#^Double n] (Math/abs (- n average))) list-of-nums)), but I still get the same error

15:41 defn: technomancy: just a suggestion, but for a `lein new project`, I keep having to reformat the project.clj from the single line to a more readable/editable version

15:41 any plans to make that indented properly on init?

15:41 the-kenny: defn: hmhm... I have no idea then.. sorry

15:42 cark: ,(doc double)

15:42 clojurebot: "([x]); Coerce to double"

15:43 dakrone: cark: okay, wrapping the (- n average) in double did the trick

15:44 hiredman: it seems like if you set java.system.class.loader to something like http://gist.github.com/251980 adding classes, jars, etc at runtime wouldn't be a problem

15:44 dakrone: cark: thanks

15:45 chouser: technomancy: it might be worth having a discussion about project name layouts

15:45 I certainly have no love for the extra directory level required by com/org

15:45 the-kenny: hiredman: It would be really cool if something like this would be in clojure itself :)

15:46 ska2342: dakrone: I think average is sometimes a ratio and Math/abs doesn't know how to deal with them. It should suffice to coerce average to double. Could you try?

15:46 dakrone: ska2342: yep, cark suggested that and it fixed the problem

15:46 hiredman: the-kenny: I dunno if it actually solves whatever the problem is

15:46 dakrone: ska2342: you're right, I totally forgot that average is sometimes a ration

15:46 *ratio

15:46 ska2342: ,(Math/abs 3/2)

15:46 clojurebot: java.lang.IllegalArgumentException: No matching method found: abs

15:47 hiredman: I'm throwing it out there and hopefully someone will say "yes it does"

15:47 chouser: technomancy: but surely having people at org.clojure maintain a project whose name happens to be net.n01se.foo is less of a problem (is it really any problem at all) than for two groups who have no knowledge of each other to each build libs named, oh I don't know, "statistical"

15:47 ska2342: this gives reason to having clojure-built-in abs, no?

15:47 chouser: the latter case causing really painful issues for anyone trying to have both in the same classpath.

15:48 slyrus: hiredman: is that a prototype swank-class-loader?

15:48 dakrone: ska2342: I agree, having a built-in would be nice

15:48 hiredman: slyrus: I don't know, I barely have swank working

15:49 I do have the gist posting thing in emacs working, I guess

15:49 slyrus: works for me... i even finally managed to get incanter working with slime

15:51 technomancy: chouser: right, but why would you have two groups with no knowledge of each other?

15:51 chouser: because the world is a big place?

15:51 technomancy: seems like picking a project name is a task that deserves some thorough research

15:52 hiredman: if this system classpath thing works, add-classpath could be rejiggered to check to see if the system classloader is clojure friendly and error out if it isn't

15:52 technomancy: chouser: maybe for internal projects you could make that case

15:52 but I don't see how it makes sense for open source

15:52 hiredman: I mean, I have tried it, and it in my very limited testing it works

15:52 technomancy: Google's index makes the world a lot smaller than it used to be. =)

15:52 chouser: technomancy: what about an internal project that goes open source later?

15:53 conversely, once a project is named org.something, why ever change it? I don't see a problem (other that the extra directory level)

15:53 technomancy: sure, open-sourcing a project is probably not a good reason to rearrange the directory layout

15:54 the-kenny: Is there a slime-command to shutdown the in emacs running lisp-process? Always killing *inferior lisp* is annoying

15:54 technomancy: but really the collision would only exist if two similarly-named private projects both decided to open their codebases

15:54 LauJensen: the-kenny: in the repl, hit ,q

15:54 technomancy: it's pretty edge-casey

15:54 the-kenny: ,q?

15:54 clojurebot: java.lang.Exception: Unable to resolve symbol: q? in this context

15:55 technomancy: defn: there's a TODO for prettyprinting project.clj; yeah

15:55 defn: cool

15:55 technomancy: but the contrib prettyprinter doesn't really look all that great

15:55 the-kenny: LauJensen: ahhhh I totally forgot about this ,-thing. Thanks!

15:56 LauJensen: np :)

15:56 ska2342: the-kenny: the slime REPL buffer has a shortcut-key (,) which can be used to access a few functions. I seem to remember that it only works at the beginning of a new REPL line. BTW: ,s (sayoonara) does the same.

15:56 try , TAB for a list

15:56 clojurebot: for is not used enough

15:57 the-kenny: ska2342: Yes, I used this with common lisp some time I ago. I just forgot it was there.

15:57 polypus: why is it alright to have proj-name.core at the top level of src. why does asking for this ns by way of :use or :require even work? from what chouser said i'd expect the directory structure to be proj-name/core.clj

15:57 cark: what's not to like about c.c.pprint ?

15:57 besides speed

15:57 ska2342: the-kenny: wouldn't it be nice to load a contrib-lib like you could with asdf-systems? :-)

15:57 the-kenny: ska2342: Yes :)

15:58 churib: wow, didnt knew the ,-thing

15:58 hiredman: polypus: proj_name/core.clj actually

15:58 technomancy: cark: I just meant that the output it produces in this particular case doesn't match what a human would do

15:58 polypus: that's a bug

15:58 the new task on leiningen was ... not well-tested for the 1.0 release

15:58 we should have 1.0.1 out in a couple days

15:58 the-kenny: But I mainly needs this if I've added a new lib to my project and don't want to restart my repl

15:59 ska2342: cool: , change-package seems to work

15:59 technomancy: ska2342: see also C-c M-p from a clojure buffer to change the repl namespace

15:59 polypus: hiredman: ahh so rewrite - as _? is this a java thing?

16:00 technomancy: so the behaviour will change with 1.0.1?

16:00 ska2342: technomancy: he, never used that in my CL days, or else it dropped off the memory

16:00 the-kenny: Btw. should M-x slime-list-threads work with swank-clojure?

16:00 I think it would be a nice thing to have

16:01 eno: anyone has idea why I get this error trying to run lein generated jar (not uberjar)? http://paste.lisp.org/display/91786

16:01 technomancy: the-kenny: it would... just nobody's gotten around to porting it yet

16:01 the-kenny: eno: is clojure.jar in your classpath?

16:01 technomancy: eno: try lein deps first

16:01 the-kenny: technomancy: hm okay. Maybe I will :)

16:02 eno: "lein deps" returns without anything

16:02 the-kenny: I put clojure-....jar explicitly in java -cp

16:02 patrkris: i've noticed that clojure-projects often build a project-source.jar file... what's that used for?

16:02 the-kenny: eno: and clojure.jar itself?

16:04 eno: the-kenny: tried java -cp ~/.clojure/clojure.jar:lib/clojure-1.1.0-alpha-20091126.000150-7.jar:lib/clojure-contrib-1.0-20091208.130239-27.jar

16:04 same error

16:04 rullie: hi folks, i'm a noob

16:05 eno: OTOH, hello-standalone.jar runs fine

16:05 technomancy: eno: ah; -jar and -cp are mutually-exclusive

16:05 java -jar is only good for standalones; that's just how java works.

16:05 eno: ah ok

16:06 rullie: is it safe to say you can use all existing java libs in cljure?

16:06 polypus: rullie: yes

16:06 cark: i don't think so ... some need annotations

16:07 rullie: what about generics and such

16:07 ska2342: cark: oh, they cause a problem? Never thought about that. Do you have any reading material on this at hand?

16:08 cark: with type erasure generics are no problem i think

16:08 polypus: does clojurebot have paste.lisp.org support?

16:08 eno: probably should use "java -cp clojure.jar:helloworld.jar main.Class"

16:09 the-kenny: Is there a way to show the differences between the saved version of a file and the modified file in emacs?

16:10 LauJensen: For those of you who use ClojureQL and have been annoyed with the lack of a persisted global connection, its now added :)

16:11 the-kenny: hah, got it. diff-buffer-with-file :)

16:13 rullie: don't remember what you typed? :p

16:14 so how does clojure handle generics?

16:15 the-kenny: rullie: Yes, I was working on some files and couldn't remember that I've worked on that file.. but I could have made important changes to it

16:16 cark: rullie : it doesn't, there is no need as clojure is dynamically typed

16:16 ska2342: the-kenny: that reminds me that I wanted an ediff session for unsaved changes for ages. Never got across the prototype stage, though :-(

16:16 rullie: cark: what i meant is how does it work with libs that do have generics in it

16:16 lpetit: Hello

16:16 cark: nothing special about it, just use as usual

16:17 the-kenny: rullie: Iirc, generics are removed at compile-time.

16:17 There are just type annotations to the compiler

16:17 eno: rullie: type erasure

16:17 rullie: ok, that's great

16:17 cark: well no it sucks =) .net is better in that respect

16:17 but good for clojure yes =)

16:18 rullie: great as in no need to worry about them in clojure

16:18 the-kenny: cark: C++ is better in that too :D

16:18 Templates > Generics

16:18 lpetit: rhickey: would like to know what you have in mind concerning the future of the ad-hoc hierarchy mechanisms currently in place for multimethods. And also if you want (or is it already done ?) to bridge the 2 "types" concepts ?

16:20 cark: i don't know c++ much, are generics and templates solving the same problems, or do they just have a slight overlap ?

16:21 the-kenny: cark: templates are mostly used like generics, but the types aren't dropped at compile time.

16:22 hiredman: grrr

16:22 the-kenny: hiredman: Did I say something wrong?

16:23 hiredman: I somehow end up with missing parens, and paredit won't let me insert a paren

16:23 polypus: yeah that's annoying

16:23 technomancy: hiredman: C-q )

16:23 C-q is "break the rules" mode

16:24 the-kenny: whoa, something's wrong here. swank-clojure-project just started a sbcl-session

16:25 ska2342: the-kenny: nothing wrong with sbcl .. oops, wrong channel ;-)

16:25 the-kenny: maybe you have several slime-lisp-implementations?

16:26 the-kenny: ska2342: Yes, but it worked until now. I just updated swank-clojure to the latest version.

16:26 But it's a special case here.. I don't want to use elpa ;)

16:26 ska2342: the-kenny: I don't use elpa, too. The whole setup feels rather fragile.

16:27 the-kenny: I'll take a quick look at latest commits

16:27 the-kenny: ska2342: Yes, I feel the same

16:28 ska2342: the-kenny: when did you do your last update? The latest commit seems to be from 2009-10-18

16:28 the-kenny: ska2342: Some weeks ago

16:28 3 or so

16:28 I'm a bit lazy at updating because it always breaks something on my setup :D

16:29 ska2342: the-kenny: what is the value of slime-lisp-implementations

16:30 the-kenny: ska2342: the sbcl-part and another part for clojure. I have a custom function run-clojure which starts a clojure-instance, but requiring swank fails there

16:30 ska2342: the-kenny: I always look there first. I set up everything so that slime uses the same clojure-shell-script I can use (and test!) from the command line.

16:31 hiredman: with paredit can I yank an s-expr from where it is and put it somewhere else?

16:31 the-kenny: Maybe I'll drop my setup *again* and start from scratch

16:31 Worked fine the last ~2 times

16:31 KirinDave_: hiredman: Yes.

16:31 ska2342: the-kenny. Ah, requiring swank. That was a problem. I seem to remember to have run mvn package or something and then added the target/swank-clojure-1.0-SNAPSHOT.jar to the -cp

16:31 hiredman: KirinDave_: please explaind how

16:31 KirinDave_: hiredman: Go to the start of the sexpr and hit ctl-k. Then you can yank it out. C-k only does one sexpr, not one line.

16:31 * slyrus thanks paredit really should be on default for all lispy emacs editing modes

16:32 slyrus: hiredman: ^K and ^Y

16:32 hiredman: KirinDave_: C-k does the yanking or sets up for the yanking?

16:32 KirinDave_: hiredman: C-k does the killing.

16:32 hiredman: C-k C-y ?

16:32 KirinDave_: hiredman: And then it's in your kill ring.

16:32 And then you can C-y at any time to yank the most recent kill ring entry out.

16:32 hiredman: I see

16:33 kill-ring

16:33 how superhero like

16:33 technomancy: hiredman: indeed. unfortunately M-x hide-body does *not* do what you might think.

16:33 KirinDave_: You might wanna do the basic emacs tutorials. Things like the kill ring are part of what makes emacs inordinately useful.

16:34 polypus: hiredman: peepcode has a pretty good emacs video too

16:35 the-kenny: Maybe I'll give up and use elpa... technomancy wins! ;) (No offense)

16:35 technomancy: the-kenny: cool. =) if it persists please bring it up on the swank-clojure mailing list. I don't even have sbcl installed myself, so it's good to hear from folks who use both.

16:36 the-kenny: technomancy: Okay.. I hope I don't have to change anything in my .emacs for sbcl if elpa installs slime for me..

16:40 polypus: i'm trying to make a test jar with lein jar and i'm getting Exception in thread "main" java.lang.ClassCastException: java.io.StringWriter (NO_SOURCE_FILE:0). any ideas?

16:44 the-kenny: technomancy: Okay, swank-clojure is installed now.. I'll try to bring slime with sbcl working now.

16:49 rullie: the heck there's a slime for clojure?

16:49 neat stuff

16:49 the-kenny: rullie: Sure

16:50 rullie: I'm sure it was one of the first "big" projects for clojure

16:50 ska2342: FTIW I just posted my setup to my site: http://www.skamphausen.de/cgi-bin/ska/My_Clojure_Setup works for me on Linux and OSX with current checkouts of swank-clojure, clojure-mode,current master of clojure, and a SLIME which is a few weeks behind.

16:51 rullie: ska2342: cool, i have the same setup. gonna try it tonight

16:51 the-kenny: technomancy: How can I bring slime-fuzzy to work with elpa?

16:56 technomancy: Nevermind.. just add slime-fuzzy.el to my load-path and do (slime-setup '(slime-fuzzy))

16:56 LauJensen: the-kenny: Whats fuzzy ?

16:57 dakrone: technomancy: is there a way to specify which ssh key to use when doing a 'lein push'?, it looks like leinigen isn't respecting ~/.ssh/config's option

16:57 the-kenny: LauJensen: Fuzzy-Completion for the slime repl. w-oTAB extends to with-open

16:57 LauJensen: ah ok

16:58 the-kenny: ok.. it doesn't work :(

16:59 LauJensen: Wonder how much it would speed things up anyway

17:00 the-kenny: LauJensen: I'm used to it

17:00 ska2342: LauJensen: fuzzy completion? It's a killer and your finger-brain will take even more control

17:02 LauJensen: Ok

17:02 ska2342: LauJensen: while the-kenny was already sending his answer, I was still typing mine. And had the w-oTAB example, too. I think that is the only one that I consciously know of (I found out about fuzzy completion with with-open-file in CL), all the others are in my fingers. Don't know how they work :-)

17:02 LauJensen: Common Lisp code, compared to Clojure is usally very verbose, so for SBCL its probably doing you some good, not sure how well it will fare in Clojure-land

17:09 lpetit: Hello, I would like some suggestions for implementing something in ccw: when a REPL is launched, a "ConsolePageParticipant" object (instance of some predefined interface) 's init() method is called. In this method, I have the opportunity to get the TCP port at which my "IDE backdoor" will install itself. But, there is no possibility to coordinate the call from the framework to my "ConsolePageParti

17:09 cipant"'s init() implementation, and the availability of the information of the TCP port (very frequently, init() will be called before the info is available). In my init() method, though, is the opportunity to initiate the code to get the TCP port info for future uses, *and also*, to, as soon as possible (when the TCP info is needed), use the "IDE backdoor" to display a View on the...

17:09 ...available namespaces symbols.

17:12 So my question is: is using a future a good solution ? The potential problem I can see is in the last sentence above : I would like to also initiate a use of my future, without blocking. I can see at least 2 possibilities :

17:12 do this in the future body : (future (let [tcp-port (try-hard-get-tcp-port-potentially-sleep-and-loop)] (initialise-namespace-browser! tcp-port) tcp-port))

17:13 or restrain the future body to the task of gathering the tcp-port, and in the code that creates and stores the future, launch another action (maybe via an agent ?) to asynchronously use the future ??

17:14 If anybody more skilled than me in these problems can help ... you're very welcome, 'cause I'm circling, circling on it ...

17:15 spuz: lpetit: sounds like a pretty hacky way of doing it...

17:16 I guess there's no way to wait on a callback from the REPL when the TCP information is available?

17:16 lpetit: Well, I'm currently looking at the patch provided by Gorsal, and I'm indeed neither satisfied by the patch, neither satisfied by what i can think as an alternative ...

17:17 Currently no, and I don't want to make Eclipse hang because of that (and if there's an initialization problem, sometimes Eclipse could hang forever .. :-( )

17:18 the-kenny: Hah, got slime-fuzzy working :)

17:18 ska2342: lpetit: "Eclipse could hang forever"? You're more a netbeans fan, then? :-)

17:19 lpetit: ska2342: anybody writing a plugin badly may break the underlying platform, I guess. Just trying not to do that.

17:20 ska2342: lpetit: just kidding, couldn't withstand that punchline

17:20 lpetit: :)

17:20 the-kenny: I recommend slime-fuzzy to everyone :)

17:20 spuz: lpetit: do you have gorsal's patch on github?

17:21 lpetit: ska2342: if you better would like to give me your ideas concerning how to do it :-)

17:22 ska2342: lpetit: sorry, me I'm no help with Eclipse and Java stuff. Just Emacs, nothing else.

17:23 spuz: lpetit: I found it: http://github.com/Eyaro/ccw/commit/06c00832f1c2e5c4a7c15d6de0f625ad6b0e8e7e#L7L1

17:23 lpetit: spuz: it's on his github clone ( git://github.com/Eyaro/ccw.git ). Beware there's a lot of noise inside it. But what it does is very simple : start a new thread, loop in the thread forever, with Thread.sleep pauses between 2 tries. Solves the problem. Exceptional issues not well covered, though.

17:24 spuz: lpetit: yeah, I see, you're suggesting replace the thread with a future but that doesn't really make it much more elegant :p

17:26 lpetit: spuz: a future can be cancelled (so we can call future-cancel on the dispose() method). But now that I think about it, I can also do a similar think by sharing the Thread reference

17:27 spuz: true, but when would cancel the future?

17:27 * ska2342 needs sleep now

17:27 lpetit: ska2342: really, it's not an Eclipse problem. I gave the real context but I could have stated it more generally : In a thread A I want to start the computation of a value V. I also want some stuff S done as soon as possible as V is available. And I don't want to wait on thread A. What's the best way to code it ?

17:30 spuz: on ConsolePageParticipant.dispose() call by the framework ( I guess this dispose() method corresponds to the end of the corresponding launched REPL

17:30 spuz: hmm ok

17:31 lpetit: Folks, I guess that by having written the word "Eclipse" I've frightened a lot of you, so let me point that this is not an Eclipse related problem, and restate it more generally:

17:31 In a thread A I want to start the computation of a value V. I also want some stuff S done as soon as possible as V is available. And I don't want to wait on thread A. How would you do this ?

17:41 polypus: about to light my hair on fire. here are the exact steps i'm taking:

17:41 lein new foobar

17:41 edit foobar/project.clj to look like this:

17:41 the-kenny: technomancy: Looks like sbcl works flawlessly with swank-clojure from elpa :)

17:42 polypus: (defproject foobar "1.0.0-SNAPSHOT"

17:42 :description "foobar"

17:42 :dependencies [[org.clojure/clojure "1.1.0-alpha-SNAPSHOT"]])

17:42 mv src/foobar.clj src/foobar/core.clj

17:42 edit core.clj to look like this:

17:42 (ns foobar.core)

17:42

17:42 (defn barfoo [x] (str "foobar:" x))

17:43 lein repl works fine

17:43 lein compile seems to also

17:43 but lein jar fails with:

17:43 Exception in thread "main" java.lang.ClassCastException: java.io.StringWriter (NO_SOURCE_FILE:0)

17:44 any ideas?

17:45 gravity: polypus: Add a :main your_namespace section to project.clj

17:46 technomancy: polypus: on JDK 1.5? if so that was fixed yesterday in master.

17:46 tcrayford: I made something roughly like ruby's autotest with lein and some ruby scripting

17:46 http://www.tcrayford.net/2009/12/08/Lein-Autotest.html

17:47 uses watchr for changes to .clj files in /src or /test and then runs lein test, and colours the output for pass/fail

17:48 polypus: gravity, technomancy: ty i'll have a look in a minute

17:48 the-kenny: elpa is dumb...

17:49 Doesn't install any .lisp-files with slime

17:49 So the emacs-part of slime is working, but no backend for any lisp is installed

17:50 (they are normally bundleled with slime)

17:51 technomancy: the-kenny: yep; elpa is an elisp package manager. you should use a CL package manager for the CL bits, just like you use lein/mvn for swank-clojure.

17:51 konr: for some reason, I messed up with the number of parentheses and now everything I try to enter on SLIME results in a "input not complete" error. Is there a way to "reset" things and get a real repl again?

17:52 the-kenny: technomancy: mhm... I'm not sure if the backend for sbcl is in the package manager of CL

17:53 technomancy: the-kenny: what I mean is if it's not, that's a CL problem, not an elpa problem

17:53 the-kenny: technomancy: I understand you. It's just new for me. I'm used to have everything in my slime-tarball.

17:56 KirinDave1: Hey, if I'm at the repl

17:56 How would I figure out the current working directory?

17:59 tcrayford: (use 'clojure.contrib.duck-streams)

17:59 (pwd)

17:59 KirinDave1: Man this is bizareew

18:00 So I know my pwd is correct

18:00 It's /Users/kirindave/Projects/scorekeeper/

18:00 I know that under scorekeeper is a templates directory

18:00 and in that is home.html

18:01 But (reader "templates/home.html") refuses to read.

18:03 hiredman: hah!

18:03 KirinDave1: Oh

18:04 In java, you can't change the current working directory?

18:04 ...

18:04 What kind of insanity is that?

18:04 * hiredman totally generated a Runnable that does nothing using clojure.asm.*

18:06 Chousuke: hiredman: working on a compiler now? :P

18:06 the-kenny: KirinDave1: Blame sun

18:09 tcrayford: KirinDave1: eval this (str (pwd) "templates/home.html")

18:10 KirinDave1: tcrayford: I was under the impression you could change the current working directory

18:12 dnolen: KirinDave1: nope, massive limitation of Java. I often create a var called *cwd* so that I can using binding on it to get around the annoyances.

18:12 KirinDave1: So when you're developing on the repl

18:12 how the hell do you even get to files?

18:13 dnolen: you could even make a function called cwd that either returns the standard current directory (whatever the JVM thinks) or the values of *cwd*

18:13 slyrus: KirinDave1: change the classpath and restart the JVM :P

18:13 KirinDave1: slyrus: For things like templates.

18:13 dnolen: values -> value

18:13 KirinDave1: slyrus: That seems pretty lame.

18:14 slyrus: I agree!

18:15 KirinDave1: argh and enlive stopped working for me again. Seriously, I quit.

18:16 cgrand-r1c: I don't suppose you're still here?

18:18 dnolen: KirinDave1: what's the bug you're seeing? I messed around with Enlive quite a lot at one point.

18:18 KirinDave1: dnolen: All deftemplate ever says is "null pointer exception"

18:18 So I have no idea.

18:18 dnolen: paste your template, I'll take a look.

18:18 * the-kenny was looking through the list of packages elpa provides... and wonder wonder, what's one of the coolest packages there? relax, written by the same person whi wrote swank-clojure and is present here. Again, good work, technomancy :)

18:21 KirinDave1: dnolen: both template and invocation are here: https://gist.github.com/dd83a434403e29fdf09d

18:23 dnolen: try (str *templates-dir* "home.html") -> (file *templates-dir* "home.html"), use clojure.contrib.java-utils to get file, gotta head out but will tweak your gist when I get back.

18:24 technomancy: the-kenny: heh; thanks.

18:24 KirinDave1: I'd recommend putting templates in the resources/ dir. if you use leiningen that will get put on your classpath, plus it'll be available transparently when you run from a jar if you open it via getResourceAsStream.

18:27 KirinDave1: technomancy: So like, resources/templates/home.html instead?

18:27 technomancy: sure

18:28 KirinDave1: technomancy: But that doesn't change my opening problem, right?

18:29 technomancy: And that is only available during the jar'd state, not during dev on the repl?

18:31 technomancy: KirinDave1: no, if resources/ is on the classpath, getResourceAsStream will find it.

18:33 KirinDave1: technomancy: I'll try it. Thanks.

18:36 technomancy: welcome to the wacky wonderful world of the jvm

18:36 KirinDave1: technomancy: … I loathe to ask this, but where do I call that method from, even

18:37 technomancy: oh right... it's a bit wordy: (.getResourceAsStream (.getContextClassLoader (Thread/currentThread)) "/templates/home.html")

18:37 * KirinDave1 facefaults.

18:37 KirinDave1: Well, there's hardly anything to it, now is there?

18:39 konr: Has anyone ever tried to change swing's look and feel? This code, removed from an example, simply yields a null pointer exception:

18:39 (javax.swing.UIManager/setLookAndFeel (javax.swing.UIManager/getSystemLookAndFeelClassName)) 

18:41 KirinDave1: technomancy: I wish it worked, but it doesn't seem to.

18:52 hiredman: http://gist.github.com/252110 yay macros!

18:57 replaca_: technomancy: I'm glad you guys got the resource stuff in - I was worrying about that re: autodoc (cause I want to stash the default styles and templates in there as resources)

18:57 cp2_: hiredman: watcha' making?

19:01 hiredman: cp2: my goal is to replace classloader.java with something generated using the asm package

19:02 cp2: interesting

19:03 what for?

19:03 hiredman: uh, so I don't have to write it in java?

19:04 cp2: heh, would be a good reason =P

19:19 dysinger: KirinDave:

19:19 user> (System/getProperty "user.dir")

19:20 "/Users/tim/src/sa-safe/amqp/src/main/clojure/sonian/archive"

19:20 user> (System/setProperty "user.dir" "temp")

19:20 "/Users/tim/src/sa-safe/amqp/src/main/clojure/sonian/archive"

19:20 user> (System/getProperty "user.dir")

19:20 "temp"

19:20 user>

19:20 ?

19:21 changes cwd

19:22 works with (pwd)

20:19 polypus: technomancy: btw, that lein problem i had was cuz of jdk 1.5 like you said. not sure why being that a 64 bit 1.6 version was already installed, apple chose to make the default a 32 bit 1.5.

20:23 konr: How can I round 3.14159 to 3.1416?

20:24 rullie: konr: http://java.sun.com/docs/books/tutorial/java/data/numberformat.html

20:28 konr: lr be

20:29 *or better yet: http://richhickey.github.com/clojure-contrib/pprint-api.html#clojure.contrib.pprint/cl-format

21:22 is there a macro that could replace [(function foo) (function bar) (function baz) ...] with (macro function foo bar baz ...)?

21:27 kylesmith: (vec (map function [foo bar baz]))

21:30 Has anyone gotten penumbra to work? I can't get the libraries to stop throwing exceptions.

21:31 konr: oh, of course

21:31 ambient: yep, got it working a while ago

21:31 at least all the exmples

21:40 JAS415: kylesmith: yup, got it working

21:40 what is the exception

21:43 kylesmith: one moment, let me try one more thing.

21:46 com.sun.gluegen.runtime.CPU.getPointerSizeInBits

21:48 JAS415: hmm

21:48 is it a particular example?

21:48 kylesmith: the actual exception is an UnsatisfiedLinkError if that helps

21:48 JAS415: oh

21:49 you might not have all the deps installed

21:50 kylesmith: it's for all examples. I have all the jars on my classpath, and all the *.so files are on my libpath.

21:52 what other dependencies are there?

21:53 JAS415: i had

21:53 ambient: clojure, clojure-contrib

21:53 JAS415: glugen.jar, jogl.jar

21:53 ambient: you sure you have the right binaries?

21:53 there are 32 and 64 bit versions iirc

21:53 JAS415: nativewindow

21:54 ambient: depends on the JVM, which you will need

21:54 kylesmith: yes, I have the right binaries (that is a different error message).

21:54 I'm on 32bit ubuntu, btw.

21:55 JAS415: yes, I have all those.

21:56 JAS415: hum

21:56 the only problem i had was getting the names of directories right

21:56 i'm on ubuntu too :-(

21:58 kylesmith: 32bit or 64bit?

21:58 JAS415: i think this is 64

22:00 you pointed at the directory for the java.library.path and not the individual *.so files?

22:02 kylesmith: well, actually I 'cheated' and just copied the individual files to a directory already on the libpath.

22:06 KirinDave1: Hey, does anyone here use leiningen and the resources/ directory? I'm having problem accessing resources.

22:07 JAS415: kyle: can you do a backtrace on the error?

22:07 might give you a class or filename

22:08 kylesmith: I just got it to work on the 64bit machine. I didn't see the additional library paths in swank-clojure.el before.

22:09 JAS415: hmm

22:09 kylesmith: hence, I thought I could just copy the files, but apparently that doesn't work.

22:10 JAS415: i think there is an extra jar

22:10 kylesmith: I count 3 jars and 5 *.so files. ?

22:11 JAS415: opencl4 java

22:11 5 jar 5 so

22:11 4 jar*

22:13 kylesmith: I was looking at that, but A. I don't need opencl and B. it isn't mentioned anywhere in the installation instructions. Are you saying OpenCL4Java.jar is actually needed?

22:16 JAS415: hum

22:20 kylesmith: What kind of bothers me is that the installation instructions explicitly state that what I was attempting to do was acceptable.

22:21 anyhow, thanks for the help JAS415

22:22 JAS415: yeah i'm not sure what happened there

22:22 glad you at least have it working on one machine :-)

22:23 kylesmith: no, it's working on both now :) Thanks again.

22:23 JAS415: oh

22:23 good

22:23 even better

22:45 konr: What should I use to generate an exe from a Lein uberjar?

23:24 polypus: ,'just-testing

23:24 clojurebot: just-testing

23:29 hiredman: ~ping

23:29 clojurebot: PONG!

23:30 hiredman: so, I can generate a classloader using clojure.asm.* and it has a loaders field which contains an arraylist and an add method that takes a ClassLoader and adds it to the list

23:31 now I just need to override findClass

Logging service provided by n01se.net