#clojure log - Mar 31 2010

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

0:00 hiredman: (vector (rand-int 10) (rand-int 10)) is not a function

0:00 cemerick: mcburton: (defn random-vectors [] (repeatedly #(vector (rand-int 100) (rand-int 100)))

0:00 mcburton: oh yea, I forgot the #

0:00 was typing too fast :)

0:00 cemerick: the notion of a wrapper fn that takes a count that's provided to take, drop, et al. is bad IMO

0:01 certainly not idiomatic. Implement the base case, and then slice and dice as needed using core fns.

0:02 carkh: there once was a re-split function in c.c.str-utils, does it still exist ?

0:02 with some other name maybe ?

0:02 mcburton: camerick: so how exactly would that work?

0:02 hiredman: str-utils no longer exists

0:03 cemerick: mcburton: (take 10 (random-vectors))

0:03 or whatever

0:03 carkh: hiredman:right =/

0:03 hiredman: carkh: renamed to strings

0:04 carkh: hum c.c.strings/partition seems like it

0:04 mcburton: camerick: that doesn't work "Don't know how to create ISeq from: user$random_vectors__2351"

0:04 hiredman: you are missing parens

0:05 mcburton: i fixed that

0:05 wooby: http://gist.github.com/349922 maybe

0:05 mcburton,

0:05 maybe lazy-seq is overkill? i just was under the impression repeatedly was for side effects

0:06 hiredman: wooby: rand-inisn't a pure function

0:07 wooby: ahh

0:07 cemerick: yeah, that docstring is slightly off

0:08 hiredman: if you find yourself thinking of calling lazy-seq directly you may want to re-think

0:09 cemerick: wooby: the no-args part is what distinguishes cases where repeatedly is sufficient

0:10 wooby: so perhaps

0:10 ,(take 3 (map #(apply vector %) (partition 2 (repeatedly #(rand-int 100)))))

0:10 clojurebot: ([4 12] [30 68] [89 60])

0:11 mcburton: hey thats handy

0:11 cemerick: wooby: of course, that's not worth if it you're not parameterizing the partition, but sure

0:11 although use (map vec ...)

0:12 wooby: oh right

0:12 thanks for the tips cemerick, hiredman

0:12 and gl mcburton i'm headed out

0:12 cemerick: np

0:12 * wooby is pleased with growing foo

0:13 wooby: :) clojure rocks so hard

0:13 cemerick: wooby: make sure you pass it along :-)

0:13 wooby: i am! giving presentation this weekend

0:13 cemerick: Excellent! Make some gentle noise about it in the world.

0:14 wooby: planning on it, g'night

0:14 mcburton: thanks for the tips!

0:14 nite

0:14 i'm off to

0:14 wooby: which reminds me, if anyone is in rochester NY / western NY, rochester barcamp is on saturday

0:15 feel free to drop in on my clojure talk and correct me on stuff :)

0:15 cemerick: bit of a hike for me, but good luck anyway

0:15 wooby: thank you sir, adios

0:52 Crowb4r: cemerick: Yeah

0:52 cemerick: Crowb4r: I've never used it. Compojure + enlive is more my style.

0:52 Crowb4r: ahh

0:52 cemerick: sexprs for html generation doesn't make any sense to me.

0:53 Crowb4r: conjure seems like rails.

0:53 cemerick: and I don't generally use RDBMS, so the ORM bit never attracted me

0:54 See, I always like pylons, which was far closer to the metal, as it were.

0:54 s/like/liked

0:56 wooby: hm, having a problem here with midi interaction: http://paste.lisp.org/display/97119#1

0:56 i found an irc log where rhickey mentions this particular problem, but not the fix

0:57 or at least, his explanation of why is beyond me

0:59 cemerick: wooby: clojure generally respects the access restrictions of methods and fields, though you can work around them with reflection.

1:01 wooby: cemerick, i see

1:02 hiredman: wooby: you have to find something public higher up the class hierarchy that exposes what you want and hint with that

1:02 wooby: got it

1:02 does the java compiler do that kind of thing automatically?

1:02 * wooby is curious why equivalent java code works

1:03 hiredman: I doubt the "equivalent java code" is equivalent

1:05 cemerick: wooby: if you hint synth with #^Synthesizer, that code should work

1:05 wooby: MidiChannel[] channels = synth.getChannels();

1:06 hiredman: wooby: in what package?

1:06 wooby: javax.sound.midi

1:06 hiredman: wooby: exactly

1:07 the java code is in the same package

1:07 cemerick: right, so (.getChannels #^Synthesizer synth) works fine

1:07 wooby: aha

1:07 cemerick: the java code is only aware of the statically-declared interface, whereas clojure gets "thrown off" by the runtime type.

1:08 wooby: that is interesting

1:14 Crowb4r: what si the code to show which version of clojure you are using in the repl?

1:14 or in a script in general

1:14 wooby: hiredman, thanks, we're in business now

1:23 kencausey: Crowb4r: *clojure-version*, by the way a quick search of the api page...

1:47 dnolen: is there a function which returns the _last_ logical true value?

1:50 noidi: maybe (last (filter identity foo)) ?

1:52 ,(last (filter identity [1 false nil 3 true nil 2 nil]))

1:52 clojurebot: 2

1:52 dnolen: nice turns I don't need anything that fancy anyway :) (fn [a b] (if b b a)) is good enuf for me, I'm using it with merge-with.

1:53 noidi: ok

1:54 you can do that with #(or %2 %1)

1:54 ...I think

1:56 hmm... that's odd

1:56 ,(#(or %2 %1) false nil)

1:56 clojurebot: false

1:56 noidi: ,(doc or)

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

1:56 noidi: ,(#(or %2 %1) false :truthy)

1:56 clojurebot: :truthy

1:57 noidi: shouldn't it return nil in the first case?

1:57 dnolen: huh, it seems like it should to me.

1:57 noidi: ,(or false nil)

1:57 clojurebot: nil

1:58 dnolen: er noidi: you're reversing the args

1:58 %2 %1

1:59 anyways: #(or %2 %1) does what I want thx.

1:59 noidi: ah that's right, I forgot that I started with your snippet :D

1:59 dnolen: I did too :D

2:25 naeu: I came across the following example macro which I'm still struggling to understand: (defmacro outer [& body] `(let [~'x 5] (do ~@body)))

2:26 could anyone explain why we need ~'x rather than just x?

2:26 Raynes: I know why, but I don't know how to put it into words. :|

2:26 _ato: ,(macroexpand `x)

2:26 clojurebot: sandbox/x

2:27 _ato: ,(macroexpand `~'x)

2:27 clojurebot: x

2:27 Raynes: Ah, yes.

2:27 _ato: syntax-quote (`) resolves symbols to their full namespace

2:27 the reason for this is you might use a macro from one namespace in another

2:28 naeu: ok, so ~' resolves symbols to the current lexical scope unamespaced?

2:28 _ato: in this case you actually want to do symbol capture, which most of the time is usually not what you want a macro to do, so you have to override it with ~'

2:28 ,(let [x 1] `x)

2:28 clojurebot: sandbox/x

2:28 _ato: ,(let [x 1] `~x)

2:28 clojurebot: 1

2:28 _ato: ,(let [x 1] `~'x)

2:28 clojurebot: x

2:30 _ato: so yes, by unquoting and then requoting with a normal quote instead of syntax quote it leaves it unamespaced

2:30 naeu: hmm, i'll still have to give that a bit of time to seep into my conscious

2:31 also, why do we need to deref body?

2:31 _ato: ah

2:31 naeu: is that because its in a do form?

2:32 _ato: ~@ is splicing unquote

2:32 clojurebot: Ack. Ack.

2:32 _ato: ,(let [x [1 2 3]] `(foo ~@x bar))

2:32 clojurebot: (sandbox/foo 1 2 3 sandbox/bar)

2:32 _ato: ,(let [x [1 2 3]] `(foo ~x bar))

2:32 clojurebot: (sandbox/foo [1 2 3] sandbox/bar)

2:33 _ato: see the difference?

2:33 because if you pass in (something) (something-else)

2:33 naeu: ah ok

2:33 it's like Ruby's splat

2:33 _ato: you want the macro to look like (do (something) (something-else)) not (do ((something) (something-else)))

2:34 naeu: cool

2:35 i believe i get that :-)

2:53 thanks everyone for your help :-)

2:53 LauJensen: hey there

2:54 LauJensen: Morning :)

2:56 naeu: LauJensen: just thought I'd make a connection in your head - I'm Sam Aaron the chap that you've been kindly helping out in your blog recently

2:56 thanks to _ato I believe I understand your latest macro example :-)

2:59 LauJensen: naeu: Ah okay - Nice to meet you. What did the trick for you, in terms of understanding?

3:00 naeu: for your implementation of diffuse-board you're essentially assuming the presence of a context-setting macro

3:00 Raynes: naeu: Oh! You're Sam Aaron!?

3:00 Hai, Sam!

3:00 naeu: LauJensen: nothing in particular actually - the problem was that I was missing a few key notions which combined

3:00 Raynes: hey there :-)

3:00 LauJensen: naeu: Ah ok - But yes 'context-setting macro' is the more concise way to put it I think :)

3:00 Raynes: LauJensen: He and I are both Ioke guys (he more than I, but still). :D

3:01 I get around.

3:01 naeu: :-)

3:01 LauJensen: Raynes: Yea I remember being very impressed by the Ioke version of the Transient News Reader I did

3:01 Raynes: I remember finding 2 huge bugs in 2 weeks with 2 small programs. :D

3:01 After that, smooooth sailing. ;)

3:01 naeu: I recently wrote Conway's Game of Life in Ioke - not sure if you've seen it

3:02 Raynes: naeu: I was the one who told you to put it on rosettacode.

3:02 LauJensen: Also caught that, yea

3:02 Raynes: Don't know if you did or not.

3:02 naeu: Raynes: ah, yes, that makes sense

3:02 I should do that

3:02 http://sam.aaron.name/2010/03/29/conway-s-game-of-life-in-ioke.html

3:03 Raynes: I've put a bunch of examples there. As a matter of fact, last time I checked, I had written all of the Ioke examples. I figure someday someone smarter than I will come through and make them all better.

3:03 LauJensen: naeu: Its hard to read source with the formatting you use on your blog though

3:03 Raynes: Until then, I put some examples in which I tried my best on to try to give the language a bit more exposure.

3:03 naeu: LauJensen: what do you suggest?

3:03 LauJensen: darker color for the background, than used for the text :)

3:04 On my screen your variable names like nextGrid are almost the same color as the background

3:04 naeu: ah, that sucks

3:04 Raynes: Same here.

3:04 And with a headache, it isn't pretty.

3:04 naeu: hahaha

3:05 I'll look into it and hook back with you to see if it's any better

3:05 I typically program with a dark background, but for the blog i'm happy with a light background

3:05 however contrast issues on other screens are something I didn't consider

3:05 (on my screen it looks fine)

3:06 right, i'd better head to work

3:06 nice chatting with you :-)

3:07 LauJensen: Yea - Can we expect you to be spending a little more time in #clojure henceforth? :)

3:07 Raynes: We'd miss you otherwise.

3:07 naeu: LauJensen: you certainly can :-)

3:07 Raynes: <3

3:07 LauJensen: Great

3:07 naeu: Ioke is fun, but Clojure is useful

3:07 Raynes: o/

3:07 LauJensen: Ioke isn't useful?

3:08 naeu: and wait till I tell you my plans for next year

3:08 Raynes: It's useful, but meh.

3:08 noidi: is there a version of doto that allows references to the object itself?

3:08 naeu: I've not yet found a use for Ioke. I'm assuming it will be great for internal DSLs and creating data structures that can be interpreted by Clojure

3:08 Raynes: ,(clojure.contrib.duck-streams/slurp* "www.google.com")

3:08 clojurebot: java.security.AccessControlException: access denied (java.io.FilePermission www.google.com read)

3:08 noidi: e.g. (doto (JSpinner. (SpinnerNumberModel. default min max step)) (.setEditor (JSpinner$NumberEditor. % "#")))

3:09 Raynes: Anyways.

3:09 LauJensen: naeu: I have to say though, that despite me not sharing your facination with pink in any way, you've done an amazing job at designing your website, quite unique

3:09 naeu: Ioke isn't yet good (and may never be) for implementing process, but is good for describing it

3:09 noidi: where the % would be the "doto object"

3:09 naeu: LauJensen: thanks very much

3:09 LauJensen: I'm no designer, so that's a big compliment!

3:10 LauJensen: if you have any tips on how to improve it I'm always listening

3:10 right i should dash

3:10 chat later :-)

3:10 LauJensen: naeu: No tips, but I would change pink to dark blue - but I'm biased for hating that color :)

3:10 Bye bye :)

3:11 Raynes: I <3 JSON.

3:15 LauJensen: Raynes: I think I'll make a Ioke vs Clojure

3:15 Raynes: LauJensen: You're my hero, you know that right?

3:15 LauJensen: It'll just be a Venn diagram though.. ( Useful language ) ( Useless languages )

3:15 :D Thanks

3:15 Raynes: Biased, or just plain wrong, it's absolutely exhilarating to read your comparisons.

3:16 LauJensen: wr0ng?!

3:24 noidi: is there a version of replace that recurses into subcolls?

3:27 wooby: noidi, in clojure.walk

3:29 noidi: wooby, thanks!

3:29 wooby: noidi, no trubs

4:04 Raynes: How can I create an empty file somewhere?

4:06 Scratch that, missed the method in File

4:32 wooby: man, fill-queue is ingenious

4:42 esj: wooby: yeah, this one too: http://clj-me.cgrand.net/2009/11/18/are-pipe-dreams-made-of-promises/

4:44 wooby: wow

5:00 Fossi: hiredman: i'll fork lein-gae tomorrow and update it, just so you know

5:39 cgrand: esj & wooby, for your eyes only: it's a stunt don't use that in production code!

5:43 wooby: cgrand, it's ok, it's good enough for academic work :)

5:43 esj: cgrand: rats! I was about to do just that, its a perfect fit. What do you suggest to fill a blocking queue from a callback function ?

5:43 i'm a bit confused with all the options right now

5:45 cgrand: esj: a java queue :-) (beware of nils though)

5:46 esj: cgrand: bummer ! Thanks for the advice though.

5:48 wooby: fill-queue is workin' nicely for me

5:49 pao: #linux

5:49 Fossi: no

5:50 or, yes, actually

5:50 both

5:58 cgrand: esj: http://gist.github.com/350146 -- a replacement for pipe using a java queue

5:58 esj: cgrand: merci, merci !

5:59 cgrand: esj: eer, posted too quickly

6:00 bsteuber: ce n'est pas une pipe! :)

6:01 cgrand: esj ok, the 3rd revision seems ok

6:02 bsteuber, actually I considered "Ceci n'est pas une pipe" as a potential title for http://clj-me.cgrand.net/2009/11/18/are-pipe-dreams-made-of-promises/

6:02 esj: lol

6:02 wooby: http://gist.github.com/350150 yay

6:02 bsteuber: cgrand: sorry for my bad repitition, culture is not my strengh :)

6:03 esj: wooby: nice !

6:03 wooby: thank you!

6:04 i enjoy it so much more than my java version

6:04 i think it even sounds better ;)

6:05 esj: clojure has more soul

6:16 Is this insane: I have a concrete datatype over which I can get a seq. It lives in a reference type and is added to by another thread frequently. I want to return a seq over this data such that the seq blocks when it reaches the end, until new data has been added at which point it moves forward. Is there a suggestion on how to do that ?

6:18 cgrand: esj will you deref you reference type anywhere except in the seq producing code?

6:18 esj: yes. I'm hoping to have multiples of this seq

6:20 cgrand: multiple different seqs by instance of this reference type?

6:21 esj: yes

6:22 i want to use the data as the basis for multiple different calculations. I'm hoping to do so in a dataflow way.

6:24 LauJensen: Emacs users, if you dont have this in .emacs, please insert (add-hook 'before-save-hook 'delete-trailing-whitespace)

6:24 cgrand: esj: try to add a watch to the ref type, watch which enqueues in a pipe then compute the derived seqs by mapping/mapcatting the seq view of the pipe

6:25 esj: cgrand: that's brilliant !

6:26 LauJensen: will do.

6:30 hiredman: :(

6:30 esj: you should repeatedly [romise

6:30 esj: you should repeatedly promise

6:36 esj: hiredman: i was trying to figure out how to do that without spinning, but couldn't figure it.

6:37 hiredman: do you mean a seq of promises, into which I then deliver ?

6:37 hiredman: right

6:38 esj: because that looks like cgrand's code, which he warned me not to use :)

6:41 hiredman: esj: promises block until delivered to, no need to spin

6:42 esj: hiredman: yeah, I get what you're saying. A seq of promises, on the callback deliver the promise. No spinning.

6:42 thanks

6:44 noidi: btw, I wrote the version of doto that I asked about a few hours ago http://gist.github.com/350177

6:44 along with an example of the kind of code I wanted it for

6:44 wooby: http://gist.github.com/350182

6:45 would anyone happen to know why that's throwing "unexpected param type?"

6:48 LauJensen: noidi: I would prefer (doto [obj (JSpinner.)] (.setSomething obj x y z))

6:58 esj: hiredman: FTAOD, would you suggest using a watch on the reference type to trigger the deliver, as per cgrand's suggestion ?

6:59 noidi: LauJensen, so a let-like marker definition instead of the fixed "$" marker?

6:59 LauJensen: exactly

7:00 (defmacro unto [bindings & body] ..) just like everything else in Clojure :)

7:00 noidi: that makes sense. I'll update the macro. Thanks for the mini code review! :)

7:02 LauJensen: np

7:11 patrkris: does anyone know what happened to decorators in compojure 0.4.0?

7:20 noidi: LauJensen, I gave it a go, but there was really no benefit over nesting a let and a doto

7:21 so I'll stick with doto$, which is brief when I don't care about the object's name

7:22 it's a bit like #(+ % 2) vs. #([x] (+ x 2)) vs. (fn [x] (+ x 2))

7:23 the middle ground does not bring much benefit over the long form

7:23 but it was worth a try!

7:34 LauJensen: noidi: alright :)

8:00 carkh: is anybody aware of a compojure version that will work with clojure master 1.2.0 ?

8:04 esj: Is it a REPL artifact (first (map prn [1 2 3 4 5 6])) that all of these get printed ?

8:05 _ato: nope

8:05 it's chunked sequences!

8:05 http://blog.fogus.me/2010/01/22/de-chunkifying-sequences-in-clojure/

8:05 esj: aaaaaaaaaaah ! thanks, I forgot about that

8:08 Fossi: oh, i missed the new book

8:13 caljunior: ,(char 1)

8:13 clojurebot: \

8:16 raek: ,(char 7)

8:16 clojurebot: \

8:17 fogus: ,(map char [1 2 3 4 5 6 7])

8:17 clojurebot: (\ \ \ \ \ \)

8:20 raek: ,(str \return \newline "PRIVMSG #clojure :hello world")

8:20 clojurebot: "\r\nPRIVMSG #clojure :hello world"

8:20 _ato: ,(println \return \newline "PRIVMSG #clojure :hello world")

8:20 clojurebot: PRIVMSG #clojure :hello world

8:20 fogus: Someone should write a function that plays "Sunday Bloody Sunday" using (char 7)

8:22 wooby: ,(apply str (map char [0x67 0x6F 0x6F 0x64 0x20 0x6D 0x6F 0x72 0x6E 0x69 0x6E 0x67]))

8:22 clojurebot: "good morning"

8:46 esj: when is the cached value in a lazy-seq eligible for GC ? For instance: A lazy-seq claims to cache values for future use, yet something like (nth (range 1 a-huge-number) a-huge-number) shouldn't consume the heap ? So when does the cached value get released ?

8:54 raek: I guess the cached value get released when the lazy-seq object and all other objects that has a reference to that value have been released

8:55 esj: i thought so at first, but now think otherwise

8:55 * raek takes a look in LazySeq.java

8:55 esj: ex 1: (def a (range big-num)); (nth a big-num) --- will exceed the heap and blow up, as expected

8:56 but ex2: (nth (range a-big-num) a-big-num) does not, so it can't be keeping the entire cache live

8:57 rhickey: deftype and defrecord - objections?

8:57 esj: so nth must be 'letting go' of values as it goes

8:59 bsteuber: rhickey: sounds okay to me

9:00 esj: I guess because a stores the head of your sequence, it will get realized when processing

9:01 what will (nth (seq a)) do?

9:04 esj: bsteuber: that blew up too

9:06 I completely understand why ex 1 explodes and if lazy seq didn't do any caching how ex 2 wouldn't, but if it does cache then ex 2 not blowing up confuses me. Sigh.

9:06 raek: rhickey: sounds good to me

9:07 so, record doesn't sound to DB-ish?

9:07 rhickey: raek: like many CS words, it's overloaded

9:08 raek: yeah

9:08 esj: just like many CS'tist

9:09 raek: in Ada, record is simply the name for structs

9:09 hoeck: structs in pascal are called records too

9:10 raek: which, IMHO, is the static languages' equivalent of maps

9:10 so for me, "record" sounds natural

9:11 Borkdude: ,(defn foo [n] (+ n 1))

9:11 clojurebot: DENIED

9:11 raek: I guess it depends on what background one has

9:11 Borkdude: I was wondering if clojurebot keeps track of previously defined stuff like a REPL does

9:12 ,(def test 1)

9:12 clojurebot: DENIED

9:12 raek: rhickey: is the possible keys of a defrecord limited to those declared, or can one have more keys, as in defstructs?

9:12 Borkdude: but apparently defining stuff is forbidden

9:12 rhickey: raek: they are extensible

9:13 fogus: Borkdude: Use let

9:13 ,(let [foo #(+ % 1)] (foo 100))

9:13 clojurebot: 101

9:14 raek: ok, so they're just like ordinary maps, but have some field-backed entries?

9:21 cgrand: raek: and you can implement protocols on them

9:23 Borkdude: fogus, ok

9:24 * dnolen is happy with deftype, defrecord

9:25 djpowell: deftype and defrecord sound ok. i didn't like the full map-y construct having a name that is based on the minimal construct, but longer, cause it makes the minimal one sound more important

9:26 eg defmaptype

9:26 dnolen: cgrand: btw, I really like the middleware syntax in moustache. does it always affect all handlers after it?

9:26 (app mw1 h1 mw2 h2), will mw1 be applied to h2?

9:27 djpowell: i wonder whether deftype should have a lamer sounding name though?

9:27 squatting the noun 'type', for something mostly used for low-level interop stuff might be regrettable?

9:28 Licenser: hmm what is defrecord?

9:28 ,(doc defrecord)

9:28 clojurebot: I don't understand.

9:29 djpowell: it is a proposed new name for deftype with full support for metadata and extensible keys

9:29 chouser: deftype is not for interop, it's for building datastructures, particularly ones that should act like maps

9:29 Licenser: ah

9:30 chouser: deftype is not for interop, it's for building datastructures, particularly ones that should act like maps

9:31 the things you'd need for interop (extending concrete classes, adding annotations, etc.) will never be there

9:32 raek: so, if I wanted to implement hash-bag and sorted-bag, I would do it with deftype?

9:32 chouser: sure

9:32 cgrand: dnolen: (app mw1 h1 mw2 h2) is not supposed to work

9:32 djpowell: so that deftype is for building things that implement their own map lookup

9:33 chouser: raek: you couldn't use defrecord because you'd want (:user-key my-hash-bag) to work, but with defrecord that key would be looking up a field of your bag data structure node

9:33 right

9:34 and is probably appropriate for other constructs at that level, like a vector- or list-like thing that users probably won't be doing key lookups on anyway, but you still don't really want to expose your internal fields as keywords to be looked up

9:34 djpowell: yeah

9:36 chouser: but as soon as your keys are app-level fields, and your methods are domain-specific logic, you want defrecord to be handling all the key/field access stuff so your code can consentrarte on the application task.

9:36 dnolen: cgrand: I see wasn't looking closely enough.

9:36 djpowell: i like defrecord as a name for the full map thing

9:36 chouser: which is an interesting separation of concerns. Most languages work hard to unify those two, don't they?

9:38 Your application-level C++ classes still have the powers granted to low-level types. You might want to override operators for your linked-list type, but do you really want to on your Person or CustomerContact class?

9:38 cgrand: dnolen: but middlewares affect all nested handlers

9:39 chouser: rhickey: so "def" can work with more than Vars?

9:40 dnolen: cgrand: yeah I got that bit. middleware + enlive could be interesting. I understand your idea from before. An app can just deliver data and be customizable with templates as middle.

9:40 middle -> middelware

9:41 cgrand: dnolen: exactly!

9:44 dnolen: moustache's design make it easy to come to this realization :)

9:46 djpowell: is it perl that calls things that look like builtin datastructures, but with custom implementations 'ties'? copying perl might not be a great idea though, and i realise that deftypes can do more than that...

9:48 stuartsierra: djpowell: yes, Perl has Tie::File and other Tie::*s

10:09 powr-toc: Does anyone know why I'm getting this stacktrace when running lein test? http://gist.github.com/350350

10:14 hugod: cgrand: would you have a moustache example for servlets?

10:15 * fogus just completed his first work-related Clojure source

10:15 esj: cgrand: your pipe gist this morning is exactly the medicine I needed, much thanks.

10:17 cgrand: esj: you're welcome

10:19 raek: fogus: awesome!

10:19 neotyk: Hi Everyone

10:20 is it possible to compile java code with leiningen?

10:21 powr-toc: fogus: congratulations... can you say what it is?

10:21 neotyk: I think you can just use the javac ant task from lancet

10:22 fogus: powr-toc: At the moment its only support tools. Tree walking/manip stuff

10:22 Borkdude: ah support tools, that's how I tried to use F# when I was a .NET developer

10:22 powr-toc: Can anyone else confirm that lein test works with lein 1.1.0?

10:23 Borkdude: it's probably the easiest way to sneak in some code from your favorite language, a friend fo mine uses Common Lisp tools

10:23 cgrand: hugod: nothing specific to Moustache here since it works on top of Ring (and I can't find an example of a genclassed servlet adapter for Ring. Anyone has such a thing handy?)

10:24 hugod: cgrand: thanks for checking - I couldn't find one either

10:24 powr-toc: for me even running lein test from within the lein project generates the stacktrace I pasted above :-\

10:25 stuartsierra: chouser: is deftype distinct from defrecord in 1.2 currently?

10:25 chouser: defrecord will be like (deftype ... clojure.lang.IPersistentMap) is now, I think

10:25 Borkdude: fogus, you managed to write a book on clojure but not having written work-related code in it beofre?

10:26 fogus: Borkdude: right. All previous work was free-time stuff.

10:27 Borkdude: ok

10:27 I posted some corrections on the forum

10:27 only typo's

10:27 http://www.manning-sandbox.com/thread.jspa?threadID=37212&tstart=0

10:28 fogus: Thanks for that. Every typo is a dagger in my heart, but you've helped to alleviate that pain.

10:28 cgrand: hugod: nearly found it: http://github.com/mmcgrana/ring/blob/master/ring-servlet/src/ring/util/servlet.clj#L128

10:28 powr-toc: ahh its ok... I've fixed it

10:28 Borkdude: some you can easily prevent with a spelling checker ;)

10:28 but I'm glad to help

10:28 powr-toc: I'd forgotten I'd been hacking with lein, and had tried updating the dependency inside it to a newer version... needless to say thats why it wasnt working!

10:29 cgrand: hugod: so you simply write you ns decl with :genclass [HttpServlet] and add a (defservice my-app) to implement the service method.

10:29 neotyk: powr-toc: there is javac for lein http://github.com/antoniogarrote/lein-javac

10:30 powr-toc: neotyk: ahh cool... even better!

10:30 hugod: cgrand: that's what I have, but keep getting class not found exceptions when I try running it..

10:31 cgrand: which class is not found?

10:31 hugod: my genclassed servlet

10:32 powr-toc: fogus: btw... you listed me in your thanks section at: http://blog.fogus.me/2010/01/11/writing-the-next-clojure-book/ but I'm not sure why! :-) What did I do to help?! :-)

10:32 hugod: I am assuming that the ns is the classname to put into the web.xml

10:33 cp2: powr-toc: moral support!

10:33 powr-toc: cp2: lol...

10:33 fogus: I don't see the name powr-toc in my thanks list. ;-)

10:33 powr-toc: cp2: but then I think every active clojure programmer is providing that :-)

10:34 <-- Rick Moynihan

10:34 cp2: powr-toc: i don't give myself too much credit, i just idle most of the time :)

10:35 fogus: incase you weren't aware already, your purchase link is broken

10:35 well, broken in the sense of valid url, broken page

10:35 fogus: powr-toc: You reviewed an early proposal. Thanks for that. Very nice feedback

10:35 Drakeson: how can I generate an object that pretends to be subclass of some java class?

10:36 do I have to use proxy?

10:36 fogus: cp2: I thought we had fixed it. Are you still having issues?

10:36 powr-toc: Ahh... I thought that was for Clojure in Action though

10:36 fogus: powr-toc: Nope. "The Clojure Way" (early working title)

10:36 cp2: fogus: "Site error: the file /affiliate/idevaffiliate.php requires the ionCube PHP Loader ioncube_loader_fre_4.3.so to be installed by the site administrator."

10:36 via the tinyurl

10:37 fogus: cp2: Ahhhh. I see.

10:38 cgrand: hugod: do you find your .class in the war?

10:38 hugod: cgrand: yes

10:38 fogus: cp2: Fixed. Thanks

10:39 gstratton: Drakeson: I believe you can use proxy if you only want to override methods, not add new ones.

10:39 cp2: fogus: sure thing

10:39 powr-toc: fogus: ahhh... that rings a few bells... odd that I can't find any email records of it though

10:39 * fogus just noticed that Manning put another excerpt of the book online http://www.manning.com/free/green_fogus.html

10:40 Drakeson: gstratton: how about reify?

10:40 fogus: powr-toc: My favorite part of your review: "Immutability is key, and caused me to learn Erlang in anger" ;-)

10:40 cp2: hehe

10:40 gstratton: Drakeson: I figured out the class generation stuff mainly courtesy of this blog: http://kotka.de/blog/2010/03/proxy_gen-class_little_brother.html

10:40 (I presume the author's round here somewhere!)

10:41 powr-toc: fogus: sounds like something I'd say... any chance you can email me back the review? :-)

10:41 Drakeson: gstratton: interesting, thanks

10:41 Borkdude: Isn't that what Erlang is all about, passing messages back and forth? ;0

10:42 gstratton: Drakeson: Haven't looked at reify, sorry

10:42 cp2: kotarak's blog has pretty rainbow parens :)

10:43 fogus: powr-toc: Sure. But I do not have your email address.

10:46 hugod: cgrand: thanks for the help. I found an example http://github.com/sethtrain/beget

10:46 Drakeson: cp2: how does he generate those? are they from an emacs color-theme?

10:47 cgrand: hugod: thanks for the link

10:48 cp2: Drakeson: im assuming he just ported a rainbow parens script (probably for vim) to whatever his blog runs

10:48 can always ask him though =P

10:49 * Drakeson lurks ...

11:08 Drakeson: assume that some java class A has a constructor that takes java class B as input. How can I persuade A to accept my generated class (via proxy or gen-class, etc.) that extends B?

11:09 hiredman: it should just work

11:11 gstratton: Drakeson: I don't think it can work with proxy; what is the problem with gen-class?

11:13 Drakeson: http://paste.lisp.org/+22Y5

11:14 cp2: Drakeson: PushbackReader takes a Reader in the constructor

11:14 Drakeson: gstratton: gen-class is far more inconvenient, and I am not sure if that is the problem

11:14 cp2: wrap your proxy with InputStreamReader

11:14 hiredman: gstratton: how would it not work with proxy?

11:14 ,(doc isa?)

11:14 clojurebot: "([child parent] [h child parent]); Returns true if (= child parent), or child is directly or indirectly derived from parent, either via a Java type inheritance relationship or a relationship established via derive. h must be a hierarchy obtained from make-hierarchy, if not supplied defaults to the global hierarchy"

11:15 stuartsierra: Drakeson: what cp2 said; you've got the wrong types

11:15 powr-toc: Is there anyway from a clojure.test run via lein to know that the code should execute under a test environment?

11:15 hiredman: ,(isa? (class (proxy [CharSequence] [])) Object)

11:15 clojurebot: java.lang.RuntimeException: java.lang.IllegalStateException: Var null/null is unbound.

11:15 hiredman: bleh

11:16 anyway, proxies extend classes so they have the same isa relationship as a java class that extends B

11:16 powr-toc: Or am I best just relying on the execution or definition of a function in my test file?

11:16 Drakeson: thanks. somehow I got the wrong type after looking at the its javadoc!

11:16 powr-toc: hmm...

11:16 maybe fixtures

11:17 Drakeson: btw, can that done with reify or deftype?

11:17 hiredman: yes

11:17 reify is like proxy, but better in most respects, infact proxy may be implemented using reify these days

11:19 pao: is 1.2 planned anytime soon?

11:26 stuartsierra: powr-toc: if your functions behave differently in a "test environment" then you're not really testing them

11:26 Drakeson: well, how can I make (instance? java.io.Reader (reify ...)) true ?

11:26 stuartsierra: pao: "when it's ready"

11:27 pao: stuartsierra: thanks

11:27 In fact the only valid statuses are "almost reading / polishing" vs "unknown" :-)

11:29 stuartsierra: pao: "unknown" I think

11:29 pao: stuartsierra: thanks again

11:39 rhickey: chouser: yes, def more than vars now. Nothing else works as well, and toplevel implications are good

11:40 JohnnyL: http://www.youtube.com/watch?v=IKM07drEMRw

11:47 cemerick: rhickey: +1 on defrecord FWIW

11:47 drewr: defrecord ftw!

11:48 chouser: I still prefer defmaptype but defrecord is nothing to complain about.

11:50 drewr: love bites, chouser, love bites

11:52 sorry, "defrecord" put a few songs in my head from childhood

11:54 lpetit: I once thought defrecord was not possible. I like it's brevity over defmaptype.

11:54 cgrand: it may be a good thing that defrecord doesn't have "type" in it

11:55 chouser: I actually think it's bad -- the name you give to defrecord is exactly the same kind of name you give to deftype, and interacts with extend* in exactly the same way

11:55 gfodor: where is this defrecord discussed?

11:56 chouser: gfodor: right here. :-/ you can skim through the IRC logs if you want.

11:56 drewr: gfodor: http://clojure-log.n01se.net/date/2010-03-25.html & http://clojure-log.n01se.net/date/2010-03-30.html

11:56 cgrand: chouser: but their usecases are pretty distinct

11:56 lpetit: chouser: you mean defrecord implies that we create an instance, not a new type

11:57 gfodor: ah, thx, didn't realize it wasn't in wiki somewhere or something

11:57 powr-toc: stuartsierra: true... it's not that they behave differently though... it's more that I want to load a test-database in the test environment.

11:57 I think fixtures are what I need

11:57 drewr: gfodor: you can search for defmaptype, defmap, etc. to find the discussion

11:57 stuartsierra: powr-toc: yes, sounds like a job for fixtures

11:57 Or "contexts" in lazytest

11:57 powr-toc: but right now my tests seem to be being executed twice :-\

11:58 lpetit: So now, we will be able to create new types with deftype on one hand, and *veerry

11:58 powr-toc: stuartsierra: what are contexts?

11:58 lpetit: * easily create new map-like types on the other hand

11:58 chouser: lpetit: no, I'm not too worried about that in this case. more that while classes, interfaces, and datatypes are not exactly the same thing, datatypes and records *are*

11:58 stuartsierra: powr-toc: fixtures in my new testing framework, called lazytest

11:58 not yet finished

11:58 powr-toc: stuartsierra: ahh... I'm currently using clojure.test, because its there already

11:59 cemerick: clojure.test has fixtures too, though they're a little odd

11:59 gfodor: i like entity and defent

11:59 my 2c

11:59 lpetit: I see defrecord as a language provided way to place a tag on a map, so that protocols can behave differently with these kinds of tagged map. A replacement for :type, if you will

11:59 powr-toc: stuartsierra: though I was considering using circumspec... and I saw you were rewriting test-is with protocols...

11:59 cgrand: chouser: I think it's easier to explain that defrecord is a glorified deftype than to explain there are two types of types: one for data, one for structure

11:59 lpetit: At least, it's my "current mental model"

11:59 * cgrand has to run

12:00 powr-toc: but I really want something thats stable just now

12:00 drewr: cgrand: I tend to agree

12:00 lpetit: run cgrand, run

12:00 drewr: although chouser's point is why I liked something like deftypem

12:00 gfodor: defent seems shorter and speakable since its 2 syllables

12:00 drewr: no need to rehash all that; defrecord is a good compromise

12:00 cgrand: lpetit: go home!

12:01 powr-toc: stuartsierra: I have three deftests in my namespace, and I want to execute them all once, but in a specific order... how do I do it? Defining a test-ns-hook seems to mean they get executed twice

12:01 lpetit: I tend to agree with chouser: there's still an underlying problem lurking around

12:01 powr-toc: (via lein test)

12:01 stuartsierra: powr-toc: Halloway and I are collaborating to merge features of lazytest and circumspec.

12:01 powr-toc: stuartsierra: ahhh nice

12:01 * lpetit should stop watching Dora with his children

12:02 stuartsierra: powr-toc: as I recall, there's a bug related to fixtures and test-ns-hook, don't know if that's what you're seeing

12:02 lpetit: Question: how easily could a clojurist create a vector-like type, just like he will be able to create a map-like type.

12:02 technomancy: powr-toc: your tests should be independent and able to run in any order

12:03 lpetit: Seems hardcoded, and not recursive enough, to me.

12:03 powr-toc: technomancy: yeah I know :-) and they are... I'm just curious about clojure.test feature that says you can order them

12:03 technomancy: oh, gotcha; didn't know about that

12:03 cemerick: powr-toc: why not define a single test that calls three fns?

12:03 lpetit: Seems like it will only be possible to have types (other than ones created by defrecord) be composed into other types, and a special case of "derivation" for map-like types

12:05 powr-toc: cemerick: good point... seems like the clojure.test docs were leading me astray a little... it implies that you (deftest addition) (deftest subtraction) and then (detest arithmetic (addition) (subtraction))... I'm guessing it means what you said though

12:06 lpetit: chouser: is it something along the lines I just described that makes you unhappy too ?

12:07 chouser: lpetit: I'm not quite sure what you're getting at. Nothing about the behavior of deftype or defrecord makes me unhappy.

12:07 powr-toc: technomancy: ordering seems like it might be handy if you have a database with state that is built up between tests... I guess that'd be more kinda integration test, than unit testing though.

12:07 chouser: rhickey: will your work on some kind of mix-in capability show up anywhere?

12:08 lpetit: chouser: yes, it's difficult to be precise, it's more a feeling right now.

12:11 chouser: lpetit: I've used deftype quite a bit, mostly in the deftype way but also in the defrecord way. Both seem clean and natural.

12:15 lpetit: chouser: time will tell. I have to use it more myself. My thoughts are "how can I reuse a raw type RT defined with deftype in a higher level construct made with defrecord ? Only by composition I imagine. So a map is the only raw type on which one can easily place a new 'tag' by creating a new record with nothing more than a name"

12:16 powr-toc: out of curiosity, what does RT stand for btw? Runtime?

12:17 chouser: lpetit: well, both types are concrete, so "reuse" in the way I think you're describing is somewhere between discouraged and impossible.

12:18 lpetit: chouser: I see defrecord as "reusing" most of the code from a lower level construct which will define the map type, is that it ?

12:19 chouser: the weakest spot for deftype/defrecord currently is that if you want methods implemented inside the form (I think this gives slightly better performance than 'extend'), the only way currently is to use a macro that tends to end up with a lot of non-macroy code in it.

12:19 which works but seems clumsy. rhickey was looking at a mixin capability to mitigate that.

12:20 lpetit: oh, defrecord itself will yes, but I think so does reify.

12:20 Borkdude: chouser, are you one of the authors of TJOC?

12:20 chouser: Borkdude: yes

12:21 Borkdude: I knew it when you said 'mitigate'

12:21 :)

12:21 chouser: ha

12:23 powr-toc: What's the easiest way to reset a namespace again?

12:23 lpetit: chouser: thanks for the chat, must go home, cu

12:23 powr-toc: I want to nuke all its vars, and re-eval them

12:23 chouser: lpetit: bye!

12:23 powr-toc: I guess I'm looking for (ns-clean)

12:24 stuartsierra: powr-toc: remove-ns then ns

12:25 powr-toc: stuartsierra: ahh cheers

12:29 seems like a slime/swank-clean-namespace might be handy...

12:30 tulsi: hello! how can I specify in gen-class :methods that a method will return a (java) List<T>? for example:

12:30 :methods [[getUsers [] List<User>]]

12:31 chouser: tulsi: just leave out the <...> bits

12:32 tulsi: and return a generic List?

12:32 chouser: yep

12:33 Java's generic types are used only at Java compile time and mostly to avoid manual casting.

12:33 tulsi: thanks!

12:34 chouser: By the time the JVM is running those type parameters have been "erased", a technique confusingly described as "type erasure" :-)

12:34 Clojure avoids manual casting in other ways.

12:35 KirinDave: I read that amazing blog post on using macros to get a clojure-based fluid dynamics sim working.

12:36 My mind was totally blown

12:36 But it also made me sad, because the primitive support is so weird and some of the macros were pretty tortured.

12:36 raek: ah, so java collections really holds Objetcs?

12:38 stuartsierra: rake: yes

12:39 raek, sorry

12:41 KirinDave: http://blog.ksplice.com/2010/03/null-pointers-part-i/ makes me laugh.

12:41 It also makes me wonder if people understand what virtual memory is.

12:42 raek: can two protocols have methods with the same name and be implemented by the same type with different implementations?

12:42 stuartsierra: yes

12:42 KirinDave: God damnit

12:42 raek: that's nice!

12:42 KirinDave: Every time, I paste to the wrong channel.

12:42 Ev

12:42 every time.

12:42 I just gotta close #clojure when i am not using it. :\

12:42 stuartsierra: raek: The two protocols would have to be in different namespaces.

12:43 raek: ok, so methods names are simply namespace resolved symbols?

12:44 powr-toc: This might be handy for clojure slime users: http://gist.github.com/350555

12:46 chouser: raek: they're just functions in the same namespace as the protocol that defined them.

12:46 powr-toc: technomancy: any comments on the above gist's utility?

12:47 raek: powr-toc: yes, indeed

12:47 astoddard: I want to be able to monitor progress of a future. Here is my idea: http://paste.lisp.org/display/97137

12:48 Any comments or criticisms?

12:49 chouser: astoddard: the only thread sending to that agent is the one created by (future ...), so you might consider an atom instead of an agent

12:49 or an AtomicInteger

12:50 powr-toc: raek: any comments on what the function should be called? It really feels like its more part of swank-clojure than slime, but I think as a command its name should be similar to slime-eval-buffer

12:51 astoddard: chouser: Thanks. My initial thought was to make the agent metadata for the future, but it seems futures can't have metadata. Hence the map.

12:51 raek: something-reset-clojure-namespace sounds resonable to me

12:53 astoddard: If work done by the future was pmap'ed would I then prefer an agent over an atom?

12:53 powr-toc: raek: but is that something slime-... or swank-... or perhaps clojure-reset-namespace?

12:54 raek: well, I think it's closer to slime than swank

12:55 chouser: astoddard: hard to say without testing, but for something as simple as inc'ing an integer, I'd start with atom (or AtomicInteger) until is was shown to be undesirable.

12:55 raek: and it depends on slime, so "slime-" sounds good

12:57 powr-toc: raek: true... but it's also clojure specific... so it'd be a patch to either clojure-mode or swank-clojure rather than slime, would it not?

12:57 astoddard: chouser: fair enough, thanks for the feedback. Any idea if it a design choice that futures can't have metadata or just an unhappy (for me) coincidence?

12:58 raek: ah, I see. maybe clojure mode then

12:59 or maybe something like "slime-clojure-"

12:59 chouser: astoddard: I suspect it's a coincidence. 'future' is implemented as a reify which could support metadata but by default does not.

12:59 powr-toc: raek: but then, clojure-mode doesn't require slime/swank... you can use it with inferior-lisp-mode... arhgghghghghghg

13:10 LauJensen: Emacs crowd, if you haven't pull the latest swank-clojure from technomancys repo, with the added swank/break and debug-repl I highly recommend you do so now, insanely helpful stuff!

13:11 xb

13:11 powr-toc: LauJensen: Agreed... it's very, very good

13:15 duncanm: does a clojure map implement the java Map interface?

13:15 carkh: a slime question : when i C-c C-k a function which (println "coucou") , the output goes to *inferior-lisp* instead of slime repl, is there a way to fix that ?

13:15 drewr: duncanm: yes

13:16 duncanm: drewr: and a clojure set implements Set?

13:16 powr-toc: carkh: yes there is...

13:17 duncanm: sigh, the java Map interface is not iterable

13:17 carkh: powr-toc : ah how so ?

13:17 maybe have a link ?

13:17 astoddard: carkh: call slime-redirect-inferior-output

13:17 drewr: ,(.size #{:foo :bar :baz})

13:17 powr-toc: carkh: gimme a minute... just looking

13:17 clojurebot: 3

13:18 powr-toc: carkh: I think this does it... http://gist.github.com/350588

13:18 carkh: yes it is ! thanks both of you

13:19 drewr: I actually like output going into my *inferior-lisp*

13:19 joshua-choi: On defrecord and deftype: when would you ever want a type that cannot act like a map?

13:19 drewr: I keep a separate frame open so I can monitor it

13:20 carkh: drewr : i have too many frames open already =P

13:20 astoddard: carkh: the problem is that swank/slime rebinds *out* (the per-thread default outputstream for clojure) only on the repl thread. Once you run something on another thread default output goes to *inferior-lisp*

13:21 carkh: so when i compile it's on a different thread ?

13:23 astoddard: carkh: That I don't know. It is quite easy to have stuff running off the repl thread though. I consider it a swank "gotcha".

13:24 Any sort of javaland logging or interactive testing of concurrency stuff will often have expected output go to *inferior-lisp*.

13:25 If your println output appeared in *inferior-lisp* it wasn't called on the repl thread.

13:25 carkh: yes i can live with that, but i like to sometimes sprinkle my functions with quick and dirty println debug statements

13:25 i don't want to have to change buffer to see these

13:26 anyways i'm happy now =P

13:27 astoddard: Yeah, I would prefer slime-redirect-inferior-output to be the default for clojure slime.

13:27 powr-toc: astoddard: yeah me too

13:28 astoddard: One could always turn it off. But knowing to turn it one requires relatively obscure knowledge of both clojure and slime/swank.

13:29 carkh: yes that's a whole days work to get slime working the first time

13:29 powr-toc: LauJensen: You mentioned debug-repl when you told us about swank.core/break... Is that included in swank too?

13:30 LauJensen: Yep

13:30 powr-toc: hows it different from break?

13:30 and how do you use it?

13:41 Licenser: greetings my lispy friends

13:45 nteon: Licenser: good day

13:46 Licenser: hi nteon how are things going?

13:47 nteon: Licenser: would be better if I was writing clojure code at the moment :)

13:47 Licenser: heh hmm chatting directly in clojure code, that might be interesting

13:48 (to "#clojure" "It might look like this.")

13:48 LauJensen: powr-toc: You'll have to ask hugod or technomancy for all the specifics, but so far what I've found is that from a swank/break you can switch to the REPL and play around with all the locals

13:48 kotarak: sounds like the debug-repl

13:49 hugod: powr-toc: you can also inspect the locals from the first frame of the stack trace

13:49 LauJensen: kotarak: it is

13:50 powr-toc: cool... i didn't know you could switch to debug-repl

13:50 kotarak: LauJensen: beh, that is not possible from Vim due to the UDP-style connection. :/

13:50 LauJensen: powr-toc: Just dont close the stack-trace

13:50 kotarak: Wow, then that would make a great opportunity for you to switch sides and help out with swank-clojure a little bit :)

13:50 nteon: haha

13:51 kotarak: LauJensen: don't think so...

13:51 ;)

13:51 * LauJensen pouts

13:51 hugod: initially there is no new prompt in the repl - just press return

13:51 nteon: perhaps I was too imprecise when I used the term 'at the moment'

13:53 powr-toc: ahh wow... that is cool... I'd assumed the repl was blocked

13:54 a note would be nice indicating that that's available

13:54 hugod: powr-toc: I have a blog post lined up - just need to persuade my slime to run sbcl again...

13:55 powr-toc: hugod: I look forward to reading it... whats your blogs url?

13:55 Licenser: hmm what was that rails like thing named again?

13:56 hugod: powr-toc: hugoduncan.org

13:56 kotarak: Is shelling out from Java slow?

13:57 LauJensen: hugod: Ah you beat me to it :)

13:57 powr-toc: hugod: the mimetype on your feed.xml is wrong

13:57 LauJensen: kotarak: Not in my experience

13:57 kotarak: k

13:58 hugod: cgrand: for reference - my problem was a (:require [ring.adapter.jetty :as jetty]) - once removed, everything worked

13:58 LauJensen: don't let me stop you

13:58 LauJensen: hugod: Send me a picture where you're smiling and I'll gimpshop a little medal around your neck, that'll be my post :)

13:58 hugod: powr-toc: it is? thanks, I'll investigate

13:59 powr-toc: n/p :-)

13:59 cgrand: hugod: ok, thanks

13:59 hugod: LauJensen: :-)

14:06 Licenser: grrgrr

14:08 licoresse: if I have a map {:fn (fn [x] (+ x x) :arg 123) how can I utilize the fn at :fn with the arg at :arg ?

14:09 LauJensen: ,(let [m {:fn (fn [x] (+ x x)) :arg 5}] ((:fn m) (:arg m)))

14:09 clojurebot: 10

14:10 LauJensen: licoresse: You mean like that?

14:10 licoresse: I would think like this: ((my-map :fn) (my-map :args))

14:10 LauJensen: ^

14:10 Borkdude: ,(reduce #(if (or (= 0 (rem %2 3)) (= 0 (rem %2 5))) (+ %1 %2) %1) 0 (range 1 999))

14:11 clojurebot: 232169

14:11 kotarak: ,(apply (map {:fn #(+ % %) :arg 5} [:fn :arg]))

14:11 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$apply

14:11 LauJensen: licoresse: no diff

14:11 kotarak: ,(apply apply (map {:fn #(+ % %) :arg 5} [:fn :arg]))

14:11 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer

14:11 kotarak: pfff

14:11 licoresse: hmm

14:12 chouser: there's no 'invoke' fn

14:13 licoresse: LauJensen: I get it

14:13 LauJensen: k

14:13 fogus: ,(eval (let [f {:fn (fn [x] (+ x x)) :arg 123}] (map second (seq f))))

14:13 clojurebot: DENIED

14:13 fogus: GRRR

14:13 Oh well

14:13 LauJensen: DENIED

14:14 fogus: I always forget that clojurebot dislikes me and my tricks

14:14 LauJensen: And I think rightfully so in that case, should have been a macro :)

14:14 fogus: We need macrolet

14:17 * joshua-choi wishes there was an invoke function

14:18 ipostelnik: licoresse, what about (defn af [v] (apply (:fn v) (vector (:arg v))))

14:19 cgrand: what is invoke? #(apply % %&)?

14:19 Borkdude: any improvents on Euler #1? (reduce #(if (or (zero? (rem %2 3)) (zero? (rem %2 5))) (+ %1 %2) %1) 0 (range 999))

14:19 fogus: ,(.invoke #(+ % %) 2)

14:19 clojurebot: 4

14:19 fogus: :p

14:19 * licoresse thinking

14:20 licoresse: ipostelnik: I like that one

14:20 kotarak: ,(apply #(apply % %&) (map {:fn #(+ % %) :arg 5} [:fn :arg]))

14:20 clojurebot: 10

14:20 kotarak: cgrand: yup

14:21 licoresse: kotarak: cheers

14:21 ipostelnik: can you get away without inner apply?

14:21 kotarak: cheers?

14:21 clojurebot: hip hip, hooray! hip hip, hooray! hip hip, hooray!

14:22 kotarak: clojurebot: horrido joho

14:22 clojurebot: It's greek to me.

14:22 kotarak: clojurebot: No. It's german.

14:22 clojurebot: excusez-moi

14:23 ipostelnik: ,(apply #(apply % %&) (map {:fn #(+ % %) :arg 5} [:fn :arg]))

14:23 clojurebot: 10

14:23 ipostelnik: ,(#((:fn %) (:arg %)) {:fn #(+ % %) :arg 5})

14:23 clojurebot: 10

14:25 fogus: ,((fn [{f :fn a :arg}] (f a)) {:fn #(+ % %) :arg 5})

14:25 clojurebot: 10

14:26 licoresse: thanks for all input!

14:29 joshua-choi: Hey, could people give me an example of when you'd want to use deftype to create a type that *cannot* act like a map?

14:30 chouser: joshua-choi: if you're implementing PersistentHashMap in Clojure

14:31 that is, you'd want it to act like a map, but not with keys of :count, :root, :meta, etc.

14:31 joshua-choi: chouser: What do you mean by that last part?

14:32 chouser: joshua-choi: maybe this is a better example: http://github.com/richhickey/clojure/blob/master/src/clj/clojure/gvec.clj

14:32 joshua-choi: Okay, I see.

14:34 LauJensen: joshua-choi: you do?! :)

14:35 joshua-choi: LauJensen: :)

14:56 Raynes: How is this causing a stackoverflow? http://gist.github.com/350721 it overflows when I try to evaluate the function, not when I call it.

14:58 chouser: neat

14:59 Raynes: :o

14:59 chouser: ,(fn [] (->> :a :b (->> :c :d)))

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

15:00 Raynes: I can't nest them? :(

15:00 It felt all warm and fuzzy inside.

15:00 chouser: well, first of all it's a bit weird to nest them like that

15:01 Raynes: I know, but it was really fun. :|

15:01 chouser: I guess that should expand to (:b :a (:d :c))

15:02 is that really what you wanted?

15:03 Raynes: Yeah, I believe so.

15:04 chouser: ,(-> '(->> :a :b (->> :c :d)) macroexpand-1)

15:04 clojurebot: Eval-in-box threw an exception:java.lang.StackOverflowError

15:04 chouser: huh. that works for me.

15:10 kotarak: And another recur-try ...

15:11 hugod: a quick explanation of the new swank.core/break in swank-clojure http://bit.ly/bcRUSM

15:18 hoeck: hugod: great!

15:19 patrkris_: kotarak: a question about vimclojure - what's the best way of defining per-project lispwords?

15:19 kotarak: patrkris_: this is an unsolved problem. You can check Luc Hermite's per-directory-vimrc

15:20 patrkris_: \aw is a rather unfulfilling workaround

15:20 patrkris_: kotarak: Ok. Just out of curiosity, do you know how the Emacs folks do it?

15:21 kotarak: patrkris_: I think they have some heuristic (with-*). I don't think we can use metadata (the arglists). I'm probably going the same route with the heuristics...

15:21 patrkris_: ok sounds good

15:34 cemerick: /join #tomcat

15:34 fooey :-|

15:35 hiredman: hah! now we know

15:35 cemerick: good thing I wasn't typing something more risque, like /join #php or something :-P

15:35 lancepantz: hahah

15:35 kotarak: :)))

15:35 cemerick: hiredman: it's crazy, I know. The remote hot deployment is pretty hard to beat tho.

15:36 it's amazing how much longevity there is in the jvm world. I first used tomcat ~2001

15:36 ...and haven't since ~2004, but there it is still, waiting for me.

15:36 chouser: now with annotation support

15:37 * chouser does know anything and is just trying to be funny.

15:38 cemerick: I've come to quite adore the intransigence of Java-the-language, and the knots it ties itself up in. Makes things comfortable for the big guys (for bad reasons, but whatever), which leaves a huge, stable platform for people like us to play around in.

15:38 kotarak: boah, "longevity" and I know the epoch BJ... I'm old. :|

15:39 cemerick: If Sun had pushed out something like groovy in 2002 or whatever, fully reified generics, etc. etc., I'm not sure things would be better, net-net.

15:42 TakeV: So, no different between compile time, run time, and the development time basically means that one can modify running code without rebooting?

15:42 cemerick: Within some constraints, if you want to take it that far, yes.

15:43 TakeV: Ah, what would those constraints be?

15:44 cemerick: The biggest one is that you can't (easily) change your classpath at runtime. There are workarounds, but they're not pretty.

15:47 TakeV: That's a pretty big one. Though, if classpath doesn't need to change, then that is an incredibly useful feature of the language...

15:49 cemerick: TakeV: The workaround is to add a directory to your classpath, and then unzip jars you want to add into that directory. Definitely hacky.

15:49 There are other limitations -- like, most jvm configuration (heap size, vm type, the whole array of tuning parameters) are static, and set once at startup.

15:49 TakeV: Huh.

15:50 cemerick: You can't readily reload statically-defined classes, without some magic like rebol (or whatever it's called these days).

15:50 But these are all very minor edge conditions IMO.

15:51 The biggest difference in this area compared to systems like some CLs and smalltalks is that there's no notion of an image -- you can't dump, and then deploy that somewhere else.

15:52 But then, that's a plus in my book.

15:52 * TakeV nods

15:53 hiredman: clojurebot: clojure?

15:53 clojurebot: clojure > scheme

15:53 hiredman: bleh

15:53 clojurebot: clojure?

15:53 clojurebot: clojure is the bestest programming language available.

15:53 hiredman: I am looking for the one about trades offs

15:53 TakeV: clojurebot is smart.

15:53 hiredman: clojurebot: clojure?

15:53 clojurebot: clojure is the brand

15:53 Licenser: greetings my clojurey friends, is there a way to supress, capture, eat, destroy, anihilate, warnings?

15:54 hiredman: warnnings like reflection warnings?

15:54 or exceptions?

15:54 Licenser: like: WARNING: reader macro ^ is deprecated; use meta instead

15:54 they get printed to the shell and that is right now very annoying

15:54 hiredman: those warnings should be compile time only

15:54 Licenser: ah

15:54 hiredman: if you aot you should not see them

15:55 Licenser: yes but the problem is they are run in a sadnbox so compiled realtime

15:55 chouser: no difference between compile time and run time also means you have access to at least the entire language at compile time, which makes certain behaviors and performance tweaks possible

15:55 Licenser: I trind to rebind *out* and *err* but nothing seems to work

15:56 kotarak: One could also drop ^. That should make the warning go away... ;)

15:56 hiredman: Licenser: you can try re-binding various *whatever* things

15:57 Licenser: kotarak: if it were my code, yes I'd do that, but the problem is it isn't my code :P

15:58 kotarak: we're working on defn's waltom

15:58 kotarak: waltom?

15:58 carkh: is there a way to "dechunk" a sequence ?

15:58 Licenser: walton

15:59 chouser: carkh: yes. while I'm looking, could you explain why you want to dechunk?

15:59 Licenser: kotarak: it is a very neat idea, it looks for code examples in the logs from #clojure to give people a hint how to use code

15:59 kotarak: oh. ah.

16:00 Licenser: so to extract more usefull code examples we push them through a sandbox, executing them to see if they are running OK.

16:00 so some of the logs from clojure contain the ^ opperator

16:00 carkh: chouser : i have a serie of predicates in a sequence, they need to be executed until one is false, they might have side effect and throw an exception if the one executing before wasn't returning true

16:01 the old way was : use some

16:01 chouser: carkh: http://blog.fogus.me/2010/01/22/de-chunkifying-sequences-in-clojure/

16:02 carkh: can't use reify =/

16:03 i'm trying to get out of compojure right now, but i still have dependencies to it, and it's not working with head

16:03 chouser: carkh: so perforance isn't too huge an issue here?

16:03 carkh: mhhh i guess not

16:03 proxy ?

16:03 chouser: yeah, or lazy-seq

16:03 lazy-seq would be easire

16:04 easier

16:04 carkh: lazy-seq isn't chunked ?

16:04 chouser: not automatically, no

16:04 carkh: mhhh that means that my actual use case (as opposed to test case) wouldn't be chunked

16:05 anyways i think this issue is code smell

16:05 i might go and rethink the whole thing

16:05 thanks for your input chouser

16:05 chouser: untested: (defn seq1 [s] (lazy-seq (let [[x & xs] s] (cons s (seq1 xs)))))

16:06 oh, I see. well, using something like seq1 just for a test case doesn't sound too bad.

16:06 natesbrain: hi, I am seeing weird behavior from load

16:06 chouser: though I suppose having your app code break on unchunked seqs feels a bit fragile.

16:07 carkh: indeed =P

16:07 natesbrain: I'm trying to set a context classloader in one file

16:07 and then load a second that requires the classloader

16:08 chouser: carkh: wait, you're using 'some'?

16:08 natesbrain: I can do it when I call load separately, but put both files together and it throws a ClassNotFound exception

16:08 carkh: yes

16:09 chouser: oh, probably (some identity (map #(% x) preds))

16:10 which might call a pred past a false one

16:10 carkh: yes but i have a negation as well

16:10 chouser: oh right, you said that. :-) sorry.

16:10 carkh: hehe don't be sorry !

16:10 chouser: (some #(not (% x)) preds) should work

16:12 carkh: hum yes it does =/

16:25 Crowb4r: ohh wow, so netbeans is super nice for clojure

16:25 heh

16:25 cemerick: Uh-huh. :-)

16:28 Licenser: hmm is clojure.lang.Var.deref the @ deref or another one?

16:28 chouser: the same

16:28 Licenser: okay thanks :)

16:28 chouser: ,'@foo

16:28 clojurebot: (clojure.core/deref foo)

16:29 chouser: and (deref foo) is just (.deref #^IDeref foo)

16:30 raek: what clojure.contrib versions are available with leiningen?

16:34 technomancy: raek: all of them, pretty much

16:35 Licenser: yea you just have to roll your dice and hope you find the right combination of prefixes, suffixes, version numbers group id's

16:35 raek: exactly...

16:35 Licenser: but mvn/leinigen are so great for dependency management :P you don't need easy when you can have XML ;)

16:35 </sarcasm>

16:36 XML is enterprise!

16:36 raek: so, which combos work?

16:36 Licenser: I've no clue, I gave up

16:36 bsteuber: raek: just use the latest one from http://build.clojure.org/releases/ or http://build.clojure.org/snapshots/

16:36 Raynes: I want a JSON build system.

16:36 :D

16:37 Licenser: greetings Raynes

16:37 Raynes: Greetings.

16:37 Licenser: I want something that is as simple as rubygems :(

16:37 I know everyone will hate me again for bringing it up

16:37 * bsteuber hopes Maven 3 will be completely polyglot

16:37 raek: also, is there any fix for the lein repl always uses 1.1.0 problem?

16:37 Licenser: Raynes: I've an idea for sexpbot!

16:38 Raynes: Licenser: Shoot. :D

16:38 Licenser: add walton to it

16:39 it extract code examples from irc logs and gives you hints on functions

16:39 also it uses clj-sandbox too :P

16:39 Raynes: Cool.

16:39 Licenser: which of cause in itself is a reason to use it ;)

16:40 Raynes: I'll see about that. I'm working on figuring out how to do a privilege system with IRC being such a horrible protocol and such.

16:40 Licenser: *G*

16:40 also then we connect sexpbot and clicki and epic and walton and we'Ve a huge fuzzy program that can do everything

16:40 Raynes: Hehe.

16:43 raek: bsteuber: thanks! now I can finally run lein deps

16:43 bsteuber: ur welcome :)

16:43 raek: is there any way of doing what lein repl or swank-clojure-project does, but with another clojure version?

16:46 patrkris_: kotarak: what's the easiest way of using clojureql in its current state? I guess I have to compile it myself and include it in the classpath?

16:46 kotarak: patrkris_: use master and avoid frontend-2.0 branch

16:46 It's the "old" cql.

16:47 patrkris_: kotarak: ah

16:47 ok

16:48 kotarak: but I was actually hoping to start using the new frontend-2.0 stuff - it looks really promising :)

16:48 kotarak: patrkris_: yes. But it is incomplete.

16:48 patrkris_: incomplete to the point of unusability.

16:49 patrkris_: kotarak: Ok. I think I'll just wait then. I was just looking to play around with it.

16:49 kotarak: patrkris_: playing around is possible. But I doubt you get a working query. :/

16:50 patrkris_: kotarak: heh, ok :) will it at some point be possible to avoid excluding the clojure.core functions like the standard operators when clojureql is used? I'm thinking about your blogpost about cql-frontend-2.0 where you do that.

16:50 could it possibly be avoided by constructing a macro inside which they are bound to the cql specific versions or something?

16:51 kotarak: patrkris_: that would be possible, but it is a rather voodoo thing.

16:51 My current approach is rather to use an alias.

16:52 (require '[clojureql.query :as q]) ... (q/= ...) ..

16:52 patrkris_: yeah, that probably wouldn't be too bad

16:52 Borkdude: hello Associat0r

16:53 Associat0r: hey Borkdude

16:53 kotarak: patrkris_: what also works quite well is (use '[clojure.query :as q :exclude (= <= ...)])

16:53 Borkdude: I see you're also from NL

16:53 kotarak: patrkris_: then you just have to prefix the core symbols.

16:53 patrkris_: ymmv

16:53 Associat0r: Borkdude: yes

16:53 patrkris_: kotarak: yeah, cool

17:00 Borkdude: Associat0r, are you in a Clojure user group?

17:02 Associat0r: Borkdude: no

17:02 Borkdude: you?

17:02 Borkdude: Me neither

17:04 There is a group in Amsterdam that meets regularly

17:05 anyone here got some experience with Eclipse + Counter Clockwise?

17:05 How do I get a repl without having to run a file

17:09 Associat0r: Borkdude: I just started learning Clojure but have no plans to use it for real

17:09 Borkdude: ok

17:11 Associat0r: Borkdude: what are you doing with it?

17:14 Borkdude: Until now just exploring it

17:16 Associat0r: Borkdude: what other languages do you use?

17:16 licoresse: Is there add-watch for atoms?

17:17 or would I just use a ref instead

17:17 Borkdude: Associat0r: I used Common Lisp, Java, C#, F#, SAS if you can call that a lang

17:18 currently mostly java, because I have to adapt to my environment ;-)

17:19 Associat0r: Borkdude: we have ##fsharp channel

17:19 Borkdude: ok, that's cool

17:20 but I think Clojure is more what I need

17:20 Chousuke: licoresse: shouldn't add-watch work on atoms just as well as on refs? :/

17:20 hoeck: licoresse: add-watch works on all ref types, including atoms

17:20 licoresse: I was not aware of that

17:21 ,(doc add-watch)

17:21 clojurebot: "([reference key fn]); Experimental. Adds a watch function to an agent/atom/var/ref reference. The watch fn must be a fn of 4 args: a key, the reference, its old-state, its new-state. Whenever the reference's state might have been changed, any registered watches will have their functions called. The watch fn will be called synchronously, on the agent's thread if an agent, before any pending sends if agent or ref. Note that

17:21 licoresse: silly me

17:21 polypus: i would like to (derive X ::sequential) for use in a multimethod, such that it dispatches for any object which is (sequential? obj). is there such a beast? else how should i go about it?

17:22 btw, i am using clojure.contrib.generic stuff, so i have to dispatch on type

17:24 i.e. i'd like to write (defmethod * [::sequential ::sequential] [x y] ...), and have it catch all objects for which (sequential? obj) is true.

17:26 technomancy: so what's the deal with persistent HTTP connections in the JDK?

17:26 according to http://java.sun.com/j2se/1.5.0/docs/guide/net/http-keepalive.html HTTP connections are persistent by default, but we did some perf tests that indicate there's no difference between the default and explicitly setting Connection: close

17:29 polypus: the above is why i often think isa? should be able to take predicate functions

17:31 (isa? (type 5) number?)

17:41 cemerick: technomancy: the JDK will often ignore Connection: close

17:41 the keepalive impl has some faults :-(

17:41 lancepantz: how can i get a string into an inputstream?

17:42 cemerick: People generally go to httpclient if they really want to know what's going on, but that's not a lot of fun.

17:42 * licoresse trying to understand the ::

17:43 kotarak: ,::foo

17:43 clojurebot: :sandbox/foo

17:43 kotarak: ,(= ::foo :sandbox/foo)

17:43 clojurebot: true

17:43 licoresse: so :: belongs in the namespace

17:43 kotarak: yup

17:43 licoresse: and can therefore never conflict with a similar :

17:44 kotarak: (require '[foo.bar.baz :as baz]) ::baz/frob => :foo.bar.baz/frob

17:44 licoresse: ah

17:45 my global namespace is way poluted

17:45 polluted

17:48 technomancy: cemerick: yikes. good to know; thanks.

17:49 cemerick: technomancy: that's not to say that it's not usable; in general, you can let it do its thing and ignore it. The price to pay is that (esp. when interacting with servers that have less-than-stellar keepalive impls), things can go sideways in odd ways.

17:53 technomancy: See http://stackoverflow.com/questions/1440957/httpurlconnection-getresponsecode-returns-1-on-second-invocation/1441491#1441491 and http://stackoverflow.com/questions/1936872/how-to-keep-multiple-java-httpconnections-open-to-same-destination/1936965#1936965

17:54 raek: what is the simplest way of getting a seq of n values of x?

17:54 polypus: (take n (repeat x))

17:55 unless you mean that x is a seq and you only want n of those, in which case, it's just (take n x)

17:55 ska2342: ,(replicate 3 \a)

17:55 clojurebot: (\a \a \a)

17:57 raek: ah, replicate, there it is!

17:57 kotarak: ,(repeat 3 \a)

17:57 clojurebot: (\a \a \a)

17:58 ska2342: raek don't ask me why replicate exists, when repeat has just the same form...

17:58 Raynes: (doc replicate)

17:58 clojurebot: "([n x]); Returns a lazy seq of n xs."

17:58 Raynes: (doc repeat)

17:58 clojurebot: "([x] [n x]); Returns a lazy (infinite!, or length n if supplied) sequence of xs."

17:58 kotarak: ska2342: once upon a time repeat did only infinite things

17:59 ska2342: replicate will be go away eventually...

17:59 ska2342: kotarak: good to know.

18:00 raek: ah, ok

18:00 naeu: I'm trying to get my head around the combination of the functional style and java interop

18:01 could anyone shed some light in my direction. How do I call the Java instance method getName on each of the File objects in a seq

18:01 ska2342: naeu: use map ?

18:01 naeu: for example, I want to make the following print out less noise info:

18:01 raek: (map #(.getName %) files)

18:02 boojum: (for [f files] (.getName f))

18:02 naeu: (map println (seq (. (new File "/Users/sam/") listFiles)))

18:02 kotarak: naeu: map is not a loop

18:02 ska2342: naeu: when printing for side effects use doseq

18:02 naeu: ah, thanks - I'm still trying to break out of Ruby-thoughts

18:03 ska2342: all the credit to kotarak ;-)

18:04 kotarak: ska2342: I'm a nit-picker. :P

18:04 tomoj: that's what I was thinking about the blog post someone linked to a while ago

18:04 http://blog.fogus.me/2010/01/22/de-chunkifying-sequences-in-clojure/

18:04 that one

18:05 is there a reason we need seq1 other than so that we can use map with side effects?

18:05 oh, wait

18:05 yes, of course :)

18:06 the printing was there just to demonstrate the problem chunking causes

18:06 boojum: tomoj, i think the argument was exploding computations

18:06 tomoj: yeah, I was just not thinking straight

18:23 polypus: how do i define a new function with the name / (forward slash). i did it once, and there was something special i had to do because / is special, but just can't remember

18:23 btw, i've already :refer-clojure :exludeded it

18:24 raek: then I think it should work...

18:24 what error do you get?

18:33 polypus: raek: thanks, it does actually work. i just tried it in a minimal file w/o a problem. not sure yet why it isn't working in my real code

18:34 raek: I've made an implementation of "hash-bag", a bag/multiset based on a hash-map: http://gist.github.com/350986

18:34 (def b (hash-bag :a :b :c :a :b :c))

18:35 (count b) => 6

18:35 (seq b) => (:c :c :b :b :a :a)

18:36 (seq (conj b :a)) => (:c :c :b :b :a :a :a)

18:36 (seq (disj b :a)) => (:c :c :b :b :a)

18:37 what do you think?

18:37 Chousuke: huh

18:37 ah, hm, never mind

18:38 I misread you and was thinking of hashmaps. that behaviour then thoroughly confused me :P

18:39 is disjoining nonexistent keys an error? :/

18:39 ,(disj #{} :a)

18:39 clojurebot: #{}

18:42 raek: ys

18:43 (disj b :f) => IllegalStateException: Can't disjoin non-existing key

18:44 count should be constant time and seq lazy

18:44 is there any other expectations I should be aware of?

18:45 arohner: raek: count is not always constant time

18:45 raek: I've noticed that it is for a lot of clojure's data types

18:46 even PersistentList

18:46 arohner: raek: yeah, for the ones that implement ICountable or whatever it is

18:46 raek: IPersistentSet extends Counted

18:47 I really love that adding one such detail (constant time count) is really trivial in persistent data structures

18:51 btw, is (new TypeDefinedWithDefType field1 field2) the right way to make a new instance inside a method implementation?

18:52 in the methods, the type name seems to refer to the class rather than the generated factory function

19:02 Raynes: It isn't bad to use slurp* to get a webpage, is it? :o

19:03 I tend to use it for simple API calls for stuff like bit.ly.

19:06 raek: I guess it depends on how much data it slurps

19:07 the point of streams is to not be required to have everything in memory at once

19:08 if having the whole webpage in memory is no big deal, then I don't see why not

19:15 duncanm: is there a reason why 1.0f is not a proper float literal?

19:15 ,1.0f

19:15 clojurebot: Invalid number: 1.0f

19:15 duncanm: i thought Clojure numbers look the same as Java numbers

19:22 raek: (class 1.0)

19:22 ,(class 1.0)

19:22 clojurebot: java.lang.Double

19:26 raek: I don't know any particular reason for why there isn't a reader syntax for java.lang.Float

19:27 but you rarely deal with the primitive numeric types directly in clojure

19:33 quidnunc: How do I use slime with clojure and other lisps? This was working a few months ago but now some magic (c.f. slime-read-interactive-args) is happening that I don't understand how to deal with.

19:50 dnolen: quidnunc: you're best bet if you want to work with other lisps as well as Clojure is using technomancy's swank-clojure on GitHub, esp. if you want to use the latest version of SLIME. You'll need some .emacs-fu to make it work tho.

19:52 alexyk: liebke: ping

19:53 liebke: alexyk: hey

19:54 tomoj: has anyone had any luck with using the ELPA clojure stuff to connect to multiple swank servers at once?

19:58 alexyk: is (apply + things) preferable tp (reduce + things) ?

19:58 to

19:58 AWizzArd: They are conceptually different things.

19:59 alexyk: ,(let [s [1 2 3]] [(apply + s) (reduce + s)])

19:59 clojurebot: [6 6]

19:59 alexyk: that's what I mean

20:00 their results are identical

20:00 AWizzArd: Yes, there exist several such cases where apply and reduce both can be used.

20:00 alexyk: so what I'm wondering is the performance in this specific case

20:01 AWizzArd: They should be practically identical, as those functions that you apply and which produce the same result use reduce under the hood, or something similar.

20:04 quidnunc: dnolen: I am using swank-clojure. I thought my fu was sufficient but it appears not. The question was what am I missing?

20:06 dnolen: quidnunc: technomancy's fork of swank-clojure? The original project will not work.

20:06 or won't work with SLIME master rather.

20:11 TakeV: How does one open a new frame and buffer in Emacs? Watching the guide on how to set up slime, and when he says to open a new file, it just appears, no commands inputed.

20:11 tomoj: TakeV: maybe try #emacs?

20:12 (but.. C-x C-f)

20:12 TakeV: I didn't know there was an #emacs.

20:12 AWizzArd: http://www.cheat-sheets.org/

20:12 tomoj: (also try C-h t)

20:12 (that is, hit control+h, then hit t)

20:12 AWizzArd: There you can download and print a two-page overview.

20:12 TakeV: Thanks.

20:12 hoeck: TakeV: C-x 5 2

20:26 quidnunc: dnolen: I fetch technomancy branch but I still have the following basic problem: How do I choose clojure as my slime lisp implementation?

20:28 dnolen: quidnunc: I don't really recall I let my SLIME lisp stuff rot a bit. You definitely need to set some swank-clojure vars.

20:34 quidnunc: dnolen: Yes, I had it working before. But now the behaviour seems to have changed. slime-lisp-implementations is automatically configured anymore it seems

20:35 s/is/is not/

20:42 raek: we now have a project name generator: http://www.morewords.com/ends-with/sure/

20:42 :D

20:43 just replace the last s with j, and you're good to go!

21:05 quidnunc: Can anyone clue me in on how to build swank-clojure?

21:27 dnolen: quidnunc: I recommend using lein to do that

21:27 quidnunc: lien compile should work

21:28 quidnunc: dnolen: Will try it, thanks

22:12 alexyk: is there a map which preserves the type of the input, e.g. maps vectors onto vectors?

22:22 arohner: alexyk: no, but it's easy to write your own using 'into' and 'empty'

22:22 I have my own map-same

22:23 http://gist.github.com/351238

22:23 alexyk: arohner: how's empty used?

22:23 looking...

22:24 nice

22:24 arohner: the (apply map f colls) should probably be moved into the let...

22:25 tomoj: hmm, using into there raises the constant factor?

22:27 arohner: tomoj: yeah, but if you need at a collection of the same type, you're going to do it anyways

22:27 tomoj: is there a faster way to do it?

22:28 tomoj: well, that's what I was thinking

22:28 instead of using map, can you rewrite map to keep the type?

22:28 couldn't be lazy

22:28 but of course it can't..

22:29 arohner: ~map

22:29 clojurebot: map is lazy

22:29 arohner: thank you clojurebot

22:29 ~def map

22:29 tomoj: god I hate github on core.clj

22:51 rem7: whats the best way to get an image into clojure (jpg, png, tif -- anything better than 8bit would be a plus) ImageJ?

22:52 Im not very familiar with Java's libraries but in C I use openCV mostly for image processing stuff.

22:53 hiredman: ~javadoc javax.imageio.ImageIO

22:53 ~google clojure opencv

22:53 clojurebot: First, out of 6090 results is:

22:53 Fun with Clojure, OpenCV and Face Detection

22:53 http://nakkaya.com/2010/01/12/fun-with-clojure-opencv-and-face-detection/

22:53 rem7: yeah I saw that...

23:04 slyphon: the compiler is confusing me

23:04 it's giving me very strange "No such var" errors

23:05 where the var in question is very much defined

23:05 arohner: slyphon: how do you know it's defined?

23:05 * slyphon double-checks

23:07 slyphon: hrm, wtf

23:07 ok, now i'm just confused

23:07 when i C-c C-k the file, it gives me the "no such var" error in a *different* file than the one i'm compiling

23:08 arohner: slyphon: do you have require/use statements in your files?

23:08 slyphon: yeha

23:08 arohner: slyphon: and do you have circular requires?

23:08 slyphon: hrm

23:10 argh

23:11 this programming thing is hard

23:13 wow, this is gonna be tricky

23:24 brweber2: how can I improve this code? (and (.exists file) (.isFile file) (.canRead file))

23:24 ->, ->> and doto ... none fits exactly

23:24 is there something that does?

23:25 lancepantz: anyone mind taking a look at http://www.pastie.org/898326 for me?

23:26 i'm having difficulty figuring out the splicing unquote reader macro

23:26 arohner: brweber2: I'm not aware of anything

23:26 hiredman: foo needs to be an iseq for splicing

23:27 ,(let [a '(1 1)] `(~@a))

23:27 clojurebot: (1 1)

23:27 hiredman: ,(let [a '(1 1)] `(~a))

23:27 clojurebot: ((1 1))

23:27 hiredman: yes?

23:28 tomoj: ,(let [foo ["1" "3"]] `(~@foo))

23:28 clojurebot: ("1" "3")

23:28 tomoj: m is ["1" "3"] here

23:30 hiredman: the whole point of macros is the arguments are not evaluated

23:30 m is the symbol m

23:31 tomoj: oh, yes :)

23:32 foo is the symbol m, I guess?

23:32 hiredman: yes

23:32 tomoj: so I guess you want (apply println ~foo) instead of splicing

23:32 slyphon: god *dammit* it's hard to track down circular deps

23:33 lancepantz: so in my example, how do i get my for loop to return an iseq?

23:33 hiredman: clojurebot: for?

23:33 clojurebot: for is a loop...in Java

23:33 hiredman: clojurebot: for?

23:33 clojurebot: for is not used enough

23:33 hiredman: clojurebot: for?

23:33 clojurebot: for is not a loop

23:33 lancepantz: for macro, sorry

23:33 hiredman: not a loop

23:33 tomoj: lancepantz: m is an ISeq in your example

23:33 hiredman: it's a list comprehension

23:33 tomoj: the problem is that foo isn't pointing to the value of m

23:33 lancepantz: i get for, typo, sorry

23:33 hiredman: it does return a seq

23:33 but it returns a seq at runtime

23:34 macros run before/as part of compile time

23:34 why do you want to write macros anyway? just use hofs

23:35 lancepantz: just learning

23:35 slyphon: i don't understand why i'm having so much trouble with references

23:35 somnium: hofs?

23:35 slyphon: don't hassle the hofs

23:36 hiredman: higher order functions

23:36 somnium: Ill have to patch that one into wtf-mode

23:37 hiredman: juxt, partial, comp

23:38 somnium: so thats what those are

23:39 hiredman: compliment, but (comp not ...) has less keystrokes than (compliment ...)

23:40 slyphon: has anyone written code-analysis tools for clojure, like to graph dependencies between namespaces?

23:40 hiredman: since maps, vectors, sets, keywords, and symbols are all callable as functions, maybe anything that returns on of those is a hof

23:41 http://www.thelastcitadel.com/images/clojure.png

23:41 somnium: recently Ive been wishing map would return (partial map f) when called with one arg (or even better a brand new fn that inlines f into the def of map)

23:42 slyphon: hiredman: yeah, like that

23:42 hiredman: http://github.com/hiredman/clojure-dependency-grapher

23:42 slyphon: hiredman: awesome :D

23:43 hiredman: feel free to fork and make better :P

23:43 slyphon: :)

23:44 hiredman: I would use the find-namespaces branch if you do make any improvements

23:44 I don't exactly recall the difference, but I think it's Better™

23:51 tela: Is there an idiomatic way to ensure an expensive computation only be done once even if multiple threads may near simultaneously request the result?

23:53 slyphon: use a monitor?

23:53 hiredman: sync or async?

23:53 async is a future, for sure

23:54 sync may be a promise or a delay

23:54 ~def delay

23:55 tela: hm, sync definitely. If the thread tries to force the promise/delay it'll just block until the computation completes, no?

23:55 Crowb4r: hiredman: did you have any trouble getting the pirc lib to work with clojrue

23:55 ?

23:56 hiredman: Crowb4r: nope

23:56 Crowb4r: k

23:56 hiredman: tela: right

23:56 Crowb4r: must be somethign with my code, thats good to know. probbably did something dumb.

23:56 hiredman: the delay might not block though

23:57 ~def c.l.Delay

23:58 tela: wait, hm. The computation is stochastic. I might be able to work it still but it'll take some more trickery ---

23:58 hiredman: looks like delay will work fine

23:59 Delay's deref is synchronized

23:59 tela: but it'll memoize the thunk in the future, right? I want to call it again later for a new stochastic result.

Logging service provided by n01se.net