#clojure log - May 16 2010

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

0:00 defn: lespea: do you have a link to the requirements for this project?

0:00 i could try to write something and see if i have any stroke of genius

0:00 (rare in my case, but always worth a try)

0:01 lespea: I turned the warn-on-reflections on (or w/e the exact syntax is) and nothing is showing up?

0:01 rhudson: lespea, the map function could just be second; #(second %) wraps an extra function call around it

0:01 lespea: http://code.google.com/codejam/contest/dashboard?c=433101#s=p2

0:01 sexpbot: "Qualification Round 2010: Dashboard"

0:02 lespea: rhudson: wouldn't that just return the second item in the (take runs ...) list?

0:03 defn: is it too late to do the code jam lespea

0:03 lespea: rhudson: the (take runs) returns a bunch of vectors [[2 1] [1 4] [2 5]] etc

0:03 defn: I know I competed using perl since that's what I know, I'm just trying to learn clojure more

0:03 rhudson: It's that #(second %) === (fn [p] (second p)) , so map calls a function that calls second for every item

0:04 defn: yeah i feel like there is too much first, rest, and second going on in there, something is subtly wrong

0:06 lespea: rhudson: oh cool didn't know you could just remove map like that

0:06 maybe I should explain my logic an y'all can come up with a better way

0:07 defn: yeah sure, every bit helps

0:08 lespea: so I have a structure like this: [[2 3][0 6][1 3]] and what I want to do is look at the first one, see the first element is a 2, return the 3 as the first item in a seq, get item seq[2], see that points to 1 and put 3 in the return seq, etc

0:09 I just don't know how to return the second item every time so I return the the whole vector as each item in the sequence and then pull out the second item later

0:09 so ideally the function would return (3 times) [3 3 6] whereas right now it should be [[2 3][1 3][0 6]]

0:10 i think the get-income-fast method probably shows my logic better

0:11 defn: lespea: okay, hmm

0:12 lespea: will the length of that structure be consistent

0:12 lespea: which one? the [[2 3] etc one?

0:13 defn: yes

0:13 lespea: it won't change during the lookups (it's being setup before all the looping happens

0:13 rhudson: Yeah, I can see the correspondence between the two; I just don't see why get-income should be so much slower. Using (map second ....) vs (map #(second %)) is a slight inefficiency, but shouldn't make it 10 times slower

0:13 lespea: (let [ride-map (vec (map #(riders-for size % 0 riders)

0:13 (range (count riders))))]

0:13 oh, no it's way slower than the loop version

0:13 map second vs map #(second %) didn't make a difference really

0:15 rhudson: I'd say just go with get-income-fast then. It's not actually evil to use loop/recur!

0:16 It's actually a lot more readable than the other, aside from being a lot faster

0:16 lespea: rhudson: okay, in the end I'm just trying to understand clojure better... I thought it was shunned upon to use loop haha

0:17 I think it's pretty cool that the "lazy version" works at all honestly!

0:17 I'm pretty new to functional programming :/

0:17 it's fun! but mentally taxing haha

0:17 is the way i'm doing parse-int bad?

0:17 rhudson: It seems to be frowned on when reduce (or doseq or for or whatever) gives you cleaner code, but that doesn't seem to be the case here.

0:18 lespea: that's the other thing that looks "bad" to me

0:18 rhudson: makes sense

0:19 defn: rhudson: can you type hint to parseInt?

0:19 rhudson: like can you pass the final container type as an argument or hint the var or something?

0:20 lespea: I just stole that code from some guys blog because I was getting angry it wasn't detecting the numbers as such like perl haha

0:20 rhudson: You mean the Integer/parseInt call?

0:20 parse-integer looks ok to me, assuming you know your numbers are going to be in range.

0:21 defn: lespea: this might just be superficial but...

0:21 lespea: rhudson: yeah the string is always ints

0:22 surrounded by spaces

0:22 there isn't an easier way?

0:23 defn: ,(let [ [[k k2] n n2] [[2 3][0 6][1 3]]] [k k2 n n2])

0:23 clojurebot: [2 3 [0 6] [1 3]]

0:24 defn: ,(let [[[k k2] &ns] [[2 3][0 6][1 3]]] [k k2 ns])

0:24 clojurebot: java.lang.Exception: Can't take value of a macro: #'clojure.core/ns

0:24 defn: oops

0:24 ,(let [[[k k2] & nz] [[2 3][0 6][1 3]]] [k k2 nz])

0:24 clojurebot: [2 3 ([0 6] [1 3])]

0:24 defn: ack, ugly

0:24 i was thinking you could maybe set yourself up by destructuring and remove some of the stuff going on inside like the firsts and rests

0:25 lespea: defn: sounds above me haha

0:26 defn: lespea: nah not at all, i might be misunderstanding your problem

0:26 lespea: destructuring is your friend

0:27 lespea: examples i could read up on?

0:27 seths: ,(map #(vec %&) [1 2] [3 4])

0:27 clojurebot: ([1 3] [2 4])

0:28 defn: lespea: http://getclojure.org:8080/examples/let

0:28 that might take awhile to load, especially if a few people click it :X

0:28 lots of destructuring examples in there

0:29 rhudson: could do (reduce + (take runs (for [[nxtpos money] (iterate ....)] money))

0:29 technomancy: who wants to maintain swank-clojure.el? take in an orphan under your wing.

0:30 lespea: rhudson: oh that's a cool idea

0:31 wtf does ->> do?

0:31 rhudson: ,(->> 3 (- 7))

0:31 clojurebot: 4

0:32 lespea: lost me...

0:32 rhudson: ,(- 7 3)

0:32 clojurebot: 4

0:32 seths: technomancy: ask again after you come back from Hawai'i :-P

0:32 rhudson: It takes the first arg (3) and makes it the last arg of the next form (- 7 ,,,)

0:33 & keeps doing that for more forms

0:33 ,(doc ->>)

0:33 clojurebot: "([x form] [x form & more]); Threads the expr through the forms. Inserts x as the last item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the last item in second form, etc."

0:33 technomancy: heh

0:33 lespea: huh that's cool, so like you can chain things together?

0:34 rhudson: so you can write (--> a (b c) d e) instead of (e (d (b c a)))

0:34 sorry, ->> not -->

0:35 seths: technomancy: does swank-clojure need someone for the Clojure 1.2 release?

0:35 technomancy: seths: no, I'm about to push out a new release of the swank server

0:35 seths: but I'm no longer maintaining swank-clojure.el

0:36 seths: technomancy: will that go to ELPA or technomancy.us?

0:36 technomancy: the recommended way going forward is to launch your swank server using lein or mvn and connect via raw slime

0:36 seths: ah

0:37 * seths going to write a song named "connect via raw slime"

0:37 technomancy: seths: http://p.hagelb.org/swank-readme.html

0:37 sexpbot: "README.md"

0:38 seths: technomancy: that .html file is an .org file, but no -*- mode:org -*-

0:38 or maybe markdown

0:39 technomancy: seths: it's actually a markdown file that's been rendered as markdown-as-HTML

0:39 seths: it's from my personal pastebin, it's not the official docs

0:40 rhudson: ,(->> 5 range (map #(* 2 %)) (reduce +))

0:40 clojurebot: 20

0:44 defn: me no likey the ->> on that expression! :D

0:46 lespea: ,(->> 5 range (map #(* 2 %)))

0:46 clojurebot: (0 2 4 6 8)

0:46 lespea: I don't understand whey it goes up by 2 :(

0:47 ooooh

0:47 nevermind

0:47 it's doing range 5 first

0:47 then the map

0:47 cool beans

0:49 technomancy: OK, swank-clojure 1.2.0 is released.

0:49 next up: leiningen 1.2.0 (/me gulps)

0:49 (still a week or two away)

0:50 defn: bravo, technomancy

0:50 seths: technomancy: yay! looking forward to lein 1.2

0:50 defn: lespea: get it figured out?

0:51 seths: technomancy: package-list-packages shows swank-clojure 1.1, should I reconfigure it for technomancy.us?

0:51 lespea: defn: yeah I think so, it's pretty neat

0:52 seths: lespea: technically it does map first

0:52 lespea: so I was reading that java7 will have closures (officially) will that help out clojure a lot?

0:52 seths: ,(macroexpand '(->> 5 range (map #(* 2 %))))

0:52 clojurebot: (map (fn* [p1__16558] (* 2 p1__16558)) (clojure.core/->> 5 range))

0:52 technomancy: seths: I don't think you need any new elisp to use the latest swank-clojure.

0:52 just upgrade in your project.clj

0:52 seths: technomancy: awesome, thank you

0:53 technomancy: seths: you can get the latest slime (20100404) from my git, and I've submitted it to ELPA, but I haven't actually put it up on technomancy.us yet

0:53 but there's not a big difference

0:53 lespea: seths: right, i just thought it was going (range (map #(* 2 %) 5))

0:54 so does anybody else use vim for clojure programming?

0:57 dakrone: lespea: yes, quite a few people

0:59 lespea: dakrone: I'm using slimv and I was wondering if there is a way to stop the .... "results buffer" from stealing focus ever time you eval a statement

1:00 dakrone: ahh, sorry can't help, not a slimv user

1:01 lespea: I tried using the other one (clojure-vim or something) but couldn't get it working in windows

1:01 dakrone: could you map a <c-w><c-w> to the end of it?

1:02 lespea: dakrone: yeah that would probably work, not sure how it'd work if it took a while... i'll test

1:03 defn: how do i install to another drive from my current drive

1:07 lespea: dakrone: well it sorta works, just doesn't refresh the buffer if the call takes a while; don't know why i just didn't think of that haha

1:11 ninjudd: NetBeans is setting my hair on fire! cemerick must really hate me to trick me into proving that my patch doesn't break it...

1:12 is there anyone here who can help me set up a simple clojure netbeans platform application?

1:12 rdsr: Is there a way to dynamically plugin in method definitions to a class which is to be generated by "gen-class" macro?

1:13 lespea: so i'm just using plain old clojure 1.1.0, am I crazy for not using the latest dev version or does it not matter too much?

1:13 rdsr: I'm thinking of writing a wrapper macro on top of gen-class which could add new method definitions

1:14 ninjudd: lespea: this is the killer new feature that's in clojure 1.2: http://clojure.org/datatypes

1:15 rdsr: it may also solve your use case

1:16 rdsr: So I think I have to declare a var bound to the namespace in which the wrapper was called and create a method definition and bind it to the var

1:16 ninjudd: rdsr: http://clojure.org/protocols

1:16 rdsr: niinjudd: oh I'll havea look at it thanks

1:16 ninjudd: now, can anyone help me with fucking NetBeans?

1:20 _brian2_: noob quetion> I'm trying to call this java in clojure twitterStream = new TwitterStreamFactory(this).getInstance() , thi doen't work > (def twitterStream ( . (new TwitterStreamFactory) getInstance ))

1:20 ninjudd: ok, time to send hate mail to cemerick... i'm not waiting until monday

1:22 rdsr: _brian2_@: that looks weird to me, getInstance is a static method of TwitterStreamFactory right?

1:22 rdsr: does this work hi all, is there a way I could plug in function definitions

1:22 _brian2_: i'm not really sure, just a sec

1:22 rdsr: sorry about that

1:23 brain2 : does this work ? (def twitterStream (TwitterStreamFactory/getInstance))

1:23 _brian2_: yea, maybe, I gues I never understood the difference

1:24 i need to open a repl

1:31 ninjudd: technomancy: let me just say, compared to NetBeans, lein is so easy

1:32 when oracle bought sun, they should have offered them more it the didn't include NetBeans

1:33 s/it the/if they/

1:33 sexpbot: when oracle bought sun, they should have offered them more if they didn't include NetBeans

1:34 * ninjudd forgot how to type because he was so busy right clicking shit in NetBeans.

1:36 ninjudd: clojurebot: don't forget, NetBeans is evil, and i want you to tell people that whenever they mention it

1:36 clojurebot: Ack. Ack.

1:37 ninjudd: Ack Ack Indeed.

1:37 brixen: clojurebot: I'm thinking about using NetBeans for a project, good idea?

1:37 clojurebot: project euler is http://ProjectEuler.net

1:37 brixen: heh

1:39 * defn prays for a working circumspec sometime soon

1:48 _brian2_: rdsr : doesn't seem to work , but I don'tknow if its a static method, at least the docs don't say it is

1:48 Click here to find out more!

1:48 * Research Centers

1:48 * + Core Java

1:48 o Client-side Java

1:48 o Design Patterns

1:48 o Java Language

1:48 o Java Platform APIs

1:48 o Java Programming Concepts

1:48 o Swing/GUI Programming

1:48 o Threads/Concurrency

1:48 defn: uh oh

1:48 _brian2_: * + Enterprise Java

1:48 o Ajax/RIA/Web 2.0

1:48 o Architecture & Scalability

1:48 o Enterprise Best Practices

1:48 o Java & XML

1:48 o Java Web Development

1:48 o Web Services & SOAs

1:49 * + Mobile Java

1:49 * + Tools & Methods

1:49 o Application Servers

1:49 o Data Management/RDBMS

1:49 o Enterprise Middleware

1:49 o Java IDEs

1:49 o Java Security

1:49 o Open Source Tools

1:49 o Scripting/Other Languages

1:49 defn: _brian2_: part the channel and rejoin now please

1:49 _brian2_: o Software Development Lifecycle

1:49 o Software Development Methodologies

1:49 o Testing & Debugging

1:49 o Web Application Frameworks

1:49 * + JavaWorld Archives

1:49 o Design Techniques

1:49 o How-to Java

1:49 o Java 101

1:49 o Java Design Patterns

1:49 o Java Q&A

1:49 o Java Tips

1:49 o Java Traps

1:49 o Server-side Java

1:49 o Under the Hood

1:49 * Site Resources

1:49 * Featured Articles

1:49 defn: _brian2_: please part the channel, you are spamming

1:49 _brian2_: * News & Views

1:49 * Community

1:49 * Java Q&A

1:50 * JW Blogs

2:20 defn: did he part or quit?

2:20 i turned down my logging

2:35 hiredman: ping?

2:35 clojurebot: PONG!

3:20 dsantiago: If I'm trying to do a macro, and I want to pass the name of a variable as an argument to it, is there some way I can inside the macro's implementation get both the name and the value of the variable without fully evaluating it? (It's a list structure)

3:27 tomoj: dsantiago: maybe you can instead explain what you're trying to do?

3:29 dsantiago: I can try. I'm trying to write some macros that will let me define a named set of functions as a "default" protocol implementation, and then mix those in with overrides as specified by the user. All of which is passed to extend.

3:29 So I want to be able to write something like (mixin SomeType DefImpl), where DefImpl is a function map, and have that be turned into an extend.

3:30 tomoj: ok, I don't think I will be able to understand what you're trying to do :/

3:30 dsantiago: Heh, OK.

3:30 tomoj: but, does this satisfy your original question? (defmacro foo [x] `[~x ~(eval x)])

3:30 I mean, that is a terrible macro, of course, but macroexpand-1 it

3:30 e.g. with (def z '(1 2 3)), (macroexpand-1 '(foo z)) is [z (1 2 3)]

3:31 dsantiago: Yeah, that hasn't worked for me.

3:31 tomoj: actually, a simpler version is (defmacro foo [x] [x (eval x)])

3:33 dsantiago: The contents of x aren't something that can be evaluated.

3:34 tomoj: you said "name of a variable"

3:34 I assumed you meant a symbol

3:34 dsantiago: Yeah, I did.

3:34 tomoj: symbols can be evaluated..

3:35 (eval (eval x)) in my case above will try to eval (1 2 3), which will break, of course

3:35 dsantiago: Yeah, but it's something like (def test '((this) 1)). You don't want to evaluate test.

3:35 tomoj: but x is 'z, and (eval 'z) is just '(1 2 3)

3:35 if you evaluate 'test you'll get '((this) 1)

3:35 don't evaluate the result of that, though

3:36 dsantiago: Oooooh.

3:36 Right on.

3:36 That does the trick! Thanks.

3:36 tomoj: note that the symbol must resolve at macro-time

3:36 dsantiago: Yeah, it would in my case.

3:37 tomoj: so you couldn't do e.g. (let [z '(1 2 3)] (foo z))

3:37 good luck, then

3:37 dsantiago: Thanks man.

3:37 tomoj: I feel like the language I've been using just now is very imprecise :/

3:39 dsantiago: No more imprecise than mine.

3:50 rava: hello

3:54 mind if i ask a few simple questions about compojure not importing?

3:57 nvm, looks like i just needed to find more up to date information

4:35 Borkdude: ,(clojure-version)

4:35 clojurebot: "1.1.0-master-SNAPSHOT"

4:38 Raynes: Borkdude: sexpbot is running 1.2

4:38 Borkdude: chouser: I am reading section 5.3.3 of TJoC, but I'm not sure I get the example

4:38 Raynes: aha..

4:39 $(let [r (range 1e9)] [(first r) (last r)])

4:39 sexpbot: Execution Timed Out!

4:39 Borkdude: hmm

4:39 ,(let [r (range 1e9)] [(first r) (last r)])

4:40 clojurebot: Execution Timed Out

4:44 Borkdude: In Clojure 1.2 the example doesn't generate a heap space problem, because last r doesn't hold on the the head and local r gets cleared when (last r) starts executing?

4:46 $1e9

4:46 sexpbot: Command not found. No entiendo lo que estás diciendo.

4:46 Borkdude: $(print 1e9)

4:46 sexpbot: result: 1.0E9

4:47 Borkdude: $(let [r (range 1e9)] (last r))

4:47 sexpbot: Execution Timed Out!

4:47 Raynes: Borkdude: You can do $eval for stuff like that.

4:47 $eval 1e9

4:47 sexpbot: result: 1.0E9

4:48 Raynes: The reason it didn't work before is because the way I do $() is hackish. ( is seen as a command. :p

4:48 Borkdude: $+ 1 2 3

4:48 sexpbot: Command not found. No entiendo lo que estás diciendo.

4:49 Borkdude: $(+ 1 2 3)

4:49 wooby: $'1e9

4:49 sexpbot: Command not found. No entiendo lo que estás diciendo.

4:49 result: 6

5:11 kotarak: $(do 1e9)

5:11 sexpbot: result: 1.0E9

5:29 elean: is there an easy way to do something like "1 -> [1]" "[1] -> [1]"

5:30 in other words make a number, one-element list; and if given a list keep it a list ;]

5:32 kotarak: ,(let [to-vector #(or (and (vector? %) %) [%])] [(to-vector 1) (to-vector [1])])

5:32 clojurebot: [[1] [1]]

5:33 tomoj: why not use if?

5:33 kotarak: tomoj: sheesh... if... ;)

5:34 elean: kotarak: yeap.. does the trick, but after few weeks of clojure I though there was some magic "x" function already ;D I guess I'd use this one then

7:30 r0man: hi all, some months ago i was using incanter-chrono in one of my projects. it seem like it is no longer maintained. what's the new way to go? what are you using? clj-time?

7:37 AWizzArd: Moin r0man, simplesimon2k und robo___ :-)

7:37 esj: r0man: try clj-sys

7:38 it has chrono in it now

7:38 r0man: esj: ok thx, that's what i wanted to hear :)

8:38 TheBusby: er, what's the current (1.1.0) code to generate a lazy fibonacci sequence? (all the old posts don't seem to work any longer with lazy-seq in 1.1.0)

8:44 arg, nmind realized a typo was throwing me off...

9:05 emh: can I override toString on a record?

9:05 Raynes: emh: Yes.

9:08 emh: Raynes: I specified Object as the protocol and (toString [this] (java.lang.Integer/toBinaryString (:subset this))) as the method. I can call it, but print doesn't use it. what's wrong?

9:08 Raynes: I don't know. I don't think I've ever done that before. I just know that it's possible.

9:12 * Hodapp grumbles at how he can't use 'int' in a Java collection

9:18 mmarczyk: emh: you should probably look into print-method

9:22 AWizzArd: emh: or print-dup

9:22 (defmethod print-dup YourRecord [r, writer] (.write (str "Name: " (:name r)))) something like that

9:23 for (defrecord YourRecord [name a b c])

9:23 (binding [*print-dup* true] (print (YourRecord. "emh" 1 2 3)))

9:23 same with print-method

9:24 though, print-dup should really write something readable.

9:37 stribb: hi there, trying to work out why lein isn't working for me...

9:38 http://pastebin.org/241659 is a brief synopsis of the problem

9:41 lein uberjar; java -jar <jarfile> works

9:42 but lein repl and lein swank both fail

9:45 rdsr: hey all, is it possible to define a var in namespace "A" from namespace "B"

9:45 ?

9:55 Borkdude: rdsr: I get a "java.lang.Exception: Can't create defs outside of current ns" if I try to do that

9:55 so I think not

10:01 rdsr: Borkdude: hmmmm, what I really wanted was to plug a function definition dynamically while calling gen-class

10:11 otfrom: stribb: I'm having a similar problem to you moving to clojure 1.2.

10:13 does anybody have a basic project.clj that works with swank-clojure and clojure 1.2?

10:14 The project I have at the moment works fine with clojure 1.1, but I want to try out some of the new defrecord stuff in 1.2.

10:16 stribb_: did you get your lein swank stuff fixed?

10:16 stribb_: nope

10:17 otfrom: me neither

10:17 google isn't providing much clarity atm either (though that is probably my failure)

10:18 stribb: Stuart Halloway has something that works under labrepl - http://github.com/relevance/labrepl/blob/master/project.clj

10:18 though I get problems with my unit tests when I make my project.clj look like that.

10:19 stribb: are you using emacs-starter-kit and elpa as a start?

10:20 stribb: been using emacs for years

10:20 but elpa, yeah

10:21 otfrom: I dumped my 4kloc .emacs for emacs-starter-kit. ;-)

10:24 stribb: no way I could do that, got my org-mode just right and there are some custom functions I can't do without

10:24 <shrug>

10:24 don't think emacs is the problem here

10:25 the expected workflow is lein swank, in the console, then M-x slime in emacs, right?

10:26 otfrom: I've been pulling some of my org-mode bits and others into a separate file, but yeah I did dump a lot.

10:26 I'm doing M-x slime-connect from a clojure file

10:26 stribb: still, the "lein swank" bit has to work first, right?

10:27 otfrom: my project.clj is here: http://pastebin.org/241679

10:27 so I get swank up and running, but then I can't actually do any work with it.

10:27 The only change is moving from clojure 1.1 to clojure 1.2.

10:28 and adding :repositories

10:28 yes, the lein swank needs to work first to connect to

10:29 stribb: interesting: I haven't qualified the lein-swank as leiningen/

10:30 it's just plain in my .prj

10:30 maybe that's my problem

10:30 tcrayford: stribb: slime-connect

10:30 M-x slime-connect

10:30 unless swank is still failing

10:31 if it is, shoot for what the errors are

10:31 otfrom: I was having trouble with 1.2. lein swank started working when I went to lein-swank 1.1.0

10:31 tcrayford: heh

10:31 that might be my fault

10:31 otfrom: oh?

10:31 It would be nice to have fixed before the next dojo. ;-)

10:31 tcrayford: I authored xref support (slime-who-calls) into swank

10:31 also hi otfrom

10:31 otfrom: hi

10:32 tcrayford: I'll probably be doing my talk on monads at the june dojo, unless uncle bob makes his blog post on em before then

10:32 stribb: so when I look at swank.clj -main

10:32 it just runs start-repl

10:32 with no args

10:32 otfrom: tcrayford: that'd be cool

10:33 stribb: but start-repl requires at least one arg

10:33 tcrayford: stribb, none of that should be any problem

10:33 can you paste the error you get?

10:33 stribb: tcrayford: http://pastebin.org/241659

10:34 tcrayford: that's weird

10:34 otfrom: tcrayford: I got the same before rolling back to swank-clojure 1.1

10:34 I'm using emacs, emacs-starter-kit and elpa, btw

10:34 tcrayford: yeah

10:34 weird, because I have EXACTLY the same setup

10:34 clojurebot: dirt simple setup is http://www.thelastcitadel.com/dirt-simple-clojure

10:34 rdsr: stribb: I have clojure-1.2 and swank-clojure compile from source

10:34 tcrayford: and 1.2.0 works here

10:35 rdsr: strib: it works fine for me

10:35 only problem is that "lein help" fails

10:35 otfrom: tcrayford: can you post your project.clj?

10:35 stribb: it's possibly alo interesting that when I make the uberjar, it includes 1.1.0 and 1.2.0-snapshot for both clojure and clojure-jar

10:35 tcrayford: rsdr: can you try using `slime-who-calls` over a function name

10:35 otfrom: or paste rather

10:36 rdsr: in which ns is the fn defined

10:36 ?

10:37 tcrayford: rsdr: using emacs


10:37 rdsr: oh ok

10:37 tcrayford: M-X `slime-who-calls`, over like defn or summat

10:37 otfrom: http://pastebin.org/241685

10:38 rdsr: something like the var shoul

10:38 sorry

10:38 1 sec

10:38 error in process filter: who-calls is not implemented yet on clojure.

10:38 this is the result I get

10:39 tcrayford: heh, emacs just crashed because I pressed some crazy slime thing by accident

10:39 did you get who-calls working?

10:39 it should take a while (depending on the speed of your HD)

10:41 rdsr: tcrayford: it gives me the following error "error in process filter: slime-check-xref-implemented: who-calls is not implemented yet on clojure.

10:41 error in process filter: who-calls is not implemented yet on clojure."

10:42 tcrayford: rsdr: and that's with swank 1.2?

10:42 otfrom: Tried a cut down version here: http://pastebin.org/241686

10:42 and still get java.lang.Exception: Unmatched delimiter: )

10:42 when I do a M-x slime connect in the unit test file

10:42 tcrayford: ah

10:43 you need the latest version of clojure-test-mode

10:43 (from technomancy's github)

10:43 otfrom: ok, do I need the latest clojure-mode as well?

10:43 tcrayford: don't think so

10:43 I don't have it anyway

10:43 rdsr: yes 1.2.0-SNAPSHOT

10:43 tcrayford: it isn't on elpa yet, waiting for upload

10:44 rdsr: can you try with just 1.2.0?

10:44 that should have who-calls in it

10:45 note that who-calls only works if you have loaded each namespace by using 'use' or 'require' at the repl, otherwise :file metadata doesn't get set

10:45 (something I can't fix at all, unfortunately)

10:46 rdsr: let me try that

10:46 stribb: I get the impression lein and swank-clojure are in a state of flux at the moment and that if I try again in a couple of weeks everything Might Just Work

10:46 otfrom: needs latest clojure-mode as well

10:46 mmarczyk: rdsr: for creating Vars in other namespaces, check out e.g. intern

10:46 tcrayford: they're both waiting for clojure 1.2 to be released proper, then they should be stable enough

10:47 rdsr: though using intern is kinda icky

10:47 rdsr: I have clojure-mode 1.6

10:47 stribb: tcrayford: any idea how soon that's likely to be? are we talking days, weeks or months?

10:47 rdsr: oh thks mmarczyk

10:47 mmarczyk: rdsr: Leiningen uses something like "with-ns" (not sure about the name or where it comes from right now) to inject defproject into clojure.core

10:47 tcrayford: no idea

10:47 stribb: fair enough

10:48 tcrayford: most stuff *should* keep on working

10:48 clojure 1.0 isn't compatible with the latest version of the tools though

10:48 otfrom: tcrayford: installing the latest clojure-mode and clojure-test-mode from github seems to work

10:48 thx

10:48 tcrayford: no worries then

10:49 rdsr: tcrayford: it works now

10:49 tcrayford: and properly?

10:49 rdsr: yes

10:49 let me paste the result

10:49 1 sec

10:49 tcrayford: it'll be long if you're doing it on defn

10:49 rdsr: I ran slime-who calls on source

10:49 clojure/repl.clj

10:49 source

10:49 clojure/contrib/repl_utils.clj

10:49 source

10:49 this is what is gives me

10:49 tcrayford: that sounds about right

10:50 awesome then

10:50 note, if you (use 'some-ns) at the repl, then you can use who-calls inside that ns as well

10:50 rdsr: cool

10:50 thks

10:50 otfrom: cool. Looks like I'm cooking with clojure 1.2 now. :-D

10:50 tcrayford: otfrom: same to you with who-calls

10:50 otfrom: thx tcrayford

10:51 tcrayford: it was scary how easily that was to implement

10:51 also gogo push latest version of clork

10:52 otfrom: slime-who-calls works for me

10:52 technomancy: otfrom: yeah, sorry--there were some issues with lein-swank 1.1.0

10:52 I should have released a 1.1.1 to fix the bad stuff while 1.2.0 was cooking

10:53 tcrayford: technomancy:

10:53 otfrom: technomancy: no problem. Just wanted to get things working for the dojo.

10:53 tcrayford: the only real issue with who-calls is that it won't work on functions you compile interactively, only on things made by `use` or `require`

10:54 otfrom: tcrayford: yeah. I'll push the latest version with just the changes for 1.2. I suppose I'll need to include instructions on how to get newest versions of clojure-mode and clojure-test-mode for people though.

10:54 tcrayford: technomancy: not sure how to fix that though, as getting the metadata set correctly is probably a pain

10:54 technomancy: otfrom: when's the dojo? clojure-test-mode should be in elpa soon

10:54 I can bug the elpa maintainer; that might help.

10:54 tcrayford: last tuesday of each month

10:55 otfrom: the dojo is 25 May

10:55 * tcrayford dislikes that he can't make the dojo *again*

10:55 technomancy: where is it again?

10:55 tcrayford: london

10:55 otfrom: ThoughtWorks, High Holborn, London

10:55 technomancy: cool

10:56 is it mostly collaborating on projects then?

10:56 otfrom: and occasionally at Fry-IT, and possibly other places to

10:56 tcrayford: one project

10:56 otfrom: technomancy: mostly just us flailing around learning clojure.

10:56 tcrayford: (mostly flailing around learning emacs)

10:56 otfrom: no one really knows what they are doing so it is quite fun. :-)

10:56 tcrayford: *coughs*

10:57 otfrom: sorry, no one really knows what they are doing, but tcrayford is really bad so he makes us all feel better as we have to help him a lot. ;-)

10:57 technomancy: nice

10:57 tcrayford: that's better

10:58 technomancy: we just started doing more coding at the Seajure meetings, which I like a lot more than our past meetings of all talk

10:58 tcrayford: are you just collaborating on projects?

10:58 otfrom: we seem to be doing short talks and then the dojo

10:58 http://github.com/ldncljdojo

10:58 technomancy: tcrayford: we did this at the last one: http://github.com/technomancy/serializable-fn

10:59 just coming up with a tricky problem to try to solve as we start out the meeting and then collaborating on it

10:59 "swarm coding"

10:59 otfrom: about a 50-50 split between Java coder and Pythonistas

10:59 tcrayford: does seriazable-fn do locals properly?

10:59 might be able to use that for refactoring-mode

11:00 technomancy: tcrayford: yeah, it has a few issues with serializing the closures though; not all types can be serialized if they're closed over

11:00 I think it could be made to work reliably; I'm just focused on other things right now

11:00 tcrayford: I only really care about what vars are bound in a given subexpression

11:00 don't really care about values

11:00 technomancy: you should try it

11:01 tcrayford: it'd save a lot of pain if it does

11:01 there's like 150 lines of recursive pain for looking at vars

11:01 (in refactoring-mode)

11:02 technomancy: tcrayford: actually that probably won't work

11:02 tcrayford: because?

11:02 technomancy: you have to use serializable-fn's fn var rather than clojure.core

11:02 tcrayford: I can just nick bits of its implementation

11:02 (whichever bit cares about locals for closures)

11:03 technomancy: it can't serialize just any fn; it's a way of generating special fns that are serializable

11:04 tcrayford: I can redefine an fn when I'm examining a users code

11:04 in a different namespace

11:05 but yeah, thats kinda hacky

11:29 mattrepl: technomancy: swank-clojure-project is deprecated?

11:36 emh: mmarczyk: AWizzArd: thx! that worked. trying to figure out how to make it work with pprint now

11:38 otfrom: mattrepl: yes, use lein swank and M-x slime-connect now.

11:41 technomancy: mattrepl: deprecated is not quite it. it's "in search of a maintainer"

11:41 mattrepl: if it works for you, continue using it

11:42 I'm just concerned about it confusing folks new to the language; lein swank is a lot more foolproof

11:47 mattrepl: is there a discussion of the issue(s) anywhere?

11:51 otfrom: tcrayford: changes pushed to ldncljdojo repo

11:54 tcrayford: otfrom: cheers

12:02 mattrepl: otfrom: just came across a paste you made about the "unmatched delimiter )" when connecting to swank-clojure. did you figure out what was wrong?

12:22 nm, re: "unmatched delimiter", found in log

12:25 otfrom: mattrepl: yes. Fixed it with the help of technomancy and tcrayford. Posted about it here: http://wp.me/ppA5G-K

12:25 sexpbot: "leiningen, clojure 1.2 and emacs « Wifi and Coffee"

12:25 mattrepl: otfrom: thanks

12:26 otfrom: np

12:32 LauJensen: Evening all

12:35 emh: overriding pprint was done same way, but overrididing simple-dispatch instead of print-method

12:44 mattrepl: otfrom: interestingly, after installing clojure-mode 1.7.1 from a buffer, installing clojure-test-mode from a buffer fails saying that 1.7 isn't available, only 1.6 (even though 1.6 was deleted via the list-packages buffer and verified that it was, in fact, removed from elpa dir)

12:55 mabes: hrm.. I can't seem to "use" a ns with a defrecord and then use the constructor of the type defined... I get a "Unable to resolve classname" error. I've tried compiling it but no luck.. Is there a trick to use records defined in another ns?

12:57 Kjellski: Can someone give me a hint why this snipped does not create a JFrame that has a GridLayout?

12:57 (def frame

12:57 (doto (new JFrame "Test")

12:57 (.setLayout (new GridLayout height width))

12:57 (.setSize 400 400)

12:57 (.setVisible true)))

12:58 AWizzArd: Kjellski: what happens instead?

12:59 Kjellski: I'm getting a JFrame with a BorderLayout =(

12:59 AWizzArd: sieht eigentlich gut aus soweit...

12:59 Well, in his example at http://clojure.org/jvm_hosted Rich gave four arguments to the constructor.

13:06 otfrom: mattrepl: not sure, possibly try restarting emacs? Worked all at once for me.

13:17 arohner: mabes: what version of clojure are you running? recent 1.2 snapshots got rid of the var constructor

13:17 mabes: so if you do (defrecord record) in ns foo.bar, it just makes a class foo.bar.record

13:17 so just do (foo.bar.record. args)

13:24 otfrom: do you still have to do foo.bar.record. if you do :use foo.bar?

13:46 emh: otfrom: (:import foo.bar.record) enables the unqualified name, since a record is a Java class. idk if it's a good way to do it

13:51 Kjellski: Anybody here with the rights to change examples on clojure.org?

13:53 The example from http://clojure.org/jvm_hosted seems to use a JFrame, but it is not... weird as swing is, there needs to be an underlying JPanel in order to set the layout correctly...

13:54 *err* replace JFrame with GridLayout

14:03 otfrom: emh: thanks. Does anyone know if there are there any good examples out there?

14:14 qbg: Kjellski: JFrames contain a contentPane in which the components go

14:15 _brian2_: technomancy : is the compojure tutorial still current?

14:19 Kjellski: qbg: Yes, but the example from that page is missing that point... this setLayout leads to nothing but an BorderLayout in that JFrame... ;)

14:19 LauJensen: There wouldn't happen to be a real X11 + Nvidia + Ubuntu expert hiding in here? :)

14:20 Kjellski: LauJensen: What would he need to answer?

14:20 LauJensen: I would tell him in private as not to clutter #clojure :)

14:23 qbg: Kjellski: The layout manager in the content pane should be a GridLayout with that code

14:27 maacl: Does anyone have an example of how to do file uploads using compojure 0.4 / ring?

14:35 _brian2_: maac1 : there is also a compojure mail list

14:36 shevrondeluca: Hey everyone. I'm trying to write an article 'bout clojure. For that I try to find some great examples. Are there any good collections with great programs using clojure?

14:39 tomoj: the other day my cousin (known for his bullshit) tried to talk to me about programming: "so are you using any new programs?" "uh, yeah, there's this one called clojure that's kinda new" "oh, yeah, they used that for this database I worked with at motorola" "...awesome" "no, it was a shitty program. cool way to program, but they screwed it up"

14:42 maacl: _brian2_: yeah I know, but people here are usually really helpful with compojure

14:42 LauJensen: maacl: The old routines from 0.3.x arent working?

14:43 maacl: LauJensen: nope - they are gone

14:43 LauJensen: oh - I used some apache lib, didnt know compojure had its own

14:43 apache commons FileUpload

14:44 maacl: ah - is there an example somewhere?

14:44 LauJensen: I never published it, but I can go look

14:45 _brian2_: noob question > how to do this java instantiation > http://clojure.pastebin.com/DJu5pi0F ?

14:46 LauJensen: maacl: went something like this http://gist.github.com/403077

14:47 maacl: LauJensen: thanks

14:47 LauJensen: np

14:48 qbg: _brian2_: The last line would be (.getInstance (TwitterStreamFactory. this))

14:48 tomoj: ring has stuff to do this

14:48 trying to extract an example now

14:48 _brian2_: qbg : ok thnks !

14:49 AWizzArd: btw, does ring have something for encoding handling?

14:49 qbg: _brian2_: you are going to need this from somewhere though

14:49 maacl: tomoj: thanks a lot!

14:49 AWizzArd: For example, when I request (via jnlp) a .jar for Web Start, then this could be encoded in pack200 or at least gz

14:49 _brian2_: qbg : not sure "from" means

14:50 I'm using it locally

14:50 qbg: In Java, you would probably be executing that in a class, right?

14:50 AWizzArd: Is there a ring handler that can manage to send out one of the three files that I have (file.jar, file.gz or file.jar.pack.gz), depending on what the Client is requesting?

14:50 _brian2_: right

14:51 why does that matter?

14:52 qbg: There really isn't a 'this' concept in clojure unless you are using proxy/reify/etc.

14:52 maacl: LauJensen: I think the syntax for routes has changed to because the gist doesn't work - I get Unsupported binding form: (:servlet-request request)

14:52 _brian2_: ok, this is another form of the method that calls string arguments

14:53 there is, i mean

14:53 LauJensen: maacl: As I recall thats now tucked away in some multipart middleware

14:53 I have used it with C4.0 now that I think of it

14:53 _brian2_: twitterStream = new TwitterStreamFactory().getInstance(args[0], args[1]);

14:55 qbg: Do you want to get the arguments from a java array?

14:56 _brian2_: no,they are strings (i guess), username and password

14:56 or maybe char[]

14:56 qbg: (.getInstance (TwitterStreamFactory.) "something" "otherthing")

14:56 For instance.

14:57 _brian2_: hmm. I think I forgot the period in back of factory

14:59 maacl: LauJensen: You mean ring middleware?

14:59 _brian2_: qbg > "Can't call public method of non-public class"

14:59 LauJensen: yea

15:04 qbg: _brian2_: That's weird

15:04 _brian2_: qbj : it is called within a class that implements another class : http://clojure.pastebin.com/t1VvTCjC

15:05 i'm digging into the source code

15:12 tomoj: is it just me or is compojure RC2 borked

15:16 well, anyway, maacl, look at ring.middleware.multipart-params/wrap-multipart-params

15:17 maacl: tomoj: yeah, got that far but I can't get it to work

15:17 tomoj: do you see the file info in the request?

15:18 _brian2_: (def twitterStream ( . (new TwitterStreamFactory) getInstance "brw314" "sera1024" ))

15:23 maacl: tomoj: trying to find out now :-)

15:39 islon: why this code doesn't need a "do" special form? (defn stuff [] (assert (= 2 3)) (assert (= 5 4)))

15:41 Licenser: islon: becase def has in implict do :)

15:44 hrm when I work with java IO how is the best way to make it thread / transaction save.

15:44 islon: Lincenser: thanks =)

15:44 Licenser: I have an transaction that HAS to do IO, it is not bad if it happens more then once as long as the latest running transaction does the last IO.

15:44 Are agents the right way?

15:45 then again I need it to finish within the transaction and agent's delay so they are not a good way I fear

15:46 islon: " However, sometimes you

15:46 want a side effect when a transaction succeeds. Agents provide a solution. If you send an action to an agent from within a transaction, that action will be sent exactly once, if and only if the transaction succeeds." Stuart's book

15:47 Licenser: islon: and thank you in return!

15:47 that is VERY nice :)

15:49 islon: the book is amazing =)

15:51 tomoj: problem with that is that the transaction might complete without the IO happening

15:51 the action will be sent iff the transaction succeeds, but some if a catastrophic failure happens right after the action is sent...

15:52 or some IO error maybe

15:56 islon: you can do the IO right inside the transaction in a try catch if you don't mind the "happen more than once"

15:57 but transactions + IO are a bad mix

15:59 emh: using deftype instead of defrecord makes overriding toString() and seq() work

15:59 but (doc defrecord) says: You can also define overrides for methods of Object.

16:15 * ober looks for a "close all parens" in slime shortcut

16:16 tcrayford: use paredit

16:16 profit

16:16 http://www.slideshare.net/mudphone/paredit-preso might help

16:16 sexpbot: "Paredit Preso"

16:16 ober: alt-return. there it is

16:17 it's ??\n profit

16:17 tcrayford: there isn't any ?? in using paredit

16:17 after you know the keybindings at least

16:18 Kjellski: Could someone give me a hint how to tell netbeans that I would like to do something with the libs I´ve included? I´ve added the jars to my library with it and clojure can not find the added dependencies...

16:19 ober: oh it's a minor mode

16:19 thought it was an alternative editor

16:19 tcrayford: nope

16:19 paredit is king once you know how to use it

16:19 ober: oh look who wrote it. yeah that guy....

16:19 tcrayford: I think its the reason lisp isn't that popular: editing sexps without paredit is painful

16:23 tomoj: Kjellski: do you really want to let netbeans handle that?

16:23 Kjellski: I would like to, yes. What solution would you recommend?

16:23 tomoj: I think that would mean other people won't be able to run your project easily (which may not be a problem for you)

16:24 the most popular solution right now is leiningen

16:24 islon: leiningen is a solution, don't know if it works with netbeans

16:24 Kjellski: tomoj: I´m actually on windows... and there it's not that comfortable to use leiningen =(, what do you recommend?

16:24 tomoj: ah

16:24 you wouldn't like my recommendation

16:25 good luck :(

16:25 Kjellski: ;) reboot to ubuntu?

16:25 =P

16:25 tomoj: yeah, something like that

16:25 Kjellski: ^^ damned... thought you would think of something like that...

16:26 islon: or use clojure box

16:26 tomoj: I think people are working on windows support for leiningen

16:26 some maybe one day soon it will be comfortable

16:26 anyway clojure should find deps just like java would -- the jars just need to be on the classpath

16:27 Kjellski: Actually I've set it up... and it seems like it's building project from git repos... but I won't end up using something like notepad++ for coding clojure =8

16:27 tomoj: Install cygwin and vim ... *grml* thought of an easier way... ^^

16:28 islon: is the actual clojurebox aware of leining projects?

16:28 maacl: tomoj: I only seem to get a ArrayMap with {file <filename>}

16:29 islon: Kjellski, i dont think so, but it's better than netbeans

16:30 tomoj: maacl: ring version?

16:30 islon: and you can put your dependencies in ~/.clojure

16:30 tomoj: putting deps in ~/.clojure doesn't sound better than much to me

16:30 Kjellski: islon: Whoot? Just stuff the jars in there?

16:30 maacl: tomoj: 0.2.0

16:30 tomoj: unless you only work on one project...

16:31 Kjellski: What about creating a leining project and edit the files and so on with clojurebox?

16:31 islon: Kjellski, yeap, and configure your .emacs

16:32 Kjellski: islon: Would you assist if I run in trouble?

16:33 maacl: tomoj: this is my code http://paste.lisp.org/display/99317

16:34 islon: something like that (setq swank-clojure-jar-path "~/.clojure/clojure.jar"

16:34 swank-clojure-extra-classpaths (list

16:34 "/whatever"

16:34 "~/clojure"))

16:35 tomoj: maacl: check the html source of your form

16:35 multipart true?

16:35 technomancy: Kjellski: the simplest thing to do is launch a swank server from leiningen and use M-x slime-connect within Emacs to join it

16:35 Kjellski: islon: thanks so for, I´ll give that a try... =)

16:35 technomancy: you just add [swank-clojure "1.2.0"] to your dev-dependencies in project.clj

16:36 Kjellski: technomancy: okay, that sounds even better =)

16:36 technomancy: Kjellski: I just updated the swank-clojure docs to explain this: http://github.com/technomancy/swank-clojure#readme

16:36 Kjellski: that should let you work around some windows quirks if you've already got lein running

16:37 Kjellski: technomancy: *lol* read that two seconds ago, thanks for that specific thing I'm looking for! ^^ I owe you a coffee ;)

16:37 technomancy: heh; great

16:37 hope it works

16:38 Kjellski: technomancy: I´ll let you know

16:38 technomancy: I don't have a windows box to test on, so I rely on others to help with platform-specific issues.

16:39 Kjellski: technomancy: Is there a better way to bring the necessary stuff working on windows than installing the clojure box?

16:39 technomancy: Kjellski: sorry, I don't know. I've heard good things about clojure box, but I don't know if it's been updated in a while.

16:39 Kjellski: technomancy: I´m right into that, update in about 20 min ;)

16:40 technomancy: hope it works well

16:41 maacl: tomoj: nope - that's annoying

16:41 * tcrayford starts reading onlisp

16:41 tomoj: yes, not sure how to get hiccup to make the form multipart

16:42 ah, map as first argument I think

16:42 (form-to {:multipart true} ...) or something like that?

16:43 * tcrayford used jquery's ajax upload plugin when he was doing file uploading with compojure

16:48 Kjellski: technomancy: damnes, that rocks! Just added the dependecy, installed clojurebox, ran "lein deps", in emacs "M-x slime-connect" and here I am. Running like a charm on Windows 7 64 Bits. You did a great job! Thanks.

16:49 technomancy: heh; that's nothing new. the only difference is one of making documentation clearer. =)

16:49 which I guess is a big deal.

16:50 Kjellski: technomancy: Yes it is. For me, relatively new to clojure and it's great projects, it's extremely important...

17:00 tcrayford: technomancy: I wasn't even using clojure before lein came along

17:00 technomancy: I tried, but got annoyed at it

17:10 maacl: tomoj: (form-to {:enctype "multipart/form-data"} works :-)

17:11 tomoj: bizarre

17:11 Kjellski: How can I add a dependency to a lein project like clj-pivot? What exactly needs to be typed?

17:13 tomoj: oh, I hadn't written a file upload field by hand in so long that rails tricked me into thinking it was <form multipart="true"> :(

17:16 maacl: tomoj: no prob - trying to find out how to control which dir it places the tempfile in

17:17 tomoj: maacl: why does it matter?

17:18 maacl: tomoj: I am a control freak :-)

17:19 tomoj: I think you need to .setRepository on file-upload

17:20 unfortunately it seems to be private

17:20 oh, actually, it's not file-upload you want anyway, but the factory, hmm

17:20 I think you will not be able to change it without hacking the middleware

17:21 maacl: tomoj: I seem to recall seeing an option on the middleware somewhere

17:22 tomoj: not the one I'm looking at

17:22 only option is encoding

17:23 aren't you just going to move them out of the temp directory immediately anyway?

17:23 nollidj: i've new to clojure and have a question about the hash type. is there a way to get a reference to the object that is used to key an entry?

17:24 something along the lines of (get-key map key), which resolves to a referene to the key that is actually used in the map entry?

17:24 Chousuke: hmmh.

17:24 nollidj: this isn't possible with a vanilla java.util.Map, so if clojure doesn't offer a special way to do that, i don't think there's an easy way to get it

17:25 Chousuke: I think there might be a java method for it.

17:25 maacl: tomoj: yeah, that might be the solution

17:25 Chousuke: getEntry or something?

17:25 maacl: tomoj: I guess that a move isn't that expensive

17:25 tomoj: File/renameTo I think

17:25 nollidj: Chousuke: i'm looking at http://java.sun.com/javase/6/docs/api/java/util/Map.html now, and it doesn't look like it

17:25 sexpbot: "Map (Java Platform SE 6)"

17:25 Chousuke: nollidj: no, I mean in the clojure map interface.

17:26 tomoj: (well, it's not static)

17:26 nollidj: ah, cool

17:26 Chousuke: nollidj: but I'm not sure; I just have a vague feeling I've seen something like that somewhere :P

17:26 nollidj: is there a doc for that somewhere? i'm still not up on where to look

17:26 http://richhickey.github.com/clojure/ is all i know now

17:27 Chousuke: no docs for the java APIs but contrib has the "show" function in some namespace which might help you

17:27 nollidj: how might i load the show function?

17:27 Chousuke: just figure out the namespace it is in (I think repl-utils?) and require it

17:28 look at the contrib docs

17:28 nollidj: okay. thanks

17:28 tomoj: yeah, clojure.contrib.repl-utils

17:29 Chousuke: but if you can't find a suitable method then one probably doesn't exist

17:30 what kind of key do you have that you need the exact object?

17:31 nollidj: i'm getting a quick course in clojure by writing a chart parser

17:31 using the cky algorithm

17:32 a chart entry is keyed by something like (span-start, span-end, span-symbol) with a value like (probability backpointers)

17:32 backpointers is a list of chart entry keys

17:32 so, ideally, i'd be able to make it a list of already allocated chart entry keys

17:32 ...if that makes sense

17:34 tomoj: so you're just trying to save memory?

17:34 Chousuke: hmm, right.

17:34 nollidj: more or less. it's a relatively trivial issue, but i'd like to be able to do it this way if i can

17:34 Chousuke: nollidj: maybe you need some kind of a lookup cache for them?

17:34 nollidj: i could just write my own cache or make the chart map a subclass of map that keeps track of its key objects

17:34 i was hoping there'd be a way around that

17:35 Chousuke: nollidj: use a set to store the keys you allocate maybe?

17:35 nollidj: that's what i would do if there weren't an easy way to pull the key out of the map, yeah

17:36 rhudson: nollidj, hashmaps just aren't designed to map backwards (value->key)

17:36 nollidj: rhudson: i don't want to do that. i want to go (object that has identical fields to key)->(key already in map)

17:37 so that i can pass around references to a key without creating dozens of identical key objects, instead using the one in the map

17:37 because, in my case, certain map values will have references to map keys

17:37 so if i have 300 map values that all refer to the same entry, i don't want 300 unnecessary duplicates of what's really the same key object

17:38 ...now that i think about, i can just make a function to generate key objects and have it intern/memoize values as necessary

17:38 rhudson: yep

17:39 tomoj: ,(key (.entryAt {:foo :bar} :foo))

17:39 clojurebot: :foo

17:39 tomoj: like that?

17:39 Chousuke: ah, so there was a method.

17:39 nollidj: tomoj: yeah... i just found select-keys, which looks like it's similar

17:39 problem solved

17:40 still getting the hang of working with a repl loop and having a lot to command quickly. it's nice

17:40 tomoj: select-keys will be O(n) instead of O(1) for entryAt

17:40 nollidj: yeah

17:40 ah, and there's also find

17:40 tomoj: oh, yeah

17:41 actually, I suspect find won't work

17:42 rhudson: It does return a MapEntry

17:42 tomoj: it seems to work despite my suspicion

17:42 ah, find is just entryAt on Associatives

17:43 but if the thing isn't Associative, it casts to Map and then returns a MapEntry with the key you passed as the key, instead of the key in whatever the thing is

17:43 nollidj: interesting

17:43 tomoj: I guess that is for java maps

17:44 zakwilson_: It appears that strings are faster as map keys than keywords. Can someone explain why?

17:47 rhudson: What leads you to believe they're faster? (How did you measure?)

17:51 zakwilson_: rhudson: I have an application that involves a very large number of map lookups. Changing the keys to strings resulted in a substantial (~30%) speedup.

17:52 rhudson: Are the keys dynamically generated, or are they literals in the code?

17:53 zakwilson_: Not entirely sure what you're asking. The maps in question are in-memory at the time the CPU-intensive operation takes place.

17:54 rhudson: Basically, I'm wondering if some input is being converted to a keyword (which essentially involves a map lookup) before the keyword is used for the lookup in the target map.

17:54 zakwilson_: They're serialized to disk with (spit (str the-map)). It's also noteworthy that reading the string version back in is five times faster than the keyword version.

17:55 Oh. No, that's not happening.

17:55 http://github.com/zakwilson/zutil-clj/blob/master/map.clj <-- the application is calling intersection and difference on in-memory maps

17:59 tomoj: for me, 100000 keyword lookups is faster than 100000 string lookups, it seems

17:59 rhudson: Out of ideas then. It seems like keywords should be faster, in that once you've found the right hashbucket you can just use identity rather than string equality to find the key

17:59 [ you can just => the implementation can just]

18:01 tomoj: this is probably a trivial case and the results are probably meaningless, but:

18:01 ,(let [m {"foo" 3}] (time (dotimes [_ 10000000] (m "foo"))))

18:01 clojurebot: "Elapsed time: 607.041 msecs"

18:01 tomoj: ,(let [m {:foo 3}] (time (dotimes [_ 10000000] (m :foo))))

18:01 clojurebot: "Elapsed time: 607.719 msecs"

18:01 tomoj: hah

18:01 for me, the keyword one is faster

18:02 zakwilson_: I think the fact that it's always the same keyword has an impact.

18:02 tomoj: and that the map only has one key anyway..

18:02 I tried it earlier with maps with keys like :1 :2 :3.. and "1" "2" "3"... and then ran through all the keys, and the keyword one was faster

18:03 but I probably screwed up

18:03 zakwilson_: I have a 27k-element map containing many multi-thousand element maps and I'm looking at all the data at once.

18:06 rhudson: Curious, on my machine I'm seeing longer times for keywords on 2-element maps.

18:07 i.e. {:a 1 :b 2} vs. {"a" 1 "b" 2}

18:07 tomoj: reading keywords is definitely a whole lot slower than reading strings

18:16 rhudson: In Java source, Keyword.hashCode() is sym.hashCode() + 0x9e3779b9

18:16 sym.hashCode() returns the value of a final field

18:16 which is presumably what String does

18:17 So there's an extra function call + addition for keywords.

18:17 Wonder if that's enough to explain the difference.

18:18 (seems unlikely offhand)

18:20 zakwilson_: I haven't tried symbols, but I'm assuming they would have similar performance characteristics to keywords.

18:22 rhudson: I see times more like strings than keywords (for symbols)

18:22 with {'a 1 'b 2}

18:22 tomoj: but

18:22 ,(identical? (read-string "foo") (read-string "foo"))

18:22 clojurebot: false

18:24 tomoj: temporarily hacking clojure's source to remove that addition wouldn't severely break anything as long as you don't put symbols and keywords in the same map, I bet?

18:24 rhudson: Right. But they'll have the same hashcode. So if the hashbuckets are small, lookup time is dominated by finding the right hash bucket.

18:24 tomoj: seems unlikely it would break anything

18:25 tomoj: I don't have a good solid benchmark to run anyway

18:25 zakwilson_: No need to mix types. Using keywords was actually premature optimization: I assumed they'd be faster than strings.

18:25 rhudson: I would have assumed so too!

18:25 zakwilson_: The only bad thing about strings is that they take more memory

18:25 tomoj: keywords are the most idiomatic choice as well, I think

18:26 zakwilson_: Strings are more correct in that I had to strip out some characters to represent the values as keywords. Memory use is really the only down side.

18:27 rhudson: It seems like Keyword could be sped up by calcing the hash on construction & just return that, just like Symbol (and presumably String) do

18:29 * zakwilson_ should probably write a hashtable implementation just for the experience.

18:29 rhudson: ... it'll make you really appreciate using someone else's

18:30 nollidj: quick terminology question: do you call 'a an "atom" (as i learned when studying scheme) or something else?

18:30 zakwilson_: 'a is a quoted symbol

18:31 tomoj: rhudson: but we should probably know how much that slows it down before doing so, no?

18:31 I mean, whether the addition is actually causing the slowdown

18:31 zakwilson_: In traditional Lisp terminology, something that isn't a cons cell is an atom. Clojure has something entirely different that's also called an atom.

18:32 nollidj: that's an important point, then

18:32 zakwilson_: So... I'm not sure what to call a non-collection value in Clojure.

18:32 rhudson: tomoj, it's not just the addition, there's an extra method call as well.

18:32 tomoj: ah, yes

18:33 technomancy: zakwilson_: the Joy of Clojure calls them scalars

18:33 which is uncomfortably close to "scala" for me

18:33 tomoj: do you have a good benchmark I can run that shows that keywords are slower?

18:35 nollidj: i've got a question related to this keyword vs string issue. i've mentioned that i'm making a toy natural language parser. from my somewhat vague background in lisp-like languages, i know that sometimes people implement such parsing on the basis of quoted symbols. so, a grammar rule might be something like {:parent 'NP :left-child 'DT :right-child 'NN}. i could also represent it like {:parent "NP" :left-child "DT" :right-child

18:35 "NN"}. i'm going to be keying some hashtables with these values, as in (get rules-by-parent "NP")

18:35 zakwilson_: If it wasn't part of a proprietary super-secret potential startup, I'd give you the actual application I'm working on as a benchmark.

18:36 rhudson: I don't know if it's good, but I was doing (def m {:a 1 :b 2}) then (time (dotimes [_ 10e6] (m :a)))

18:36 mutatis mutandis for strings and symbols

18:36 hiredman: (:a m) is a good habit to get into

18:36 zakwilson_: hiredman: doesn't work for string keys

18:37 tomoj: I get only tens of milliseconds difference there

18:37 hiredman: zakwilson_: I am aware

18:37 tomoj: that like what you're seeing?

18:37 zakwilson_: Why is it a good habit?

18:37 hiredman: but if you are using keywords you should get into the habit of (:a m)

18:38 because if you move from maps to records, (:a m) will get you fast field access for records, (m :a) and (get m :a) won't

18:38 the compiler recognizes (:a m) specially

18:38 rhudson: (:a m) actually takes longer than (m :a) on my trivial benchmark

18:39 zakwilson_: rhudson: I increased that to 10e7 and got faster results with keywords than strings

18:40 rhudson: zakwilson_: Hmm, I don't see that. I'm running Clojure 1.1 on Java 5 on Mac OS X.

18:40 tomoj: zakwilson_: same here

18:41 zakwilson_: I'm running Clojure 1.1 on Java 6 on Linux (amd64)

18:42 rhudson: Hmm. I think Hotspot's a lot brighter in J6 than J5

18:43 nollidj: zakwilson_: i'm on a similar environment (clojure 1.1, java 6, linux amd64), and (if i'm doing this right) keywords are faster

18:43 for 10e6

18:44 zakwilson_: Keywords are faster for this trivial benchmark, but not for my application.

18:44 nollidj: ah, right

18:45 zakwilson_: Records are new in 1.2?

18:45 rhudson: yes

18:46 zakwilson_: How much faster should a record lookup be than a map lookup?

18:47 rhudson: I think hiredman's point was that it's constant time (for the (:a m) form) for records

18:47 zakwilson_: It's probably not faster enough to matter in this application - the part that could be a record only has a few lookups per call.

18:50 rhudson: Well, you need to decide if faster + more correct > bigger

18:50 tcrayford: and less flexible

18:53 zakwilson_: The application involves text classification, so... I kinda like more correct.

18:54 nollidj: apologies for triviality, but when using reduce, as in: (reduce (fn ...) (range 10)), the function supplied must be able to handle the form (reduce (fn ...) ()). how can i write this in-line so that the function accepts 2 or 0 arguments as appropriate?

18:54 zakwilson_: It also involves lots of clock cycles, so... faster is nice. Memory use could be an issue. We'll see.

18:54 tcrayford: nollidj: (reduce (fn [x y] blah) [])

18:55 of

18:55 oh

18:55 umm

18:55 (reduce (fn ([] blah) ([x y] bork)) [])

18:56 nollidj: ah, interesting. thanks.

18:56 zakwilson_: (fn [& stuff] (let [[x y] stuff] do-things...)) works too

18:56 nollidj: yes, i hadn't quite gotten the & syntax down

18:56 makes sense. thanks.

18:56 tcrayford: I think the multiple arity version is somewhat cleaner though

18:56 than that destructuring one

18:57 though depends what you're doing

18:57 you could use if-let to check if you have two args

18:57 (fn [& more] (if-let [[x y] stuff] do-things...))

18:58 (fn [& more] (if-let [[x y] stuff] do-things... do-other-things...)) even

18:58 zakwilson_: There isn't really a clean way to supply default values in this situation, which I find unfortunate.

18:58 tcrayford: you can use the default parameter for reduce as one of them

18:59 (defn my-map [f coll]

18:59 (reduce (fn [xs x] (conj xs (f x))) [] coll))


18:59 zakwilson_: I miss CL's &optional in this case.

18:59 tcrayford: never used CL, explain?

19:01 zakwilson_: (defun foo (bar &optional (baz 3)) ...) uses 3 for the value of baz unless the caller supplies one.

19:01 tcrayford: like pythons def foo(x=1) stuff then

19:01 gotcha

19:02 zakwilson_: Yes

19:02 There's also &key, which uses keyword arguments (also with optional default values) and &rest, which is like Clojure's &

19:03 tcrayford: you can get keyword arguments with defnk, which is nice

19:04 tomoj: ,((fn [foo & {:keys [bar baz]}] [foo bar baz]) 1 :baz 2 :bar 3)

19:04 clojurebot: [1 nil nil]

19:05 tomoj: works in 1.2

19:05 (i.e. you get [1 3 2])

19:05 tcrayford: I thought clojurebot used 1.1?

19:05 oh, it does

19:05 yeah

19:28 what's a good way of getting clojure's working directory?

19:28 I'm using (sh "pwd) atm, but not happy

19:29 tomoj`: (System/getProperty "user.dir")? :/

19:31 tcrayford: works fine here

19:31 cheers

19:32 *is killing dependancies*

19:33 jColeChanged: This is probably going to be a stupid question, but in what situations would one want to use 'when-first'?

19:34 tcrayford: ,(when-first [x [1 2 3]] 1)

19:34 clojurebot: 1

19:34 tcrayford: oops

19:34 hiredman: huh

19:34 tcrayford: ,(when-first [x [1 2 3]] x)

19:34 clojurebot: 1

19:34 hiredman: when-let-first

19:34 tcrayford: its not named too well

19:36 hiredman: and whats the diff with (when-let [x (seq [1 2 3])] x)

19:44 tomoj: ,(when-first [x [nil 2 3]] 24)

19:44 clojurebot: 24

19:44 tomoj: :/

19:44 oh

19:44 maxhodak: is there a library for zookeeper in idiomatic clojure?

19:45 tomoj: maxhodak: I don't know of one, but I'd love to help, or please let me know if you find one

19:45 very interested

19:46 maxhodak: tomoj: i might write something that wraps the java api

19:47 my concern is that zk is a such a sophisticated system

19:47 it's not something that you'd just write a wrapper for in a few hours

19:47 tomoj: yeah..

19:48 I was planning to just wrap whatever I needed

19:48 which would probably lead to ugliness

19:48 maxhodak: well i mean, it just wouldn't work

19:48 it's all based on push notifications and watches

19:49 and dealing with the million error states that arise

19:49 its more than just a wrapper, since you need to be able to receive the watch triggers

19:58 tomoj: error states sound annoying, but why are watches a problem?

20:09 etate: whats the difference between a SNAPSHOT and a master-SNAPSHOT?

20:11 hiredman: use the first for contrib and the second for clojure

20:15 tcrayford: technomancy: ping

20:26 tomoj: is the name "seq heil" offensive? :)

20:27 jColeChanged: "seek hell" or "sequel"?

20:29 tomoj: are you asking how it's pronounced?

Logging service provided by n01se.net