#clojure log - Dec 24 2009

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

0:00 fanatico: as well as the comments on fogus's blog.

0:00 tomoj: I don't understand why it's complaining about bytes... I'm not even using it :(

0:00 devlinsf: Ah

0:02 chouser: ping

0:11 aking: tomoj: clojure 1.1 has a new defn for bytes - you'll need to remove it from agent.

0:11 devlinsf: aking: good catch!

0:15 tomoj: aking: ooh! thanks

0:16 aking: probably not remove it from http/agent.clj but rename it - doesn't look to do the same thing as core's bytes

0:17 tomoj: I guess http.agent should be updated

0:20 hmm.. not sure how to get leiningen to use my patched contrib

0:23 hiredman: swing is truely a torture devised to destroy me

0:24 devlinsf: hiredman: sometimes I wonder if Gosling gets paid a nickel every time a developer swears

0:25 liebke`: hiredman: what are you building with Swing?

0:25 hiredman: I'm rewriting my repl

0:26 aking: tomoj: I'd suggest just overwritting the existing control jav under lib - seems to work for me (don't run 'lein deps' though)

0:26 contrib*

0:26 liebke`: ah, excellent. I'm really interested in having a gui repl. I hope your luck with Swing improves :-)

0:26 hiredman: the stuff I was doing to scroll the scrollpane down to the bottom in the previous iteration does not seem to work now

0:27 http://www.thelastcitadel.com/images/Screenshot-Clojure.png

0:27 from the previous iteration

0:27 devlinsf: hiredman: Why not use a JTextArea?

0:27 hiredman: because I want to render arbitrary stuff

0:27 devlinsf: Or JPanel *in* the scroll pane

0:28 hiredman: I do have a JPanel in the scrollpane

0:28 devlinsf: Let JScrollPane do the work

0:28 liebke`: very cool! inline images, that would be awesome for Incanter

0:28 hiredman: devlinsf: jscrollpane does no work

0:28 devlinsf: And are you just adding labels?

0:28 hiredman: no

0:28 devlinsf: How come?

0:28 hiredman: I have a jscrollpane

0:28 in it is a jpanel

0:29 devlinsf: Right

0:29 hiredman: to this jpanel I am adding arbitrary jcomponents

0:29 devlinsf: And it's not working?

0:29 Hmm...

0:29 hiredman: and I have the layout for the jpanel set to flowlayout

0:29 wait

0:29 no, box layout?

0:29 anyway it lays stuff out downwards

0:29 devlinsf: Right

0:29 hiredman: and the scrollpane does scroll

0:30 devlinsf: Hmmm...

0:30 hiredman: but the keyword, in my description which you seem to have missed is: autoscroll

0:30 * devlinsf tries to remember if there are any special event handles

0:30 devlinsf: Like any other REPL

0:31 hiredman: previously I was getting the visibleRect and then using scrollToVisibleRect on the viewport

0:31 but it doesn't apear to work now

0:32 devlinsf: Okay, you've got me

0:32 Stupid swing

0:33 If I understand you correctly, you've tried manipulating the JViewport?

0:34 Hmmm... I know I've set the viewport manually before

0:34 aking: tomoj: which dependency are you using for clojure-contrib in your project.clj file? The latest contrib already has a fix in for it

0:34 devlinsf: If I find the code, I'll let you know

0:34 *set programatically

0:34 hiredman: devlinsf: I have too, and it worked last time, but now it doesn't

0:34 devlinsf: Huh

0:35 Wierd

0:35 hiredman: :|

0:35 devlinsf: have you set it in Clojure before?

0:36 My experience was in normal Java

0:36 hiredman: this was in clojure

0:36 I have the code right here

0:36 it's like a page up in my editor

0:36 devlinsf: No f'ing clue, man

0:37 Reset the REPL? Stranger things have worked

0:40 tomoj: aking: oh, great

0:40 I guess

0:40 I guess I just need to update, then

0:41 is [org.clojure/clojure-contrib "1.0-SNAPSHOT"] right?

0:41 aking: tomoj: I'm using: [org.clojure/clojure-contrib "1.1.0-master-SNAPSHOT"]

0:42 tomoj: thanks

0:45 hmm.. seems like that didn't fix it :(

0:47 aking: tomoj: try 'lein clean' and 'lein deps' - maybe it's still picking up the old one?

0:49 tomoj: aking: ah, my fault, I had my manually installed jars dumped in there too

0:49 aking: works now, thanks for your help

0:50 aking: tomoj: np - I'm still just learning leiningen too :)

0:51 lucidrains: > If i have had no exposure to functional programming before, should i first jump into clojure or start with haskell?

0:51 tomoj: any lisp exposure?

0:52 lucidrains: nope

0:52 is Lisp like the grandfather of all these languages?

0:53 tomoj: eh, I dunno

0:54 clojure seems like less of a brainfuck to me, but I already was comfortable with lisp

0:54 don't need to worry about types as much, but that might not be a good thing either :)

0:58 mitchellh: Whats the difference between "sync" and "dosync" ? I see that "sync" has flags TBD but what would be the purpose of using it in code now vs. dosync?

0:59 tomoj: I think it's just there for future use

1:00 mitchellh: Alrighty

1:00 hiredman: use dosync

1:05 mitchellh: hiredman: Any specific reasoning other than avoiding the TBD?

1:08 hiredman: because it's not used

1:08 sync is a primitive and provides some room for future use, but no one uses it

1:09 2009:Nov:17:03:44:57 rhickey : prefer dosync for now

1:09 mitchellh: hiredman: Thanks, I was only poking about it because I'm reading rich's ant.clj file and he used "sync" everywhere

1:10 tomoj: that was before dosync existed I guess

1:12 mitchellh: Figured

1:12 Just was making sure :)

1:21 hiredman: I think I am closing in on the issue

1:25 KirinDave: Ugh, so you can't use netty without a java class?

1:26 For annotations? I mean you really simply cannot

3:38 maacl: Why does lein fail to download clojure-1.1.0-alpha-SNAPSHOT.jar ?

3:43 timothypratley: "alpha" is now "master" I think

4:04 notostraca: yes! I got counterclockwise to create working executable jars!

4:05 the only caveat is that every library the app uses must be in the same folder

4:05 (as the jar)

4:06 i was working at it so long that I don't know if i can reproduce the steps though

4:37 G0SUB: what should be the right type hint for a java fn that takes Collection<String> ?

4:41 hiredman: G0SUB: #^Collection

4:41 G0SUB: hiredman: figured that out just now. many thanks.

4:55 bOR_: Trying to figure out how I can change the settings of the slime-connect called jvm (mainly -Xmx). While i'm looking, does anyone in here know the solution?

5:02 vy: bOR_: See slime-lisp-implementations variable.

5:03 C-h v slime-lisp-implementations

5:03 bOR_: thanks :).

5:08 (swank-clojure-extra-vm-args '("-server" "-Xmx1024M"))

5:10 hmm. but putting that in my .emacs won't make much sense if I start my swank using leiningen.

5:12 I'll solve that problem later.

5:12 vy: bOR_: You told SLIME, not leniningen. SLIME configuration will only affect the vms fired up by SLIME. For lenininininingen,... I have no idea.

5:13 bOR_: misunderstanding there then. You still connect to the leiningen swank from within emacs using M-x slime-connect.

5:13 thanks for the pointer though :).

9:51 saml: hey, how can I get documentation of reader macro?

9:51 (doc ') is error

9:51 clojurebot: Unmatched delimiter: )

9:54 hoeck: saml: http://clojure.org/reader

9:54 saml: so no way to do it in the repl

9:54 ah user cannot define reader macro anyways!

9:55 hoeck: saml: you may try sth like backquote and see into what the reader macro expands to

9:56 saml: (~')

9:56 hoeck: saml: but often those are special forms, documented only on the clojure page

9:56 ,`'a

9:56 clojurebot: (quote sandbox/a)

9:57 saml: coolz thanks hoeck

9:57 * saml downloads enclojure

10:34 hamza: guys, if a java call requires 2 variables, and i have a vector of [val1 val2] is there a shorter way to call the function besides, (.call obj (first vec) (second vec))?

10:55 saml: hey can emacs do auto completion? what's the keyboard shortcut (using Clojure Box on windows)

10:56 i can press TAB to get auto completion in repl. but i'm not sure if that's possible in editor

11:00 Hun: saml: M-Tab

11:00 if your window manager eats the M, use Escape Tab

11:00 saml: Hun, yah but when I do Alt-Tab, window manager eats it

11:00 Hun: ;)

11:00 saml: Escape-Tab minimizes the window

11:01 Hun: then try C-M-i

11:01 saml: oh escape-tab works

11:01 haha awkward key combo i should get used to

11:01 C-h k will tell me what command it is. and i can remap!

11:02 Hun: yep

11:03 try M-x customize-variable slime-complete-symbol-function

11:03 in CL i use compound, which is awesome - you can complete mvb => multiple-value-bind

11:04 saml: that did not let me set key binding. i should google it

11:05 does emacs have word completion? not related to clojure but using whatever is written in the buffer

11:05 hamza: yes M-. will complete anything..

11:05 Hun: that can be done with hippie-expand

11:06 i bind that to M-/

11:06 it can complete pretty much anything, using heuristics. it searches through buffers, filesystems, dictionarys, ...

11:07 saml: oh C-c Tab is already slime-complete-symbol

11:08 wow M-/ works

11:11 jburd: Try using the auto-complete.el package from the emacswiki. You won't ever need to hit M-/ again.

11:12 saml: too much to learn!

11:25 ,``'a

11:25 clojurebot: (clojure.core/seq (clojure.core/concat (clojure.core/list (quote quote)) (clojure.core/list (quote sandbox/a))))

11:25 saml: wheeeeeeeee

11:28 spariev__: hi, anyone using enclojure ? is there any keybinding to quickly switch from editor to project repl ?

11:37 saml: ,(defn foo [{x #(:x %1)}] (println "Hello" x)) (foo {:x "u"})

11:37 clojurebot: DENIED

11:40 saml: ,(let [{x #(:x %1)} {:x "u"}] (println "Hello" x))

11:40 clojurebot: Hello nil

11:40 saml: why can't i do that?

11:42 the-kenny: ,(let [x #(:x %1) {:x "u"}] (println "Hello" x))

11:42 clojurebot: java.lang.IllegalArgumentException: let requires an even number of forms in binding vector

11:42 the-kenny: oops

11:49 jweiss: in the ns macro, :import section, anyone know how to import from the default package?

11:49 just putting the classname doesn't work, it thinks that's the pkg name

11:50 the-kenny: jweiss: What's the "default package"?

11:51 jweiss: the-kenny: one at the toplevel, with no package name

11:51 the-kenny: jweiss: hm.. I'd look how the generated .class is named.. but isn't using the default package discouraged?

11:52 jweiss: the-kenny: yes. but i'm using a password hashing lib that is just one class, and they didn't put it in a package

11:52 so rather than rebuilding it i was just gonna try to import it as-is

11:52 the-kenny: jweiss: Found in Google: "You can’t use classes in the default package from a named package."

11:52 jweiss: the-kenny: the class is just BCrypt.class

11:53 the-kenny: what does that mean "from a named package"

11:53 the-kenny: jweiss: From any other package than the default one

11:53 jweiss: the-kenny: but i'm calling it from clojure. clojure doesn't have packages

11:53 the-kenny: (In clojure for example user, clojure.contrib.seq-utils etc. etc)

11:54 jweiss: oh, namespace == package?

11:54 did not know that...

11:54 the-kenny: hm.. I think so

11:54 I'm not absolutely sure

11:54 jweiss: bah, i guess i'm just gonna repackage it, will just take a minute and i gotta restart slime, but whateva

11:54 thanks

11:54 saml: spariev__, i just installed netbeans. go to Tools->Options->Keymap (tab) and search for repl

11:55 find Netbeans IDE Repl under Window category

11:55 assign shortcut Ctrl+Alt+0

11:55 Ctrl+0 goes to editor

12:00 spariev__: saml, thanks, I missed that. Actually, I' using Project Repl with my classpath, and there are no shortcuts for it. well, at least I can switch back to editor faster now

12:01 saml: no idea :P

12:25 srirampc: ?

12:33 fliebel: What could possibly be wrong with this line? It's giving java.lang.IllegalArgumentException: Key must be integer: (writer (map #(template % @pages (first args) (second args)) @pages))

13:08 joshua-choi: A question. I have a sequence "s". To get the first element in it that does not fulfill a function "pred", I do (first (drop-while pred s)). How, then, can I best get the element *right before* that one?

13:09 saml: split the list at first pred. and get the last element of the first list?

13:11 fliebel: Maybe reduce is better for this

13:11 joshua-choi: Well, split uses filter. Unfortunately, I need to get the element right before the *first* element that doesn't fulfill the predicate, so using filter or split doesn't work

13:11 I think

13:11 fliebel: With reduce you can return the next item until the next item is true and the return the other

13:11 joshua-choi: fliebel: How might you use reduce?

13:11 Yeah

13:12 fliebel: one moment....

13:12 joshua-choi: That would work, but it would always go through the entire sequence

13:13 Using drop-while in (first (drop-while pred s)) stops the sequence immediately when the proper element is found, since drop-while is lazy

13:13 It'd be great if there was a similar way for getting the element before that first element

13:13 fliebel: (reduce #(if %2 %1 %2) [false false true false])

13:14 joshua-choi: ,(reduce #(if %2 %1 %2) [false false true false])

13:14 clojurebot: false

13:15 fliebel: (reduce irc://irc.freenode.net/#(if (= :c %2) %1 %2) [:a :b :c :d])

13:15 ,(reduce irc://irc.freenode.net/#(if (= :c %2) %1 %2) [:a :b :c :d])

13:15 clojurebot: java.lang.ClassNotFoundException: irc://irc.freenode.net

13:16 joshua-choi: Is there a way, though, that doesn't have to go through the whole sequences? The sequences I'm dealing with are going to be very large

13:16 fliebel: I don't know, I'm not a Clojure expert, you see...

13:16 saml: how do you zip two lists?

13:17 (1 2 3) ==> ((1 2) (2 3))

13:17 fliebel: I'm — without success so far — trying to solve an very unhelpful java error.

13:17 saml: zip the list with its tail and modify pred

13:17 to test second element of the list

13:18 if you find it, then first element of the list is previous element

13:21 fliebel: How can I find out where an error comes from?

13:21 (generator.clj:0) is obviously not right...

13:28 chouser: ,(some (fn [[a b]] (when (odd? b) a)) (partition 2 1 [2 4 6 8 9 10 11])))

13:28 clojurebot: 8

13:29 chouser: joshua-choi: that's for you

13:29 joshua-choi: Excellent

13:29 chouser: saml: pretty much your idea. 'partition' as a sort of pre-packaged zip-with-tail

13:30 fliebel: does generator.clj start with an 'ns' form?

13:30 fliebel: chouser: yes

13:30 chouser: but nothing changed with that since it stopped working

13:30 chouser: that's usually what the :0 indicates. Haven't tried to figure out why.

13:31 fliebel: chouser: strange, but I actually think I found out which line it is by removing stuff…

13:32 chouser: yeah. :-/

13:32 aravind: hi, I need some help getting slime to work.. I am using the latest git versions of clojure-mode and swank-clojure, when I start slimme, the repl starts okay, but slime can't talk to it and fails with "Error in timer" slime-attempt-connection...

13:32 fliebel: chouser: Any idea what "java.lang.IllegalArgumentException: Key must be integer" might mean in a for expression?

13:33 mitchellh: aravind: I'll show you my .emacs with the setup and maybe that'll help

13:33 aravind: mitchellh: cool!

13:34 mitchellh: aravind: https://gist.github.com/7f060cbd1879927e3538

13:34 aravind: Thats everything that makes it work for me, you should be able to glean from the paths how everything is laid out

13:34 aravind: With that, i simply do M-x slime and it works

13:35 chouser: fliebel: trying do a lookup in a vector with a non-integer

13:35 aravind: mitchellh: okay, let me try that setup.

13:37 fliebel: chouser: I'm looking at some functions now… but without helpful error reporting it's not easy...

13:39 aravind: mitchellh: did you checkout the latest slime from github as well?

13:39 mitchellh: I am using the one that comes with emacs

13:39 oh :(

13:43 mattrepl: aravind: slime changes fairly quickly, it's best to grab the latest

13:46 fliebel: Is future suitable for doing io?

13:46 aravind: mattrepl: I would.. but there is a big fat warning that the latest slime may not work with clojure, since its designed more for CLs

13:47 mattrepl: aravind: where at?

13:47 aravind: mattrepl: http://groups.google.com/group/clojure/browse_thread/thread/4960adce009d4760/b1b259efc229cad0?lnk=gst&q=swank+2009+dec#b1b259efc229cad0

13:48 I wish something like this would be simpler..

13:49 mitchellh: aravind: Um… no, from CVS

13:49 aravind: cvs -d :pserver:anonymous:anonymous@common-lisp.net:/project/slime/cvsroot co slime

13:49 aravind: straight into my emacs.d includes folder

13:49 mattrepl: aravind: ah, ok. yes that does happen sometimes.

13:49 ELPA is a good suggestion

13:50 aravind: I have never used that, so no clue how elpa works..

13:50 mattrepl: the link technomancy provided has installation instructions: http://tromey.com/elpa/

13:51 aravind: mattrepl: yeah, I am reading about it now.. a lot of folks seem to recommend it

13:52 mattrepl: I had been managing my own packages for awhile and was reluctant to move from "good enough" to elpa - but it does work and streamlines package management

13:53 aravind: mattrepl: yeah, my concern exactly.. I am in the habit of just getting whatever .el files are needed and sticking them in a directory.

13:54 mattrepl: be ready to spend a few moments cleaning out any old packages once you've re-installed them with ELPA, but that's straightforward

14:05 aravind: mattrepl: okay, I installed clojure-mode, swank-clojure and slime with the elpa thingie and I still get the same error I did when I started out.

14:05 mattrepl: did you remove previous versions?

14:05 aravind: which makes me suspect that something upstream is broken.

14:05 mattrepl: I did.

14:06 mattrepl: hmm, anything interesting in *inferior-lisp* buffer? if so, please pastebin or msg

14:08 JonSmith: sorry,what is the error?

14:08 aravind: mattrepl: http://pastebin.com/d193f5732 and I get a backtrace with this - http://pastebin.com/d44bdf41e

14:13 you guys think its still my env thats screwy?

14:14 mattrepl: not sure, was googling around a bit for anything related, nothing helpful turning up

14:15 ooc, what emacs version and OS?

14:16 aravind: mattrepl: 23.1.1 and debian

14:20 JonSmith: hmm i'm using emacs 22

14:20 idk if that matters

14:21 aravind: well.. at least now I know the problem wasn't with my original setup.

14:22 ieure: Is there some way to make my code dump me into SLDB when I’m using slime/swank-clojure?

14:23 It isn’t throwing an exception, but it’s not working and I want to step through to figure out why.

14:26 joshua-choi: What's the difference between repeat and replicate, other than repeat's n parameter defaulting to infinity?

14:27 devlinsf: joshua-choi: I think replicate is going to be deprecated

14:27 joshua-choi: Not 100% sure, though

14:28 joshua-choi: Hmm, I see

14:44 olerixmann: hi

14:44 on christmas eve

14:45 i have a problem gettinge resources from a jar file...

14:45 maybe someone can give me a hint why i always get zero pointer-exceptions

14:45 i try it this way:

14:46 (with-in-str (slurp (.. 'this (getClass) (getResource (str "templates/" schtring)))) (read))

14:46 schtring is a string

14:48 JonSmith: did you try printing out the different arguments to the repl and seeing which one is nil?

14:48 my guess would be it has something to do with 'this, but really is hard to tell

14:48 shoover``: aravind: Any chance your machine has really tight security such that you couldn't even connect to a socket on a localhost port?

14:48 aravind: shoover``: hmmm.. :) thats possible

14:49 I didn't think of that.. but yeah, let me check

14:49 shoover``: aravind: because the one paste says swank opened the socket, but the phrase "Connection refused" is in your debugger paste

14:50 olerixmann: getResource returns nil

14:50 ..

14:50 aravind: shoover``: phew okay.. no that wasn't it.

14:51 shoover``: I disabled my firewall and still same error.

14:51 I would have felt really stupid if that was the problem!

14:52 olerixmann: maybe someone has an example of loading anything from the application jar?

14:54 JonSmith: hum

14:55 the thing is it should really be the same as doing it from java

14:55 it might be a placement issue

14:55 http://www.velocityreviews.com/forums/t134544-load-images-and-text-file-from-jar-file.html

14:56 olerixmann: thx

14:56 JonSmith: if you are getting an error it might be useful to do (.printStackTrace *e)

14:58 olerixmann: its just the zero pointer except from the getResource, but i'm trying with leading slash now :)

14:59 hiredman: olerixmann: null point

14:59 er

14:59 JonSmith: yeah, hopefully it will be the same as the java problem

15:00 hiredman: using with-in-str and read and slurp is horrible

15:00 (binding [*in* some-reader] (read))

15:03 olerixmann: reading this way works

15:03 hiredman: but is is horrible

15:03 olerixmann: yeah, maybe

15:03 i have some other problems ;)

15:04 hiredman: well, if you code in that style I am not surprised

15:05 olerixmann: i don't think its so ugly

15:05 what is the with-in-str macro for?

15:05 if not for this

15:05 sorry, my english is not as good as i want it to be

15:05 hiredman: the ugliness is from reading the whole file into memory as a string

15:06 olerixmann: ok

15:06 its just a few lines

15:06 not that bad

15:06 hiredman: it's a bad habit

15:06 smells of php

15:07 olerixmann: ;)

15:07 no php on my side

15:10 seems to work now, thanks

15:10 shoover``: aravind: I don't know what else to check, but there's definitely a networking issue. Either that socket isn't really open or you can't get to it. That's why that "connection refused" is there

15:10 hiredman: what you want to do is someting like (with-open [o (-> (ClassLoader/getSystemClassLoader) (.getResouceAsStream "Whatever") InputStreamReader. PushbackReader. BufferedReader.)] (binding [*in* o] (read)))

15:11 olerixmann: but i always get strange errors when compiling, but it works anyways....

15:11 hiredman: duck streams should take care of all those readers

15:11 olerixmann: ok, thanks

15:11 i'll change that

15:11 aravind: shoover``: yeah.. you are probably right.

15:11 shoover``: I am trying to go down to the elisp stuff thats connecting and checking if that works.

15:12 shoover``: thanks for looking into it though.

15:16 shoover``: aravind: here's some test code you can try: http://paste.bighugh.com/scratch.html

15:17 (thanks, technomancy, scpaste rules)

15:17 hiredman: what about the java side?

15:17 does the jvm start and is it listening?

15:23 aravind: hiredman: yeah, the java side is up and listening

15:24 although, it quits listening once you connect to it and quit (from telnet)

15:31 shoover``: that test code isn't working on my box..

15:32 a plain telnet to that port works, but within emacs it fails.

15:33 shoover``: fails with '(file-error "make client process failed" "Connection refused" :name "crino" :buffer "crino" :host "" :service 8888)'

15:34 shoover``: aravind: I dunno, something's hamstringing your emacs

15:36 q2: Any tips on an efficient case-insensitive lookup by key against a map?

15:37 given: {"Foo" "bar"} lookup "foo" ==> "bar"

15:38 LauJensen: (filter #(= (tolower x) (tolower y))) is probably near-optimal

15:41 q2: lau: thanks. what lib is tolower in?

15:41 LauJensen: ,(.toLower "HI THERE")

15:41 clojurebot: java.lang.IllegalArgumentException: No matching field found: toLower for class java.lang.String

15:41 LauJensen: ,(.toLowerCase "HI THERE")

15:41 clojurebot: "hi there"

15:41 q2: ah java's. got it.

15:41 LauJensen: ah.. :)

15:50 q2: lau: so close! a lowercase method that doesn't bomb on null would be more awesome :)

15:51 LauJensen: Can you write an example of what you want/what u have?

15:51 q2: lowercase what comes out of a regex prior to the map lookup. regex can return NIL

15:51 so (. toLowerCase nil) --> bad

15:54 LauJensen: (filter #(when-let [match (re-seq #"...")] (= (.toLowerCase match) (.toLowerCase %)))...

15:54 So that kind of thing?

15:55 q2: yeah that's the basic idea

15:55 LauJensen: That will work then

16:05 aravind: I think I figured it out..

16:05 shoover``: it appears that my latest kernel updates (and/or clojure updates) enabled and started using ipv6 on my box.

16:06 and the clojure repl (created by slime) was listening on a ipv6 port, but slime connection was trying to talk to the ipv4 address.

16:06 disabled ipv6, and stuff seems to be working correctly now.

16:06 what a waste of time!

16:06 q2: lau: thanks. you are right. the key difference was when-let vs just let :)

16:11 one last silly REPL question. how to abort the query I'm writing without a ctrl c or ctrl d -- which exits the repl

16:33 LauJensen: You mean if you've started a lengthy computation and you want to abort halfway through, still keeping the REPL?

16:33 q2: yup

16:33 LauJensen: Sorry I dont think thats possible

16:34 q2: ah, that's a shame.

16:34 chouser: repl-utils add-break-thread!

16:34 LauJensen: ~source add-break-thread!

16:34 q2: excellent!

16:35 LauJensen: q2, sorry about that bit of bad advice

16:35 chouser: well, using add-break-thread! is techincally bad advice -- uses deprecated Java features.

16:35 on the other hand, it generally works. so ...

16:36 q2: no worries. i'm still very much a novice, excuse the silly questions.

16:37 thanks chouser. that works quite well.

17:10 somnium: can lein be used to compile .java?

17:12 LauJensen: Is there a definitive paper on Write Skew lying around somewhere ?

17:14 chouser: wikipedia has an article. might have useful links too, if it's content is insufficient.

17:15 arohner: ,(deftype my-type [foo bar])

17:15 clojurebot: DENIED

17:15 arohner: nice

17:16 somnium: chouser: have you looked at the javascript-compiler it that new google closure thing?

17:16 arohner: anyways, it appears you can't use merge on deftypes

17:17 LauJensen: thanks chouser I'll have a look again, I only found a small reference on the snapshot iso page

17:17 arohner: even if they implement IPersistentMap

17:17 somnium: arohner: if you include IPersistentMap in interfaces you can use conj

17:17 arohner: lisppaste8: url

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

17:17 somnium: some of the other fns seem to rely on associative/collection

17:18 arohner: merge uses conj, and it's still not working for me

17:18 one sec, I'll paste this

17:19 somnium: arohner: what error? and try (conj atype [:foo :bar])

17:19 lisppaste8: arohner pasted "merge deftypes?" at http://paste.lisp.org/display/92600

17:20 arohner: assoc works, conj does not

17:21 somnium: arohner: really, I had the opposite last time I tried

17:21 I guess the edge is bleeding, so Ill stop talking :)

17:22 liebke: somnium: there is a javac plugin for lein: http://github.com/antoniogarrote/lein-javac

17:23 somnium: liebke: great! thanks

17:24 arohner: hmm, (conj (Foo 1 2) [:c 3]) works

17:40 chouser: somnium: I'm aware of its existence, but I haven't really looked at it.

17:42 somnium: chouser: it turned the gensym mess created by my still-broken compiler into frighteningly readable javascript. It might be interesting to try it on clojurescript.

18:10 chouser: somnium: interesting. I wasn't expecting it to generate *readable* js.

18:13 somnium: chouser: for locals it assigns vars like a b c, I was unrolling function calls for arg evaluation and getting big nests of curly braces and var ..., it cut out all the redundancy

18:14 chouser: seems like a big win if any clojure->js project can worry only about semantics and let google's optimizer do the rest

18:15 chouser: yes, I agree

18:25 q2: any tips on returning the hierarchy for any given classs?

18:25 all interfaces / classes it implements / inherits

18:27 somnium: ,(ancestors String)

18:27 clojurebot: #{java.lang.Object java.lang.Comparable java.io.Serializable :clojure.contrib.generic/any java.lang.CharSequence}

18:28 q2: thanks

18:59 sdeobald: Am I blind or is there no way to specify an output directory to clojure.lang.Compile?

19:04 mikehinchey: sdeobald: *compile-path*

19:04 sdeobald: mikehinchey:

19:04 thanks!

19:13 mikehinchey: Hmm. I'm not quite sure how to apply that to the Java world when doing this: `java -Dclojure.compile.path=src -cp lib/clojure.jar:src clojure.lang.Compile'

19:14 Or should I be using lein or something these days for compiling and creating jars?

19:15 dliebke: I recommend lein (or mvn)

19:32 ieure: Hm. So if I have a Java instance in an atom… How do I use that? Do I have to let-bind it?

19:32 hiredman: :(

19:32 ieure: e.g. I was doing (.writeBytes stream)

19:32 hiredman: you have to deref the atom

19:32 ieure: But put that in a map in an atom, then changed it to (.writeBytes (:stream @atom-obj))

19:32 But that gives me: No matching method found: writeBytes for class clojure.lang.Atom

19:33 hiredman: you must have the stream wrapped in an atom too

19:33 ieure: hiredman, I know, just wondering if I have to deref it in a let-binding before trying to call the method, or if there’s a better way, or if I’m doing it wrong.

19:33 hiredman: (atom {:stream (atom some-stream)})

19:33 or something

19:33 ieure: No.

19:34 hiredman: ieure: that is what the exception says you have

19:35 the exception says the result of (:stream @atom-obj) is an atom

19:35 and since atom-obj is an atom, that means you have nested atoms

19:37 ieure: Okay - I see what I did.

19:37 Thanks.

19:58 q2: mmm (try (catch)) is killing performance. there something faster than (try) ?

19:58 i don't care what exception it is. i just want to do an alternative.

20:00 slashus2: Killing performance?

20:01 q2: yeah. consider this: (defn missing?3 [x] (try (empty? x) (catch Exception _ (nil? x))))

20:01 that above line is 3800 times slower than

20:02 this line here: (defn missing?4 [x] (or (and (or (coll? x) (seq? x) (string? x)) (empty? x)) (nil? x)))

20:02 the idea is for (missing?) to take any param and tell you if its NULL or empty

20:02 er nil

20:03 so "" () {} [] nil all eval to true

20:03 maybe it's just best to check for each of those cases, but heh.

20:03 the overhead with try catch is still clear.

20:04 KirinDave: q2: It's slower even if you don't hit the exception case?

20:04 q2: yes

20:05 actually mayb enot.

20:05 but in this case I expect 50% of the calls to throw the exception

20:05 be nice to have an alternate to (try (catch)) that simple stops the exception from generating, replacing it with an expr.

20:06 guess it's java limitation?

20:06 KirinDave: q2: This just in: exceptions are expensive. :)

20:07 q2: Does (or (nil? x) (empty? x)) work?

20:07 q2: i know :) it would be nice to have a mode that turns off exceptions for certain calls :) so rather than generate one, do X

20:07 no

20:07 because empty? generates an exception

20:08 if you pass it an integer

20:08 KirinDave: So yeah it's your second example.

20:08 I'm surprised empty? lets that happen, tbh. It should say false for ints.

20:08 q2: options are: rewrite missing?, rewrite empty?

20:08 yeah it shouldn't not intuitive that way

20:08 KirinDave: Well...

20:09 q2: or ask the irc about other exception handling tricks!

20:09 KirinDave: I'd profile a multiple dispatch version.

20:09 q2: i did

20:09 KirinDave: How much slower was that?

20:09 q2: it is slower than the second option

20:09 KirinDave: Huh. Well then what's wrong with the first? ;)

20:09 q2: and results in 3 defmultis hehe

20:10 i don't like it because it's still pretty slow

20:10 php is beating me out

20:10 lol

20:10 KirinDave: (defn missing? [x]   (or    (and (or (coll? x) (seq? x) (string? x)) (empty? x))    (nil? x)))

20:10 ?

20:10 q2: that's the fastest one

20:10 KirinDave: Yeah. What's wrong with that besides the order in which you call it?

20:10 q2: takes over 1 second to do 9M calls

20:11 the same in something slow like PHP, takes about 0.7 seconds

20:11 KirinDave: Um, so?

20:11 q2: i switchd to clojure for speed :)

20:11 for this particular task

20:11 oh well

20:11 KirinDave: There is always the maybe-m monad

20:11 q2: this is the one bottleneck in the application that is slower. but i'll continue working on it.

20:12 i should check that out. the problem seems simple enough though.

20:12 KirinDave: You could basically eliminate any cases where nil enters the chain.

20:13 And the constructions used in clojure are fairly fast, esp for the maybe-m monad.

20:14 q2: also, if speed is _really_ important on this

20:15 q2: You've written your fastest version in the slowest possible way. Write it to short circuit earlier.

20:15 q2: yeah reworking the cases is an option. or not using empty? maybe, but writing my own. looks like empty just calls: (not (seq x))

20:15 KirinDave: (and (not (nil? x)) ...)

20:15 q2: right. i don't understand the use case yet. but i think nil? and empty? cases are about 50/50

20:16 KirinDave: If that's the case, then inverting the form of the logic will get you big benefits.

20:16 q2: and i'm too lazy to figure each case hehe

20:16 KirinDave: But seriously

20:16 if factoring out nils in a chain of operations is a big deal, that's pretty much exactly what the maybe-m is for.

20:16 ANd it's just function calls, it will be fast.

20:17 q2: i like that notion. time to learn monads...

20:17 KirinDave: There are 2 great tutorials I've been wrestling with.

20:17 q2: Neat. Got links?

20:17 KirinDave: For me, it's not easy.

20:17 http://intensivesystems.net/tutorials.html is for one set

20:17 (That work on compojure is epic)

20:18 And the other one: http://onclojure.com/2009/03/05/a-monad-tutorial-for-clojure-programmers-part-1/

20:18 q2: Thanks Kirin.

20:19 KirinDave: I'm trying to see if I can use the state monad to use nio to make a faster server-socket library, myself.

20:19 The current server-socket doesn't scale very well.

20:19 q2: I'll share the monad when I get around to it. If it turns out to be the best.

20:19 KirinDave: Sure.

20:19 Good luck.

20:19 q2: Good luck to you too.

20:32 Luyt: I'm still trying to understand the concept of monads. Maybe that these tutorials will help ;-)

20:45 srirampc: ?

21:08 pdk: would a clojure struct be more lightweight with its memory footprint than a java object when using both for value semantics for the same things

21:08 e.g. if i had a Point class in java to store a 3d coordinate as three doubles and i did the same with a clojure struct, could i expect a smaller memory footprint and perhaps cleaner code with the struct

21:12 hiredman: pdk: Point will be more light weight

21:12 but it is not immutable :|

21:13 datatypes (from the new branch) should be the same or less

21:13 pdk: hm is there information on clojure memory consumption for these sorts of details

21:13 i mean i know it's nitpicking and with persistency you gotta get used to it but :p

21:19 hiredman: pdk: best to run your code through some kind of profiler

21:19 q1: hired: what profiler would you recommend?

21:19 pdk: i assume that most profilers like jhat would work with clojure code after compiling it to class files and still produce useful results without much extra fuss?

21:21 hiredman: rhickey has mentioned yourkit

21:21 pdk: hm google turned up a blog post on jvisualm + clojure q1

21:21 hiredman: yourkit costs money (but there is an evaluation copy)

21:23 I've yet to be in a situation where I needed to profile

21:23 pdk: hmm

21:23 q1 jhat is bundled with the jdk and according to this blog post jvisualm is as well with more recent versions

21:23 soooo time to update jdk!

21:25 hiredman: good idea, I've seen reports of pretty significat speed ups just from switching to a newer jvm

21:27 pdk: still jdk 6 here at least but hey

21:27 hiredman: yeah

21:28 5 -> 6

21:32 pdk: what is the windows kernel installation of the jre supposed to be

21:32 hiredman: erm

21:32 I don't think the windows "kernel" has a jre

21:34 pdk: on the jre download page from java.sun.com it lists a "windows kernel installation" download, not sure what that's about

21:35 certainly the obvious meaning of kernel here seems odd

21:38 hiredman: http://java.sun.com/javase/6/docs/technotes/guides/jweb/otherFeatures/jre_install.html#kernel

21:56 pdk: gah

21:57 what's the right way to uninstall your old version of the jre/jdk again after update

21:59 tomoj: anybody noticed lein-swank not putting src/ on the classpath?

22:44 konr: anybody using both clojure and CL on Emacs? Will I run into trouble trying to install them?

22:48 tolstoy: konr: I doubt it. You can always just try it and see. ;)

22:48 konr: I start up swank by hand and use M-x slime-connect, which pretty much solves all the classpath issues for me.

22:49 I just make a little shell script that builds the classpath and starts swank.

22:49 Seems like slime's smart enough to know which system it's attaching to.

22:50 tomoj: konr: here's my old config https://gist.github.com/a59bdb809b378b7f1da1

22:50 dunno if it will help

22:51 konr: tomoj, tolstoy: thanks, guys! I'm gonna play with it :)

Logging service provided by n01se.net