#clojure log - Jul 09 2010

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

0:06 ysph: (car '())

0:06 sorry guys

0:58 fuchsd: What's the idiomatic way to run a function with side effects on every element in a list? Is it to use a sequence comprehension and then doseq it?

1:00 err, mapping the side effect function on the sequence and then doseq'ing it?

1:00 (using map)

1:11 ysph: fuchsd: does for do what you want?

1:11 fuchsd: I think I'm overthinking it; map seems to do it

1:11 Let's just say I want to print every item in a list,

1:12 I'd do it like this:

1:12 cemerick: fuchsd: doseq

1:12 fuchsd: ,(dorun (map println '("one" "two" "three")))

1:13 ysph: cemerick's suggestion is the proper one

1:13 fuchsd: Ok, cool; thanks!

1:14 ysph: as in (doseq [x '("one" "two" "three")] (println x))

1:14 fuchsd: Perfect, that's what I'm looking for

1:15 Thanks

1:22 ysph: fuchsd: btw, you might want to read about the bindings and filterings provided by for ((doc for)), they are the same in doseq

1:24 fuchsd: Oh, cool

1:29 i

1:44 Licenser: Morning my lispy friends

1:49 hiredman: ping?

1:50 ping?

1:50 clojurebot: PONG!

1:51 Licenser: Pong

1:51 Greetings hiredman

2:43 vibrant: morning

2:43 Licenser: Morning vibrant

2:58 harblcat: hi all, I have a question

2:59 I've got a lot of calls I'm making to a java class, and I can't do anything better than (do (Toolkit/init) (Toolkit/setup ...) ...)

2:59 it there a better way?

3:00 I tried using doto, but I can't access the static methods of the class, I guess.

3:07 Chousuke: harblcat: for static calls, not really.

3:08 harblcat: aww..

3:09 Licenser: It Looks like a uglyish toolkit so, perhaps there is an alternAtive?

3:09 Chousuke: you could always write your own macro for repeated static calls

3:11 harblcat: jcurses is what I am using, but there are a couple of other tools with the same thing going on...

3:12 is there a way to at least shorten 'Toolkit' to 'T' or something? (def T Toolkit)?

3:12 Licenser: Write a wrapper for the rest of us? :)

3:12 harblcat: I'm not that good yet ;)

3:13 Chousuke: harblcat: hm, not that I know

3:13 I don't think alias works on classes either

3:13 but you could try I guess.

3:18 Licenser: I always feel pain when I see a system with 16 CPUs and it isn't mine :(

3:25 LauJensen: Good morning all

3:28 Licenser: Morning laujensen

3:54 cais2002: looks like most ppl are from europe

3:54 anyone else in a timezone that's already late afternoon now?

3:54 mikem: cais2002: yep

3:55 cais2002: hehe, yeah i know

3:56 Licenser: Cais2002 many people from he us don't show up until later

4:04 LauJensen: cais2002: I am in Europe, but I think we're promoting the UGT time standard nowadays

4:07 cais2002: laujensen: now i got it..

4:07 Licenser: Ugt?

4:07 clojurebot: ugt is Universal Greeting Time: http://www.total-knowledge.com/~ilya/mips/ugt.html

4:07 esj: Good Mood Folkses

4:08 Licenser: Wownice

4:09 Morning esj

4:10 LauJensen: Good morning esj

4:10 ,ugt

4:10 clojurebot: java.lang.Exception: Unable to resolve symbol: ugt in this context

4:10 LauJensen: clojurebot: ugt

4:10 clojurebot: ugt is Universal Greeting Time: http://www.total-knowledge.com/~ilya/mips/ugt.html

4:10 LauJensen: clojurebot is knowledgable

4:11 Licenser: Jap and it even explains things when you jvust add a ?

4:13 Cookies?

4:14 clojurebot: Cookies

4:14 clojurebot: Pardon?

4:14 Licenser: :(

4:14 He does not know cookies, what a sad way to live

4:18 LauJensen: ugT?

4:18 clojurebot: ugt is Universal Greeting Time: http://www.total-knowledge.com/~ilya/mips/ugt.html

4:18 LauJensen: cool

4:19 Licenser: Yap

4:20 So I wonder how to explain him stuff

4:23 cais2002: ?cookies

4:23 cookie?

4:23 LauJensen: clojurebot: Licenser is the man who puts licenses on everything

4:23 clojurebot: Roger.

4:23 LauJensen: Licenser?

4:24 clojurebot: Licenser is the man who puts licenses on everything

4:24 cais2002: guys, is there a way to inspect all possible methods/fields of a given var/object?

4:25 LauJensen: cais2002: C-c I

4:25 Licenser: clojurebot: Cookies *nom* *nom* *nom*

4:25 clojurebot: Titim gan éirí ort.

4:26 Licenser: Cookies?

4:26 cais2002: Laujensen: is that some emacs syntax?

4:26 how do I do it in repl?

4:26 LauJensen: cais2002: Yes, of course

4:26 In the repl, just hold Ctrl and hit c, let go, hit shift+i

4:26 C-c I

4:26 Then you'll be prompted for an object of a class to inspect. Try "String" for instance

4:26 And you'll see all fields and methods

4:27 Only works in SLIME

4:27 For all other IDEs, go find your webbrowser, wait for it to start. Navigate to the adress bar, type in "google.com", then navigate to the search field, type "string javadoc", click search and wait for the result. Once you have some results, there should be a link to sun/oracle docs. There you can see the same thing

4:28 bozhidar: ;-)

4:29 Licenser: Oh come on clojure. Jt don't be boring

4:30 bozhidar: btw anyone having problems with the SLIME REPL + paredit?

4:30 for some reason

4:30 it's the only mode in which paredit

4:30 LauJensen: haha

4:30 bozhidar: I refer you to my latest tweet

4:30 bozhidar: doesn't work normally

4:31 @LauJensen?

4:31 LauJensen: Thats right

4:32 bozhidar: hehe

4:32 I'm actually rather fond of paredit :-)

4:32 except for the [] pairing and skipping

4:33 LauJensen: Yea a few people were defending it last night as well

4:33 bozhidar: that works somewhat strange

4:33 compared to parenthesis

4:33 you can also switch to autopair

4:33 it's a lot less intrusive

4:33 but it's more general purpose

4:34 doesn't have anything lisp related in it

4:34 LauJensen: Im fine just using Emacs

4:34 bozhidar: like navigating sexps

4:36 esj: I like that it understands sexps and I can navigate them, rather than chars or lines, i think thats smart.

4:36 dissipate: hello

4:37 anyone here use enclojure in netbeans?

4:38 LauJensen: dissipate: I've heard of 2 guys, but they're both Americans

4:39 dissipate: LauJensen, so consensus is enclojure is bad?

4:39 zmila: i used enclojure - but during some hours only :)

4:39 LauJensen: dissipate: No I think its the most featureful of all the inefficient IDEs available

4:39 The guys working on it do good work

4:40 dissipate: but did you read this? http://bestinclass.dk/index.clj/2010/07/trail-blazing-innovators.html

4:40 dissipate: well supposedly i can't even compile because it is running out of memory. lol

4:40 LauJensen: hehe

4:42 noidi: is there something like mapcat buf for "for" (i.e. forcat)?

4:42 I seem to keep doing a lot of (apply concat (for ...))

4:43 dissipate: so emacs is the mac daddy?

4:43 noidi: most of them (apply hash-map (apply concat (for ...))), where I build [key value] pairs in the for

4:44 Chousuke: noidi: you could just do (into {} (for ...))

4:45 it'll be a fair bit faster too

4:45 noidi: Chousuke, great, thanks!

4:45 dissipate: LauJensen, i'm a noob to clojure and emacs. what's the best way to get started?

4:46 LauJensen: dissipate: http://bestinclass.dk/index.clj/2009/12/clojure-101-getting-clojure-slime-installed.html

4:47 As you can see thats from last december so it might be outdated. You need to get clojure-mode and swank-clojure installed. When installing them like I do in that screencast, you also get slime and slime-repl from ELPA

4:47 Then when you download a new project (or make one), add lein-swank as a dependency, run 'lein deps' to pull that dependencen, then 'lein swank' to start a server. From emacs, you just hit M-x slime-connect to get a repl going for that specific project.

4:47 Another approach, which is the one I use, is shown in that first link I dropped

4:48 Licenser: We would really need some kind of out of the box way to do that all it is tiresome :(

4:49 dissipate: sounds like i'm already in over my head!

4:49 LauJensen: dissipate: Just take it one step at the time. I've given you 2 screencasts now, watch them first

4:49 dissipate: even getting enclojure set up was a task.

4:49 LauJensen: I show you a full installation on a fresh linux box, so it shouldnt be too tricky to keep up

4:49 And if there are questions Im here for a few hours, so shoot away

4:51 dissipate: enclojure in netbeans is incredibly memory hoggish

4:51 and the whole thing is a good chunk of a gigabyte to download/install. seems crazy

4:51 bobo_: dissipate: realy? i dont find it using more then just netbeans

4:52 dissipate: bobo_, i mean netbeans actually

4:52 i just don't understand why an IDE needs to be hundreds of megabytes...

4:53 bobo_: well, it supports alot, just the java version is 54MB

4:53 javaSE that is

4:54 dissipate: LauJensen, thanks for the screen casts. i will check them out.

4:54 LauJensen: np

4:55 bobo_: dissipate: http://freegeek.in/blog/2009/08/setting-up-emacs-clojure-with-emacs-starter-kit/ is pretty good for emacs aswell

4:57 cais2002: what does #^"[C" mean?

4:59 Licenser: cais2002: It is a java array

4:59 LauJensen: Its an old-school type hint

5:02 cais2002: so the new style is just ^"[C" , right?

5:03 Licenser: One thing at is bad about the current repl is that it never forgets you introduce bugs reload the namespace but the old stuff stays :(

5:04 hsarvell: Lau: Yes nice screencast, for no2 I want to see what Emacs can do when it comes to actually coding Clojure.

5:08 Licenser: Wow very strange if I just reload thie ns it woke o.o

5:19 LauJensen: hsarvell: Thanks :)

5:19 cais2002: yea

5:20 Licenser: wow, you can wake up a namespace?

5:27 dissipate: bobo_, thanks for that link.

5:54 bartj: hi all

5:56 re: formatting/style guidelines, is there any quick way to know when I need to start/"break" an expression to a new-line ?

5:56 eg: (when (="p" "np") (println "win 1M$") (println "try more"))

6:04 LauJensen: bartj: Theres a style-guide on assembla, though I dont think it covers new-lines

6:04 Typically, use them when they enhance readability

6:04 (when x

6:04 (do y)

6:04 (dy z))

6:04 but not

6:04 (map some fn

6:04 some coll)

6:05 bartj: LauJensen: does the start of an expression always warranty a new line ? (that seems to be the major difference in your examples)

6:08 Chousuke: bartj: just do what looks good and is easy to read

6:09 adding newlines to a map invocation can help if the function/coll are formed from some complicated expression

6:10 with when, the usual convention is to do a linebreak after the condition, but that's not always necessary either.

6:11 I guess in general macros tend to have some group of parameters and then a "body"

6:11 and there should be a line break before the body

6:13 eevar2: bartj whatever you do, don't do this -- http://gregslepak.posterous.com/on-lisps-readability

6:13 Chousuke: heh :P

6:14 I honestly don't find the C-style parens any easier

6:14 eevar2: meh, really should rework my sentences into something legible before hitting enter

6:14 Chousuke: You still need to trace the "invisible line" up to the matching level

6:15 eevar2: indeed. and the guy is cheating by indenting with 2x the space in his 2nd example

6:15 Chousuke: the extra indentation is what helps in the example on that page, not the paren placement

6:16 bartj: eevar2: that link is really really good! thanks!!

6:16 Chousuke: bartj: :P it's an example of what not to do

6:17 bartj: people will complain if you put closing parens on their own lines. that's just not done in lisp-land

6:17 I agree though that it's somewhat arbitrary

6:18 but I don't agree that suddenly going C-style would make lisp any more approachable.

6:19 scottj: I didn't read gregslepak's post bc it's too long but he places trailing paren on reduce (functions) and hashes in a way I don't think even C-style languages do

6:20 bartj: Chousuke: sometimes, its useful to know what one must not do ...

6:20 Chousuke: btw, his example of stacking C braces is perfectly readable to me :D

6:20 it looks pretty good actually

6:21 I think because the code is closer together, it's easier to see which block things belong to

6:21 if it's spread out, it gets longer and you need to jump up and down to confirm the block level

6:22 bobo_: i would say the method is to long no mather what style you type it in

6:23 Chousuke: well, yeah.

6:23 with C and similar languages I have a habit of commenting block ends with a note telling what they are.

6:23 so I don't need to jump up to confirm so often

6:23 Licenser: Coooooooookies

6:24 Chousuke: it's useful in lisp too, I think

6:25 if your function really gets long, a comment is a good "landmark"

6:25 bartj: Chousuke: may I urge you to write a styling document for Clojure

6:25 Chousuke: kind of like a 'you are here' dot on maps :P

6:27 bartj: did you check out the style notes on assembla?

6:29 bartj: Chousuke: link please ?

6:29 Chousuke: http://www.assembla.com/wiki/show/clojure/Clojure_Library_Coding_Standards

6:29 I suppose I could write a summary of what I think is important. hmm.

6:31 bartj: Chousuke: that link unfortunately has no information on "indentation"

6:32 Chousuke: bartj: well, indentation typically is either two spaces per level, or aligned with above code (in case of function parameters)

6:33 but you can break any rule if you think it helps readability

6:33 aligning params for example may result in too deep indentation

6:35 nipra: Highlighted matching parens, forward-sexp, backward-sexp, up-list, backward-down-list, ... are some of my good friends :-P Cheers!

6:36 bartj: Chousuke: Something along the lines of: http://lxr.linux.no/linux/Documentation/CodingStyle

6:45 nipra: For comments, we should follow advice on page 41: norvig.com/luv-slides.ps

7:50 Bahman: Hi all!

9:16 Raynes: ,(letfn [(f [] (keyword (name (gensym))) #(f))] (trampoline f))

9:16 clojurebot: Execution Timed Out

9:17 Raynes: hiredman: Is clojurebot susceptible to the same thing you broke sexpbot with last night?

9:20 defn: ,(ns-publics 'clojure.core)

9:20 clojurebot: {sorted-map #'clojure.core/sorted-map, read-line #'clojure.core/read-line, re-pattern #'clojure.core/re-pattern, keyword? #'clojure.core/keyword?, val #'clojure.core/val, chunked-seq? #'clojure.core/chunked-seq?, find-protocol-impl #'clojure.core/find-protocol-impl, vector-of #'clojure.core/vector-of, object-array #'clojure.core/object-array, *compile-path* #'clojure.core/*compile-path*, max-key #'clojure.core/max-key, lis

9:20 defn: cool, hiredman finally fixed it, deleted my issue on github, never replied to me, never acknowledged there was a problem, but fixed it

9:23 Raynes: The issue is dead, all hail the issue.

9:26 defn: ,(letfn [(f [] (symbol (name (gensym))) #(f))] (trampoline f))

9:26 clojurebot: Execution Timed Out

9:28 defn: Raynes: you could build a little timer with atoms

9:28 maybe?

9:28 Raynes: Hrm?

10:07 cemerick: fogus_: any thoughts on the scala 2.8 pain being aired on the interwebs?

10:18 fogus_: cemerick: There is a reason that we're still on 2.7.2

10:18 chouser: "we"?

10:18 cemerick: fogus_: I've heard from three others via twitter to the same effect.

10:19 is it your codebase that needs porting, or critical libs, or both?

10:20 fogus_: cemerick: I mean my project team (but really just me)

10:20 * fogus_ is legion

10:21 fogus_: cemerick: Just our codebase. I use Scala to pull together some Java libs. We do not use any other Scala save for Scala itself

10:23 moving from 2.7.2 to 2.7.3 was less than stellar. From 2.7.2 to 2.8 is a nightmare

10:24 cemerick: I'm mostly confused as to why it's not just called 3.0. There was some mention of it being "too late to change" the version number, but that seems really odd.

10:24 I mean, as soon as the breaking change became evident, wasn't twiddling the pom an easy, self-evident fix?

10:24 fogus_: I'm not sure either. The changes are pretty extensive and entirely pervasive

10:24 cemerick: (Says the bystander, in hindsight.)

10:25 fogus_: cemerick: Every change is a breaking change

10:25 always

10:26 It's kinda sad because I pitched Scala to my group and it's kinda going the wrong way (IMO) since they bought off on it

10:27 "though #^ is just deprecated at this point – no breaking changes" LOL

10:28 cemerick: I get the impression that Stephan Schmidt thinks ^String is something more than it is

10:29 cemerick: fogus_: mmm, probably. Though, as I was telling chouser a few weeks ago, I'd like to see hints become more than just advice.

10:30 He reminded me of this http://bit.ly/d84RO9 which was one of the more fun macros I've ever done. I do continue to like that style.

10:30 bobo_: hm, is it the same way in clojure btw, if you compile with one version of clojure you cant use the library in another version of clojure?

10:31 fogus_: As do I. Although, I wouldn't base my language choice on s^String, s:String, String:s, or ^String s

10:32 cemerick: bobo_: The language and libraries have remained remarkably stable, so something written for 1.1 or 1.0 will almost surely work in 1.2, etc.

10:32 AOT-compiled classfiles *will* break if you build against 1.1 and try to run against 1.2 though, which is unfortunate.

10:33 bobo_: ok, so the bytecode thing is same in other words?

10:33 cemerick: The solution there is to either just recompile (no source changes needed), or ship source instead of classfiles if you can.

10:33 It's fair to say clojure is source-compatible from 1.1 to 1.2, but not binary compatible.

10:34 * fogus_ will probably still upgrade to Scala 2.8 when it's finally released...... uh, maybe 2.8.1

10:35 cemerick: The amount of squawking about 2.8 is remarkable though. Some indication of how large the base of users is.

10:35 I wonder how much of it will be taken by more timid folks as unacceptable levels of FUD.

10:36 fogus_: cemerick: I missed that thread originally... [b:String [c:Double :as list:java.util.List] {d:java.util.Random :d}] is surprisingly clean!

10:39 While it stinks that 2.8 breaks my work code, I'm more bitter that it breaks my BASIC DSL :p

10:39 cemerick: damn, not FORTRAN?

10:40 rfg: FORTRAN favours the brave.

10:43 yacin: with clojure.contrib.logging/with-logs, what should i be using as the "log-ns" argument?

10:44 i thought *ns* was bound to the current active namespace, so i was using that

10:44 but it prints "clojure.contrib.logging$fn__168$impl_write_BANG___176 invoke" which isn't particularly useful/helpful

11:19 gilescb: does anyone know which is the "trunk" congomongo? since somnium doesn't appear to be incorporating pulls?

11:21 or does chaos reign supreme?

11:30 bigwavejake: i have a lazyseq. i need to force it to return all the results. how do i do it?

11:30 eckroth: (doseq myseq) ?

11:30 dnolen_: bigwavejake: doall

11:30 (doall (map inc [1 2 3 4]))

11:30 eckroth: dnolen_: can you describe the differences (in practice)?

11:30 dnolen_: ,(doall (map inc [1 2 3 4]))

11:30 clojurebot: (2 3 4 5)

11:31 dnolen_: eckroth: what do you mean?

11:31 eckroth: dnolen_: between doseq and doall

11:31 dnolen_: ,(doseq [x (map inc [1 2 3 4])] x)

11:31 clojurebot: nil

11:31 bigwavejake: dnolen_: thanks!

11:32 dnolen_: eckroth: doseq returns nil, it's for sideeffects

11:44 eckroth: dnolen_: oh wow, that's straightforward! thanks.

12:41 yesudeep: Can the recur form occur any number of times within the definition of a function?

12:41 chouser: yes, but only in tail positions

12:42 yesudeep: alright chouser. thank you. :-)

12:44 chouser: Does clojure barf with an error if the programmer mistakenly uses recur in a non-tail position?

12:44 I should probably try that out.

12:45 tomoj: ,(fn [] (inc (recur)))

12:45 clojurebot: java.lang.UnsupportedOperationException: Can only recur from tail position

12:46 yesudeep: hmmm.. nice tomoj.

12:51 eckroth: can I provide a method in defrecord without referring to any protocols? ie. can I make record methods without first defining a protocol?

12:54 Chousuke: eckroth: you can implement interfaces, but if you mean to ask whether it's possible to create new methods, then I don't think so.

12:56 eckroth: Chousuke: I think you're right; if I don't refer to a protocol, I get an unrelated error; if I refer to a protocol but make a method not in the protocol, I'm told I can't create new methods

13:06 lpetit: Hi, emacs users :-)

13:07 I'm sick of my current logitech keyboard. After all those years, starting to feel the pain out of my wrists

13:08 With so heavy use of the Control, Shift (and Alt ?) key in emacs, how do you manage not get hurt ? Is there a dirty secret concerning how to hit those keys ? Or do you all use special keyboards ?

13:08 Or do I need to buy two new arms ? :-)

13:09 eckroth: lpetit: I find "mousing around" the worst for my right wrist; using Emacs is much better for me. Perhaps an alternative for you is Vi-like keybindings?

13:10 fogus_: lpetit: You need one of these: http://world.std.com/~jdostale/kbd/SpaceCadet1.jpeg

13:12 lpetit: fogus_: hey, I'm not *that* old ! :)

13:12 maravillas: i like the thumbs up and down keys...very roman emperor

13:14 shadowspar: http://kinesis-ergo.com/contoured.htm

13:16 I don't use emacs, but I've used that ^^ kbd for 5 years, and it's made a huge difference for me

13:16 lpetit: eckroth: oh ? My right wrist doesn't suffer from mousing around: my arm rotates over my elbow, and the movements of the wrist while "mousing around" are small. No, it's really my left little finger, when reaching the Ctrl key which is the problem

13:16 shadowspar: the kinesis ones put all the modifier keys (except Shift) into the thumbwells, which might help

13:17 lpetit: shadowspar: now this looks really like star trek material. I like it !

13:17 eckroth: lpetit: I understand the Ctrl key issue; however, I've been using Thinkpads all my life and I love the "trackpoint", but it's not good for my wrist; I also have terrible chair/desk pairings so my wrist is always bent when using the mouse :(

13:19 shadowspar: lpetit: it's not too bad to learn to type on since all the letter/number keys are in the same spot

13:19 a lot of ppl like them, but it's not the end-all and be-all of ergo keyboards by any means. there's a lot of stuff out there =)

13:20 * dnolen_ loves his Kinesis contoured


13:21 lpetit: I guess I'll have to find a local store where I can try them, so

13:21 * cemerick apologizes

13:21 cemerick: lpetit: the standard apple keyboards are very, very nice IMO. Very short key travel, which is key for me.

13:24 lpetit: cemerick: doesn't very short key travel mean the hands are even closer than with normal keyboards, and the elbows having a greater angle ?

13:25 cemerick: lpetit: no, key travel refers to the height of the key caps. The shorter the key travel, the less effort you need to expend in order to register a keypress.

13:26 lpetit: cemerick: ok. Must leave work and go home. Thanks for the input, alls

13:26 bye

13:28 nickik: Can somebody help me with a problem setting up webdevelopment?

13:29 I made a new project with line and added compojure to the deps

13:31 then i downloaded everything with lein deps

13:34 yacin: if i want to serialize a java object with print-dup, but all the information isn't in the constructor, can i do something like:

13:35 #=(.add (java.util.ArrayList.) 4)

13:35 ?

13:35 or does read-string not understand arbitrary clojure exprs?

13:37 cemerick: yacin: I think that'd work, though you'd want #=(doto (ArrayList.) (.add 4))

13:38 defn: clojurebot is nowhere close to SKYNET when compared to this: http://techcrunch.com/2010/07/08/anybots-arrington-robot/

13:38 yacin: hmm, it doesn't seem to evaluate the expression

13:38 (clojure.core/let [G__14535 (java.util.ArrayList.)] (.add G__14535 4) G__14535)

13:38 defn: yacin: um yeah, that would just read everything you typed in

13:39 so it couldnt stop naughty things from happening

13:39 you could arbitrarily execute code on the server

13:39 yacin: i realize the implications of something like this

13:39 but i want to do it anyway

13:39 defn: you just did...at your own REPL

13:40 cemerick: yacin: read doesn't evaluate anything, eval does

13:41 defn: yacin: im sorry i missed what you were trying to do there

13:41 yacin: i don't understand why #=(java.util.ArrayList.) returns an instance then, instead of just the expression

13:41 defn: i thought you were trying to do:

13:41 yacin: no worries

13:41 defn: ,#=(java.util.ArrayList.)

13:41 clojurebot: EvalReader not allowed when *read-eval* is false.

13:41 defn: to the bot

13:41 yacin: no, i have a java class that doesn't have all the necessary information in its constructor

13:41 qbg: Why is EvalReader so restricted?

13:41 yacin: so i need to create it, and run some methods to add the extra data

13:41 in order to make a suitable print-dup for it

13:42 if that makes sense

13:43 it seems to eval when the form is just a constructor, but not when it's wrapped with doto, which i would like

13:45 ohpauleez: What does #= do?

13:45 cemerick: it's part of an undocumented, unsupported serialization framework

13:46 ohpauleez: ahh, gotcha

13:46 chouser: unsupported?

13:46 cemerick: last I heard on that topic was "it'll change, don't depend on it continuing to be there"?

13:47 chouser: oh, interesting.

13:47 yacin: so, is what i'm trying to do possible?

13:47 ohpauleez: Also, a quick clojure in commercial apps update

13:47 yacin: otherwise, i'll have to parse everything, which won't be fun =\

13:48 ohpauleez: I know of one instance where clojure will probably be used in a large, commercial, video game

13:50 chouser: yacin: #=(eval (doto (java.util.ArrayList.) (.add 4)))

13:50 but don't tell anyone I told you that, and I'm by no means recommending it

13:50 yacin: yeah, i just tried it myself

13:51 chouser: you might do better to create a class with a static method to create ArrayLists

13:51 cemerick: a binary print/read is way more sane in any case

13:51 * chouser is suspicious of all binary serialization

13:52 yacin: chouser: yeah, i might go ahead and do that instead

13:52 cemerick: Just a stable fn in a namespace will do

13:52 yacin: i just need to get it done fast right now

13:52 cemerick: chouser: the only way to go when you've got a mix of clojure and java bits

13:52 Plus, legible print/read is godawful slow.

13:57 chouser: oh, indeed. a function rather than a static method

13:58 I can never remember what exactly #=() supports

13:58 cemerick: optimize first! debug later! :-)

13:59 cemerick: chouser: I prefer to do both. :-)

13:59 print/read is simply too slow for many, many things, of course

14:00 slyrus: stupid mutable (?) vector question: if I have '((1 "foo") (2 "bar") (4 "moose")) and I want ["foo" "bar" nil "moose"] from that, is there an easy way to do that?

14:00 chouser: why nil?

14:01 oh, I see.

14:03 qbg: slyrus: It would be rather easy to write such a function

14:04 slyrus: why, trivial: (loop ... for x in '... do (setf (aref ...)) :)

14:04 i mean, yeah, trivial

14:04 in common lisp... for me anyway

14:04 * slyrus is trying to learn clojure

14:04 qbg: Find the size of the vector to create, and then use reduce

14:07 cemerick: I just feel dirty now: https://gist.github.com/1d7cdc705e6b71721207

14:08 chouser: ,(reduce (fn [v [i x]] (conj (reduce (fn [v _] (conj v nil)) v (range (- i (count v) 1))) x)) [] '((1 "foo") (2 "bar") (4 "moose")))

14:08 clojurebot: ["foo" "bar" nil "moose"]

14:08 chouser: I'm sure there's a better way

14:08 slyrus: thanks chouser

14:08 chouser: that assumes keys are in order

14:08 qbg: My method: http://gist.github.com/469794

14:10 chouser: qbg's handles out-of-order keys

14:10 slyrus: cool. I guess there's no vector-push-extend in this language :)

14:10 chouser: though I think it's O(n log n) instead of O(n)

14:11 qbg: If log_32(n) is small enough, then that log n should be small enough

14:11 slyrus: I was trying to use an atom and swap! and not getting anywhere

14:11 ohpauleez: Is there a reason why you both used (fn ..) and not #()?

14:12 chouser: different reasons

14:12 well, we both used it once for destructuring the key/value pairs

14:12 I used it a second time because I was ignoring the second arg

14:12 ohpauleez: ahhh right, cool

14:13 chouser: should have used repeat nil like qbg did instead. :-)

14:17 qbg: Learning Clojure shouldn't be too hard if you come from CL

14:21 chouser: cemerick: you made a magic auto-generated function!

14:21 slyrus: qbg: it seems to be two things: learning the differences (how CL concepts map onto clojure) and breaking old/bad habits

14:21 cemerick: chouser: dirty, filthy, ashamed.

14:21 However, I've got a 14-slot record, and it's not going to get any smaller. :-/

14:22 qbg: slyrus: It also helps a lot if you used SLIME with CL

14:23 slyrus: qbg: is there any other way? :)

14:23 speaking of slime... how do I tell an emacs buffer that I want to switch slime connections?

14:24 ah, slime-cycle-connections

14:27 laz0r: can anyone help me setting up swank-clojure with elpa? I seem to have the problem that elpa installed the wrong clojure version (1.1.0, I think I need 1.2.1)

14:29 slyrus: learning clojure is a mixed bag for me... part "man, this would be really trivial in common lisp" and part "oh, that's really nice!". the latest example of the latter is (map :my-keyword ...) that's much nicer than cl's alist/plist/etc... cruft

14:29 technomancy: laz0r: you don't need swank-clojure from elpa; just get clojure-mode and slime-repl and follow the instructions in the http://github.com/technomancy/swank-clojure readme

14:29 heh; plists... =)

14:32 laz0r: technomancy: I tried already before trying to install with elpa, but found that readme a bit confusing

14:33 I did however get lein to work, and 'lein deps' did install clojure-1.2.0 in the lib/ subdirectory of swank-clojure

14:34 is that what I am supposed to do?

14:34 qbg: laz0r: You create a project and add swank-clojure as a dev-dependency

14:35 Then after running 'lein deps', you should be able to run 'lein swank' and connect to the project with SLIME

14:38 anonymouse89: any swarmiji users?

14:38 technomancy: anonymouse89: I think there is only one user of swarmiji

14:38 anonymouse89: :(

14:40 laz0r: qbg: ok, so I create a dummy project which just consists of a project.clj file, in which I put that just one line like: ":dev-dependencies [[swank-clojure "1.2.1"]]

14:40 and then I run 'lein deps'?

14:40 qbg: You create the project with 'lein new <project name>'

14:41 anonymouse89: In that case, my application is very cpu-intensive and currently uses agents to get full utilization on all local cores. I'm looking to span multiple boxes.

14:41 qbg: And yes, after adding that line, run 'lein deps'

14:41 anonymouse89: I'm a bit clueless about the simplest way to do this

14:44 slyrus: qbg: this seems to work for me: http://gist.github.com/469794

14:44 and thanks for your help!

14:47 qbg: slyrus: Note the following:

14:47 ,(assoc [nil] 5 "hello")

14:47 clojurebot: java.lang.IndexOutOfBoundsException

14:47 qbg: But:

14:47 ,(assoc [nil] 1 "hello")

14:47 clojurebot: [nil "hello"]

14:50 laz0r: qbg: ok, lein deps did install swank-clojure-1.2.1, but it is now in a subdirectory of my dummy project

14:51 qbg: Yes, 'lein deps' will put all of the dependencies into libs/

14:51 laz0r: can I somehow replace the swank-clojure-1.1.0 file in ~/.swank-clojure to make emacs use 1.2.1 automaticly?

14:51 qbg: Yes, just replace it :)

14:51 laz0r: ah, ok

14:52 qbg: Though it should only ever use that swank-clojure if you use 'M-x slime'

14:52 laz0r: thats exactly what I want it to do

14:53 qbg: I just have a symlink to the jar in my clone of the swank-clojure repo

14:53 laz0r: I wanted to play around with clojure, I had an old installation and thought 'oh well, I might as well upgrade it first'

14:59 mh, now slime does not start anymore

14:59 Searching for program: no such file or directory, lisp

14:59 I installed it with elpa, so I assume it should work

15:01 qbg: Sounds like something happened to what is in your .emacs

15:02 You could fix that, or use swank-clojure from a project

15:02 (2nd option is likely much easier)

15:14 threepwood: can i say (re-find (re-matcher #"foo" "foobar")) more concisely? re-matches only does a complete match.

15:16 qbg: ,(first (re-seq #"foo" "foobar"))

15:16 clojurebot: "foo"

15:16 qbg: ?

15:16 ataggart: ,(re-find #"foo" "foobar")

15:16 clojurebot: "foo"

15:19 threepwood: thanks

15:31 slyrus: qbg: I see. interesting behavior there. http://gist.github.com/469794 should be more robust then.

15:32 laz0r: qgb: you are right, it is a lot easier like that

15:32 oops, qbg i mean

15:33 still, I wonder whats wrong with my config... maybe I will find out

15:33 qbg: laz0r: Did you remove elpa or something like that?

15:34 laz0r: it is removed right now yes, but I was just trying around to find out whats wrong

15:35 I just saw that it is complaining about a version mismatch

15:35 but only after I installed that latest slime to try that out

15:35 qbg: Ignore the version mismatch

15:36 laz0r: I think a solution would be to set the inferior-lisp-program to execute clojure

15:43 ericthorsen: I have some code that uses genclass and has a dependency build order problem...I'm now using the maven plugin and cannot get past this.

15:44 What is the current recipe for this? Declaring the namespaces using the compileDeclaredNamespaceOnly does not seem to work (I read that somewhere)

15:47 cemerick: ericthorsen: what does your dependency DAG look like?

15:48 ericthorsen: Very simple, no cycles...A depends on B both are genclass java classes. A instantiates a B so during AOT it is looking for the class file

15:48 cemerick: ericthorsen: Add a (:require B) to A

15:49 ericthorsen: ... *before* the relevant import! :-)

15:51 ericthorsen: cemerick: you rock!!! Thank you

15:52 cemerick: yes, yes I do ;-)

15:52 np

15:52 ericthorsen: how's the enclojure-ing going?

15:52 I haven't upgraded to 6.8 yet.

15:52 ericthorsen: cemerick: Very good...I have a mate from sun helping out...we are skying every other week

15:53 cemerick: nice

15:53 I saw the assembla invite with a sun.com email, thought something might be up

15:54 ericthorsen: cemerick: I'm testing going back to multiple modules again in hopes to simplify contributions....in the past classloader hell...but I'm hoping for better luck now. Should know before the end of the weekend

15:54 cemerick: sounds good

15:55 ericthorsen: cemerick: I think if we can get some of minor but time consuming irritants out of the way...we can make it much easier for people to contribute there

15:55 bulters: g'day all...

15:56 cemerick: ericthorsen: yeah; not sure if you noticed, but I'm going to be trying my hand at getting ccw to use the enclojure repl server

16:07 bigwavejake: I have to pass a seq to a variadic Java method with the following signature: process(Map<String,Object> attributes, String... processingComponentIdsOrClassNames)

16:07 How do I pass the seq of Strings?

16:08 (.process my-obj attributes ["Class1"]) doesn't work

16:18 TakeV: Is it possible to use Clojure with a scripting language?

16:25 dakrone: TakeV: how so? do you mean calling a scripting language from Clojure?

16:26 I've had some success calling ruby via Java's ScriptingEngineManager

16:26 same with javascript

16:26 bigwavejake: I found an answer for pushing Clojure seqs into a variadic Java method: pass them like this: (into-array ["Class1"])

16:27 TakeV: dakrone: Yeah, that's exactly what I mean. Looking into JavaScript or Groovy right now.

16:29 dakrone: TakeV: here's a good article I used as a reference for some of the work I was doing: http://java.sun.com/developer/technicalArticles/J2SE/Desktop/scripting/

16:29 * TakeV nods

16:29 TakeV: Thank you.

17:24 ohpauleez: anyone in here use moustache a lot?

17:29 Raynes: ohpauleez: Doesn't qualify as "a lot", but I used it in tryclojure.

17:30 ohpauleez: Raynes: Is there a way to get this to work without using a Ring Handler style function... ["index" names] {:get (fn-returns-str names)}

17:30 that you know of

17:31 I haven't looked at what is really happening in the code yet, so if you don't know off the top of your head, that's totally cool

17:32 Raynes: No clue.

17:32 ohpauleez: cool, thanks anyway though!

17:42 Raynes: ohpauleez: Couldn't you wrap that in a function?

17:42 ohpauleez: Just came to me that that might work.

17:42 ohpauleez: that's what i just did

17:43 Raynes: Dunno why I didn't think of that at first.

17:43 :p

17:43 ohpauleez: I originally avoided it for readability of the routing table

17:43 but it's not so bad

17:44 arohner: maven accepting invalid checksums into the central repository is one of the most idiotic things I've ever heard

17:44 seriously, wtf maven?

17:45 and serving checksum files that can be read by maven 2.1, but not maven 2.0 (lein uses maven 2.0)

17:58 technomancy: maven 2.1 has a bug that hangs the JVM that they don't seem to be in any hurry to fix =(

17:58 arohner: technomancy: ouch

17:59 does 2.2.1 have any crazy bugs?

18:11 lancepantz: does anyone have an example of using log4j with clojure.contrib.logging?

18:24 arohner: lancepantz: http://gist.github.com/470168

18:24 lancepantz: thanks!

18:30 arohner: lancepantz: that's also using commons-logging btw

18:30 nm

18:34 lancepantz: arohner: i was actually looking for an example with clojure.contrib.logging

18:35 arohner: lancepantz: oh, sorry. reading FTW

18:35 lancepantz: :)

18:36 timcharper: Would I make richhickey cry if I used metadata as a memoize cache bucket ?

18:37 Raynes: timcharper: Dunno. Ask him, he's right over there. :p

18:38 timcharper: rhickey: would it make you cry if I used metadata as a momoize cache for fetching associated records from a database ?

18:38 hahah.. ^momoize^memoize

18:41 lancepantz: timcharper: i believe thats essentially what lancet does if you call a task twice

18:46 timcharper: is that considered an abuse of meta-data ?

18:46 (looking at lancet now)

20:25 dnolen: anybody have luck getting the mysql connector from jarvana ?

20:31 ecret: can someone offer some tips on integrating clojure code inside a java project? I realize I could treat the java stuff as a jar and override classes but is there maybe some other ways?

20:32 i have a large java codebase, that is down to one jar. I would like to start new changes in clojure inside it and am curious for tips. I know clojure and java, perhaps its a vm question?

20:36 Lajla: ecret, I love you, hug me like you'd hug the Microsoft Chief Software Architect.

20:37 ecret: Lajla, my last job I had to start putting .net controls inside a win32 application

20:37 so i would not hug him

20:37 i realize its a poor question. i was hoping maybe there was a magical way

20:39 Lajla: ecret, I atually know crap about clojure, all people here hate me, I'm just here to talk Finnish.

20:39 Of which I also know crap.

20:39 Sorry man.

20:39 But I stil love you.

20:42 wdouglas: I'm having an issue getting swank-clojure to show stacktrace of locals in the repl, I'm using 1.1 with swank clojure 1.2.1 just trying with a simple let and swank.core/break

20:43 technomancy: wdouglas: local inspection requires clojure 1.2

20:43 wdouglas: technomancy: thank you sir

20:50 technomancy: np

20:50 dysinger: I'm looking to hire some clojure devs - if anyone's wanting work

20:58 technomancy: yeah, come work for dysinger and enjoy working from environments like http://www.flickr.com/photos/technomancy/3797798785/ and http://twitpic.com/23bgqb =)

20:59 dysinger: or my version http://www.hoopgirl.com/blog/kauai.jpg

20:59 (not my photo but close)

20:59 :)

21:00 too bad we didn't get any beach computing photos from May

21:01 technomancy: dysinger: http://www.flickr.com/photos/technomancy/4673178238/

21:05 scottj: are there docs for what to do to replace dependency foo with your own foo when both projects use lein?

21:06 technomancy: scottj: yeah, change the group-id to org.clojars.$USER and publish to clojars

21:06 assuming you can't get your changes accepted upstream for some reason. (but you should try really really hard to do so)

21:07 scottj: well I'm thinking for developing the changes and testing them out in the first place

21:07 technomancy: oh sure. if you don't need to share across a team you can just do lein install instead of pushing to clojars.

21:08 or use checkout dependencies

21:32 bulters: anyone here aware of a manual on how to set up emacs/clojure-swank?

21:34 hiredman: clojurebot: emacs?

21:34 clojurebot: emacs is an out-moded belief system

21:34 hiredman: clojurebot: clojure-mode?

21:34 clojurebot: clojure-mode is an Emacs mode for Clojure, found at git://github.com/jochu/clojure-mode.git

21:34 hiredman: clojurebot: slime?

21:34 clojurebot: slime-install is an automated elisp install script at http://github.com/technomancy/emacs-starter-kit/blob/2b7678e9a331d243bf32cd8b591f826739dad2d9/starter-kit-lisp.el#-72

21:34 hiredman: hmmm

22:04 mudge: hello

22:10 i know that if you want to compile clj files to .class files you can use the compile function, like so: (compile 'namespace) but what if you want to compile all the clj files in a whole directory?

22:10 dnolen: Database for a Concurrent World, http://dosync.posterous.com/22516635

22:10 s/Database/Databases

22:15 lancepantz: mudge: you have to do it yourself

22:16 mudge: you can use read-file-ns-decl and find-clojure-sources-in-dir from clojure.contrib.find-namespaces

22:17 then a doseq, and viola

22:17 mudge: lancepantz: oh, i see, neato

22:18 lancepantz: i believe that currently if you compile a ns, it will transitively compile all refered to nses

22:18 but i think that is changing, there was a discussion about it on assembla the past week or so

22:19 mudge: hmm, but actually I'm compiling from ant like so: <java classname="clojure.lang.Compile" fork="true" failonerror="true">

22:19 Ant

22:22 lancepantz: that's going to be a little tricky, i'm not an expert there

22:22 i'm not familier with using the Java task to call clojure

22:23 mudge: k

22:25 i have a different question

22:25 lets say that you have a clojure file with some code in it and you want to use a function in a different clojure file, how do you do that?

22:26 chouser: "some code" but not a lib with its own namespace

22:26 qbg: mudge: Have the first file correspond to a namespace and then use or require it from the other namespace

22:26 mudge: okay, cool

22:27 do all clojure files have a namespace declared at the top?

22:27 can namespaces span multiple files?

22:27 just want to know how things are done

22:27 lancepantz: they do not all have an ns, but its very good practice to do so

22:27 qbg: Usually you have one file per namespace

22:27 mudge: oh okay

22:28 qbg: Though exceptions are made for huge namespaces

22:28 mudge: how would a namespace span more than one file?

22:29 qbg: The way clojure.core does it is that the main file loads the other files at some point

22:29 mudge: yea, that makes sense

22:29 like an "include" in C ?

22:30 read in other files to make a big file?

22:30 lancepantz: mudge: there is a function, load-file

22:31 qbg: and there is also load

22:31 mudge: okay

22:31 qbg: It is sort of like include from C, but it is just another function call in the file

22:32 mudge: i get it

22:51 absalom: Are there really clojure jobs that allow one to program in environments like the ones linked earlier?

22:51 I've been programming professionally in CL for a long time, but usually in secret.

22:55 mudge: wowsers, I just figured out that to have compiled clojure code to .class files I don't have to compile every namespace and use gen-class for every namespace

22:55 i can just use gen-class and compile a single clojure file --- and everything that clojure file requires or uses will automatically be compiled to .class too!

22:55 this makes me happy

22:58 so I'm thinking that you don't want to write clojure in a java way, you just want to be able to interoperate with java

22:58 would everyone agree with me?

22:59 hiredman: is that something in dispute?

23:02 mudge: no, it's just that I'm writing a module for an existing java application, and I found myself writing clojure code as if it was java ---- writing new namespaces and treating them like classes by writing methods

23:02 instead of using a namespace to organize functions

23:02 and implementing interfaces with my namespaces, and extending my namespaces etc.

23:03 instead of all that, i could just use namespaces to organize my functions, and use proxy if I need extra functionality in existing java classes

23:04 i'm figuring out what my coding style should be in clojure

23:04 anybody have any good tips on coding style in clojure, specifically structure of programs

23:05 i'm wondering what's good ways to structure programs in clojure

23:05 hiredman: functions in namespaces

23:05 mudge: maybe writing one main file, and writing libraries of functions for that one main file to use

23:06 hiredman, yes, so functions in namespaces to be used as libraries, right? what do you do to structure the main flow of your program?

23:07 use one namespace for that? and that namespace then just uses other namespaces as libraries of functions?

23:08 hiredman: mudge: depends on what kind of program you are writing and how it interacts

23:09 mudge: well how do you do things hiredman?

23:09 how have you done things?

23:09 hiredman: ~source

23:09 clojurebot: source is http://github.com/hiredman/clojurebot/tree/master

23:09 hiredman: it ain't super but it's something

23:09 mudge: okay

23:11 hiredman: generally stuff can be divided pretty cleanly between namespaces

23:12 but really I don't think any of my personal projects has gotten large enough for it to be a huge concern

23:12 I certainly didn't spend time thinking about what namespaces functions should go in while writing clojurebot

23:12 mudge: okay

23:13 by the way, i know there would be problems with clojure bot using "def" or "defn" but it sure would be cool to be able to do that with clojure bot

23:13 aria42: Anyone know in Slime how to send a form to the REPL rather than the mini-bubber?

23:15 scottj: unclear

23:15 hiredman: mudge: *shrug*

23:25 mudge: so all things in clojure usually lowercase?

23:25 namespaces and function names are all lowercase?

23:25 is that the convention?

23:25 scottj: yeah

23:27 aria42: no ideas?

23:28 mudge: green slime?

23:28 slime has mini bubbers?

23:28 aria42: s/bubbers/buffer/

23:28 I'm not sure what bubbers are, but I'm sure emacs interacts with it

23:30 mudge: why do clojure file names user underscores, but the namespaces use hyphens? file test_this, namespace test-this

23:32 aria42: I believe its because java package and class identifiers don't allow hyphens and since namespaces map to java packages

23:33 mudge: makes sense

23:38 scottj: aria42: you mean how to show the result in the repl instead of in the minibuffer? I don't know what it means to send the form the minibuffer

23:38 aria42: yes.

23:39 so C-X C-E evals and sends result to mini-buffer

23:39 and is there a command that will send the form to the slime-repl and evaluate

23:40 scottj: I think you'll have to write some elisp

23:41 aria42: that's never a good thing

23:41 sigh, you're probably right, I'm a little shocked this isn't baked in

23:41 scottj: aria42: tried #lisp? CLer's tend to have more experience with slime

23:43 hiredman: C-c C-c evals the current form and C-c C-k compiles the current file

23:44 scottj: hiredman: not what aria42 is looking for

23:44 wants the code to be send to the repl and the output to appear there

23:45 "sent to" as in the code is visible in the repl

23:46 hiredman: C-k C-x o C-y

23:46 aria42: hiredman: Thanks!

Logging service provided by n01se.net