#clojure log - Aug 02 2010

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

0:14 slyrus: ah... my old friend "error: java.lang.OutOfMemoryError: PermGen space (smiles.clj:311)"

0:23 cais2002: hi guys, when does the execution of the body of defmacro occur?

0:23 Scriptor: cais2002: during compile time

0:24 cais2002: -> (defmacro ++ [& exprs]

0:24 (if (>= 2 (count exprs))

0:24 `(+ ~@exprs)

0:24 `(+ ~@(first exprs) (++ ~@(rest exprs)))))

0:24 sexpbot: java.lang.Exception: EOF while reading

0:25 cais2002: at compile time exprs still has no value, right?

0:25 is this a valid macro definition?

0:25 Scriptor: cais2002: please paste code in a pastebin, like http://pastebin.com/

0:26 cais2002: scriptor: sorry, i thought it's short enough.. will do

0:27 Chousuke: cais2002: otherwise yes, but the ~@(first exprs) is wrong and the condition looks weird.

0:28 or hm

0:28 cais2002: scriptor: am I correct to say that I can not rely on any run time value of the parameters in macro def?

0:28 Chousuke: maybe I just misread it.

0:28 yes.

0:28 rather, you *can't* rely on runtime values of the parameters

0:28 Scriptor: cais2002: you can still rely on the count, I think, since it's still a list

0:29 but like Chousuke said, it should be ~(first exprs)

0:30 cais2002: can you guys elaborate on "rely", (count exprs) is a type of "rely" that's allowed, but (= (first exprs) 1) is not?

0:31 Chousuke: cais2002: exprs will most likely be a sequence of symbols and/or lists

0:31 cais2002: though IF they are literal numbers, then the latter works too

0:31 Scriptor: cais2002: remember, exprs is unevaluated

0:31 say you have (my-macro (+ 2 3))

0:32 s/my-macro/++

0:32 when exprs would be a list containing +, 2, and 3

0:32 Chousuke: actually not

0:32 cais2002: chousuke: but the actual value of (count exprs) varies depending on the run time value, isn't it?

0:32 Chousuke: it would be ((+ 2 3))

0:32 since there's no destructuring

0:32 cais2002: nope

0:33 Scriptor: Chousuke: ah, good point

0:33 Chousuke: cais2002: the macro expansion is done before runtime

0:33 cais2002: though I suppose macro expansion could be thought of as "runtime" too since the entire language is useable already.

0:35 cais2002: the value of (count exprs) depends on the number of parameters you pass to the macro, but the evaluated values (the ones a normal function would see) of those parameters don't matter.

0:37 as long as you remember you're dealing with unevaluated code in macros, you can do anything you want to the parameters though.

0:37 TakeV: Is there a way to define a struct that extends another struct?

0:38 Chousuke: you could write a C compiler macro if you wanted :P

0:38 just parse a string

0:38 and return a function

0:38 cais2002: chousuke: here is an example that confuses me http://pastebin.com/QUNBcPrY

0:39 Chousuke: cais2002: right. the parameter to testm in the first cases is a vector of numbers, so it works.

0:39 cais2002: but in the last case, it's just a symbol. you can't call first or rest on a symbol

0:40 cais2002: chousuke: so it's evaluated at run time, but using the unevaluated form of the parameters?

0:40 Chousuke: hmmh

0:41 a macro call is expanded at macro expansion time, and then the result of the macro call is the thing that's evaluated

0:41 so in your case, (+ 1 2 3) and (* 2 2 3) are the things that get evaluated at runtime

0:42 the (def a [1 2 3]) doesn't matter at all to the macro, you can remove it and the error you get would not change.

0:44 though IIRC if I remember clojure's evaluation model correctly, the macro could access a from itself since it's a previously defined global constant.

0:45 just not through the parameter. :P

0:45 I mean, the testm def would have to be after the def for that to work, too

0:46 wwmorgan: cais2002: the use case for most macros is syntax transformation. If you find that you need the parameter value, you probably just want a function

0:46 cais2002: wwmorgan: I figured so. but just want to make sure that I understand how it works

0:48 chousuke: at macro expansion time, are the parameters replaced with the actual values of the parameters verbatiam?

0:54 Chousuke: cais2002: what do you mean?

0:55 cais2002: the macro is given the parameters you call it with, unevaluated. Then the macro does its magic, returns some code, and that code is then either further macroexpanded or just evaluated

0:58 what the macro returns usually depends on the parameters you pass to the macro but that need not be the case.

0:58 eg. the comment macro that just returns nil :P

1:01 cais2002: chousuke: thanks, let me digest a bit

1:26 notsonerdysunny: http://github.com/relevance/labrepl/issues#issue/14

1:26 http://osdir.com/ml/clojure/2010-07/msg00977.html

1:26 I am a newbie to netbeans-enclojure-maven thing .. and I am trying to get labrepl working .. but have trouble ..

1:27 I see that other people have had similar problem for over a month ..

1:28 It seems like the problem is with the maven trying to track the latest-bleeding-edge clojure-contrib stuff.. I would like some help trying to resolve this...

1:28 It is probably some thing very simply if you knew maven

1:28 can anybody help me?

1:29 tomoj: notsonerdysunny: I don't understand

1:29 labrepl doesn't specify clojure-contrib 1.2.0-master-SNAPSHOT as a dependency

1:30 notsonerdysunny: well my latest labrepl from git-hub is doing that

1:31 tomoj: you're getting an error that says 1.2.0-master-SNAPSHOT isn't found? from netbeans?

1:31 notsonerdysunny: yes only for clojure-contrib

1:32 mister_m: does clojure have list comprehensions?

1:32 tomoj: oh, maybe one of labrepl's dependencies has 1.2.0-master-SNAPSHOT as a dependency

1:33 notsonerdysunny: http://pastebin.org/440415

1:34 shows the complete log of the netbeans-enclojure compile output

1:34 raek: mister_m: for

1:34 ,(for [x [1 2 3 4]] (inc x))

1:34 clojurebot: (2 3 4 5)

1:35 notsonerdysunny: even though it shows up as a warning only .. I get an error when I try to start the repl for the project

1:36 tomoj: what's the error then?

1:37 hmm "[WARNING] JAR will be empty - no content was marked for inclusion!" that's odd

1:38 well, I'm stumped, sorry, I've used neither labrepl nor netbeans

1:42 raek: S = {2x | x e N, x^2 > 3} --> (for [x (iterate inc 0) :when (> (* x x) 3)] (* 2 x))

1:42 notsonerdysunny: tomoj: http://dl.dropbox.com/u/7271654/labrepl-netbeans-enclojure-start-repl-error.png shows the screen-shot of the error-message

1:44 tomoj: ... are you working on clojure inside a windows VM on an ubuntu host?

1:44 notsonerdysunny: yea

1:45 tomoj: I think things are probably a lot more likely to work on ubuntu than on windows

1:45 (not that I think windows is causing your current problem)

1:46 notsonerdysunny: k let me give direct-ubuntu a shot ..

1:48 tomoj: I really have no idea whether your current problem is caused by windows (never used labrepl or netbeans..)

1:49 and since it's all java I guess it shouldn't make much of a difference?

1:49 raek: is this dependent on leiningen?

1:49 tomoj: looks like it's using mvn, not lein

1:49 raek: cause iirc, windows support for leiningen is still experimental

1:49 notsonerdysunny: yes it is using mvn

2:21 outside the topic ..

2:21 shouldn't freenode make all the irc-log available to the search engines..?

2:22 Scriptor: notsonerdysunny: freenode itself doesn't keep logs

2:22 they're kept by individual users

2:22 notsonerdysunny: oh ..

2:22 if it did it would be wonderfull!!

2:23 Scriptor: some channels have official logs though kept by some bot

2:24 for others, I think people like not having a permanent record of what they say, especially if it's just a conversational place

2:24 notsonerdysunny: probably #clojure should have one though .. :)

2:24 brehaut: like clojure-log.n01se.net/ ?

2:25 notsonerdysunny: oh neat there is one!

2:25 but can the searach-engines access this log?

2:26 Scriptor: yep

2:26 notsonerdysunny: may be we should mention the link where the log is available on the topic of clojure

2:28 i meant #clojure

3:05 cobol_expert: what's the best way to force a (map) to fully execute if all you care about is the side-effects?

3:06 tomoj: dorun

3:06 cobol_expert: (dorun (map ...)) ?

3:06 tomoj: but I usually like doseq better than (dorun (map ..))

3:07 yeah

3:07 cobol_expert: awesome, it took me forever to figure out why my code wasn't running (i.e. map is lazy)

3:08 unfo-: cobol_expert, had the same problem :)

3:08 latest commit to my clj project:

3:08 (map fn coll) is *LAZY* -- thanks #clojure @ freenode :-)

3:08 ;)

3:09 cobol_expert: haha

3:10 tomoj: ,(first (map println (range 100)))

3:10 clojurebot: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

3:10 tomoj: so.. just be careful :)

3:28 notsonerdysunny: If all I am interested in is Clojure .. should I try to learn Maven or leiningen

3:30 bobo_: notsonerdysunny: leinigen is simpler i belive. and fits more into clojure.

3:31 but maven is probably more usefull outside of clojure. or more used atleast.

3:31 brehaut: start with lein unless you already do a bunch of java stuff

3:32 bobo_: also, with maven, you an open the project without any fuss in netbeans/eclipse/idea. if you are gonna use one of thoose

3:44 notsonerdysunny: thanks bobo_ brehaut .. I am using netbeans .. I will start of with leiningen ..

3:45 brehaut: im using eclipse and bobo_ is right that maven would be more cleanly integrated

3:46 but id rather be learning clojure than tools

3:47 bobo_: indeed, you should use what you used before

3:48 i used netbeans for a while, and just used the plugin. no leinigen or maven. belive its ant based

3:48 worked fine

4:21 Bjering: What is the clojure syntax to do: new byte[] { 0 }

4:25 Fount it I think, this: (byte-array [(byte 0)]), right?

4:29 Fossi: that's at least a way to do it

4:33 Bjering: next question. how do I call a static java method that takes variable no of arguments?

4:34 Trying to call a static method with this signature: public static ChannelBuffer wrappedBuffer(byte[]... arrays)

4:35 Yet (ChannelBuffers/wrappedBuffer (.getBytes "Hello" "UTF-8") (byte-array [(byte 0)])) fails, with this: java.lang.IllegalArgumentException: No matching method found: wrappedBuffer

4:50 raek: I think java's variadic methods work a bit differently under the hood that one would suspect

4:50 Bjering: try doing (show TheClass) to check what the signature really looks like

4:51 (use 'clojure.contrib.repl-utils)

4:52 ^-- that's where show is

4:52 [18] format : Formatter (String,Object[])

4:52 that is what Formatter.format(String, Object...) looks like under the hood

4:53 sid3k: morning guys

5:03 callen-nyc: would anyone like to critique my code?

5:03 trivial, but I'd like to know if I'm violating any idioms.

5:04 esj: Good Morning Noble Colleagues

5:04 callen-nyc: esj: good morning. would you like to critique some trivial code?

5:05 esj: callen-nyc: i'm truly not qualified, but I'm happy to try help

5:05 callen-nyc: esj: you read Stuart's Clojure book?

5:05 esj: yup

5:05 callen-nyc: esj: is there a clojure pastebin?

5:06 esj: gist or pastebin

5:06 callen-nyc: should I just use lisp highlighting?

5:06 ah gist.

5:06 esj: you know the ellipsize he demonstrated in the book?

5:06 esj: yeah, that's fine

5:06 not offhand - point me in the direction, the book is right here

5:07 callen-nyc: it drove me nuts, here's my attempt at improving on it: http://gist.github.com/504370

5:07 the original generated ellipsized sentences with a space between the final word and the ellipsis, drove frakking crazy.

5:07 esj: hehe

5:08 callen-nyc: went through like 4 revisions as I was getting a feel for the different way of functioning, so to speak.

5:08 that's what I came up with.

5:08 you want to see stuart's version?

5:08 esj: hmmm.... first idea is that you could just (str (last words) "...") to get the non-spaced ellipse

5:09 and the str join " " blah blah as before ?

5:09 callen-nyc: I'm not sure the difference you're proposing

5:09 edit the gist?

5:10 esj: 1 sec... need to get a REPL up in front of me

5:11 callen-nyc: (ellip-2 "test1 test2 test3 test4 test5") returns "test1 test2 test3..."

5:11 esj: sorry... I misunderstood your intent

5:12 callen-nyc: esj: anything to improve on?

5:12 esj: I would say that code is good

5:12 callen-nyc: anyone care to squish my clojure neophyte ego?

5:12 Chousuke: it looks fine to me

5:12 callen-nyc: it's 3 lines :P

5:13 esj: callen-nyc: that's not how they do it here. No squishing.

5:13 brehaut: callen-nyc: its clear and it does what it needs to do right?

5:13 esj: yes

5:13 callen-nyc: brehaut: da.

5:13 brehaut: callen-nyc: no ego needs squishing then :)

5:13 callen-nyc: I'm calling it finito and proceeding then.

5:13 btw I would just like to state my undying love for leiningen and personal wish that it be replicated for all programming languages.

5:14 esj: if you're a real neophyte you might like to add an optional second argument that varies the number of words taken before placing the ellipse with a default of 3

5:14 but its pretty trivial

5:14 Chousuke: The only critique I can think of is that the "sentlist" name is weird :P

5:14 callen-nyc: Chousuke: pseudo-hungarian.

5:14 although it's technically not a list

5:15 the re-split returns some type I don't know the name of

5:15 but the literal is parens.

5:15 Chousuke: yeah but what's "sent"? :/

5:15 brehaut: what about words ?

5:15 callen-nyc: Chousuke: sentence

5:15 brehaut: string

5:15 brehaut: words is Mr. Stuart's nomenclature, not mine.

5:15 Chousuke: it doesn't return sentences though, does it?

5:15 brehaut: oh sorry, i missed that as an arg

5:15 callen-nyc: Chousuke: it returns strings again.

5:15 Chousuke: eventually.

5:16 after the (str)

5:16 Chousuke: I mean the splitting operation

5:16 callen-nyc: that's re-split which is...clojure.contrib.str-utils

5:16 Chousuke: but yeah, the function is so simple the name could be frob and it wouldn't matter much

5:17 yeah, and it'd return a list of words, not sentences, right? :)

5:17 callen-nyc: (defn re-split "Splits the string on instances of 'pattern'. Returns a sequence of strings. Optional 'limit' argument is the maximum number of splits. Like Perl's 'split'."

5:17 Chousuke: "sentence that is a list of words"

5:17 Chousuke: sentlist. technically a sequence

5:17 Chousuke: you have the words and sentence backwards there I think

5:17 callen-nyc: but I don't know the bloody difference.

5:18 Chousuke: the argument is a sentence, and splitting it produces a list of words

5:18 callen-nyc: word-seq would be less moonspeaky.

5:18 would you like it to be word-seq? :P

5:18 it is now word-seq

5:18 Chousuke: I think I would just change words -> string/sentence and sentlist -> words

5:19 callen-nyc: it matches the actual type, and expresses what each object returned on iteration is.

5:19 Lajla: Chousuke, menekaamme yhteen gaybariin.

5:19 Chousuke: no :P

5:19 brehaut: (defn ellip-2 [words] (str (->> words (re-split #"\s+") (take 3) (str-join " ")) "…"))

5:20 callen-nyc: oi vey finnish.

5:20 brehaut: remove the need to keep handlng the name when the ops make it clear

5:20 callen-nyc: brehaut: you made it points-free 'ish?

5:20 brehaut: yeah

5:20 callen-nyc: hoopy.

5:20 brehaut: i learn FP in haskell sorry

5:20 its not really point free

5:20 callen-nyc: brehaut: I know not technically

5:20 brehaut: that's why I said ish.

5:20 brehaut: cool

5:20 Lajla: mutta anna mun käyttää sun gaybariin, gaybariin gaybariin.

5:20 callen-nyc: brehaut: I fiddled with haskell before.

5:21 brehaut: i love haskell but it breaks my brain

5:21 Lajla: Loppukaamme gaybarilla, gaybarilla gaybarilla

5:21 callen-nyc: brehaut: haskell just isn't practical.

5:21 Lajla: brehaut, does clojure support continuation passing style?

5:21 brehaut: if clojure had an ML syntax it would a) probably not work as clojure any more and b) be totally amazing

5:21 callen-nyc: brehaut: handling IO and state composition is just cantankerous.

5:21 Lajla: brehaut, eeeewwwww

5:21 brehaut: Lajla: *somewhat*

5:21 Lajla: ML syntax

5:22 brehaut: there is a continuations monad for haskell

5:22 Lajla: brehaut, but I said cloure.

5:22 brehaut: but it runs into no tail call removal overflows

5:22 callen-nyc: brehaut: your version is gorgeous. please make me understand ->>

5:22 brehaut: trampoline?

5:22 brehaut: err sorry ment clojure

5:22 Lajla: brehaut, clojure has monads?

5:22 brehaut: Lajla:

5:22 yes

5:22 Chousuke: in contrib

5:22 callen-nyc: Lajla: anything with first class functions has monads.

5:22 brehaut: but they are often not idiomatic

5:23 callen-nyc: Lajla: ^^ caveat.

5:23 brehaut: javascript can have monads if you are mad enough

5:23 http://intensivesystems.net/tutorials/cont_m.html

5:23 callen-nyc: brehaut: I've used currying in js before. legitimately.

5:23 Lajla: Don't monads require a (static) type system?

5:23 Chousuke: I wrote my own monad implementation for clojure a while ago

5:23 Lajla: After all, it's just a type

5:23 Chousuke: it's just a toy though, like a couple dozen lines of code :P

5:23 brehaut: Lajla: yes and no

5:23 callen-nyc: Lajla: naw. it's just state expressed in function composition

5:23 brehaut: http://brehaut.net/blog/2010/monads_redux thats my opion of monads in clojure

5:23 Lajla: Chousuke, mikä on gaybar suomeksi?

5:23 callen-nyc: Lajla: the reification of monads in the type system in haskell is an idiom, not an absolute.

5:24 Lajla: callen-nyc, that's not really a 'monad' as in Haskell though

5:24 That's just 'a random way to use functions to express state'

5:24 brehaut: Lajla: conceptually it is and isnt

5:24 they obey the monadic laws

5:24 Chousuke: callen-nyc: I wouldn't say "state" has anything to do with monads intrinsically

5:24 * defn is so happy he /ignored Lajla

5:24 brehaut: there is conceptually a wrapper

5:24 Chousuke: callen-nyc: state is just one of the things that monads can be used to handle.

5:24 callen-nyc: Chousuke: it doesn't, I'm just speaking on how they're used

5:24 Lajla: Ahhh, obedience brings victory, and victor yis life.

5:24 defn, you can /

5:24 callen-nyc: Chousuke: this is #clojure not #lambda-calculus :P

5:24 Lajla: I love you

5:24 You can never ignore me

5:25 defn: awww, lambda calculus is fun!

5:25 callen-nyc: moving right along.

5:25 Lajla: defn, noooo

5:25 brehaut: callen-nyc: re what does ->> do, it stiches the first arg into as the last arg of the second form

5:25 Lajla: You cannot ignore me

5:25 I love you

5:25 callen-nyc: brehaut: explain ->> ?

5:25 Lajla: Like Chousuke loves child porn

5:25 brehaut: and does that recursively

5:25 callen-nyc: brehaut: or at least tell me the things bloody name.

5:25 Lajla: Like Bush loves oil

5:25 callen-nyc: Lajla: shush you.

5:25 Lajla: Like women love to be raped

5:25 Chousuke: Lajla: You really need to learn to shut up

5:25 brehaut: defn you have excellent ideas

5:26 callen-nyc: brehaut: if you tell me the name, I can google it.

5:26 brehaut: I cannot google ->>

5:26 Chousuke: Lajla: If you want to be weird, do that on -casual; don't be disruptive on this channel.

5:26 * callen-nyc pokes brehaut's shoulder

5:26 callen-nyc: wait a second.

5:26 t?

5:26 brehaut: callen-nyc: yeah but you can search for it on clojuredocs.org

5:26 clojurebot: callen-nyc: the fn created by future (like all fns) doesn't close over dynamicly scoped stuff

5:26 callen-nyc: brehaut: you make panda sad.

5:26 Sorry, couldn't find any results for your search of '->>'.

5:26 brehaut: http://clojuredocs.org/v/1660

5:26 callen-nyc: brehaut: liar.

5:27 brehaut: yeah sorry

5:27 i browse that sight by default

5:27 s/sight/site/

5:27 sexpbot: i browse that site by default

5:27 brehaut: ok thats just too cool

5:27 callen-nyc: AHA

5:27 brehaut: shanks.

5:27 brehaut: no worries

5:27 callen-nyc: looks like a unidirectional pipe.

5:27 Chousuke: the first example has the good old redundant #() error :P

5:27 callen-nyc: I'm sure that's a facile way of putting it.

5:27 brehaut: pretty much :)

5:27 Chousuke: or well, not an error but an anti-idiom

5:28 oh wait never mind, I misread it

5:28 brehaut: callen-nyc: in ML family it would be a pipe or similar

5:29 Lajla: I will never abide to your twisted sense of artificial order.

5:29 I bow to no man, not even to you.

5:29 Chousuke: Lajla: k. Then you get ignored.

5:29 brehaut: it also has a relative -> which stiches the args into the first position of the form

5:29 Lajla: Never shall I.

5:30 brehaut: you could do proper point free in clojure, but it gets bogged down in calls to partial comp and #( )

5:30 and all the overhead of being so incredibly explicit about it all defeats the purpose

5:31 sid3k: how can I add clojure-contrib directory to classpath? I'm not familiar with java stuff

5:31 callen-nyc: brehaut: yeah I did OCaml.

5:31 brehaut: sid3k: java -cp clojure-contrib.jar ?

5:31 callen-nyc: brehaut: btw, I think 2 lines is short enough for this :)

5:31 brehaut: callen-nyc: sure :)

5:31 sid3k: brehaut: it raises an exception

5:31 callen-nyc: no.

5:31 just have him use leiningen

5:32 one nubcake to another. just use lein.

5:32 brehaut: yeah that works too, its my prefered solution ;)

5:32 callen-nyc: brehaut: hypocrite >:P

5:32 brehaut: accidentally overly literal

5:32 sid3k: have you heard of leiningen ?

5:33 sid3k: what should I do put in that command instead of ? sign?

5:33 brehaut: oh you dont need the question mark

5:33 it was intended as just the beginning of your (soon to be monsterous) incantation

5:34 are you on linux, mac os x or another *nix?

5:34 callen-nyc: brehaut: I've named ->> The Winchester. It shoots things that way ->

5:34 sid3k: linux

5:34 defn: lol

5:34 brehaut: haha

5:34 defn: "The Winchester"

5:34 callen-nyc: damned skippy.

5:34 defn: I call -> Whistler's Mother

5:34 raek: to start a repl with contrib manually, you can do java -cp 'path/to/clojure.jar:oath/to/clojure-contrib.jar' clojure.main

5:34 sid3k: btw, what's the lein way?

5:34 callen-nyc: defn: lol.

5:34 sid3k: it's a shell script you put in your bash path.

5:34 raek: *path/to

5:34 brehaut: sid3k: github.com/technomancy/leiningen

5:35 defn: would -> be an inverted whistler's mother?

5:35 raek: but with lein, it's simpler

5:35 sid3k: raek: this is what I'm looking for, thanks

5:35 defn: I can't remember which way she's sitting

5:35 raek: lein new my-proj; cd my-proj; lein deps; lein repl

5:35 brehaut: sid3k: it handles project dependancies for you

5:35 callen-nyc: sid3k: you describe project dependencies/versions/libs in project.clj, run lein deps, it gets everything going locally, then lein repl to fiddle around.

5:35 sid3k: personally, I run swank-clojure -> emacs slime, but that's me.

5:36 brehaut: sid3k: related is http://github.com/liebke/cljr which is based on lein and provides the repl without needing to create a project

5:36 raek: between the cd and lein deps step, instert: "edit project.clj and specifiy dependencies (clojure and clojure contrib will be filled in by default)

5:36 callen-nyc: I am a laaaaazy bastard, so I loves me some slime.

5:36 sid3k: callen-nyc: me too?

5:36 brehaut: callen-nyc: no need to scare the new guy

5:36 callen-nyc: brehaut: I was using emacs when I was 10. :(

5:36 brehaut: callen-nyc: i used emacs for about 7 years and eventually just got sick of it

5:37 i hate futzing with my tools

5:37 callen-nyc: brehaut: I don't use it for everything.

5:37 brehaut: as do I.

5:37 I just grab the right tool for what I'm doing.

5:37 for workaday, I'm usually in gedit because I have to deal with a ridiculous number of files.

5:37 brehaut: for workaday im stuck in .net land so i have exactly one choice :(

5:37 sid3k: raek I'm using this line "alias clj=clj-env-dir" to start clojure

5:38 callen-nyc: brehaut: ooh. I left .NET 2 years ago.

5:38 brehaut: I'm in django-land now. :)

5:38 sid3k: as I understand I should change this line too

5:38 callen-nyc: brehaut: maybe F# will saves you?

5:38 brehaut: callen-nyc: i recall having this discussion the other night :)

5:38 callen-nyc: wait a tic.

5:38 brehaut: I'm terribly sleep deprived, pardon me.

5:38 brehaut: callen-nyc: only one problem, my coworkers dont understand it

5:38 no problem

5:38 sid3k: callen-nyc: try tornado, its much better and pythonic

5:38 callen-nyc: brehaut: fuck them, do all the work yourself with F#

5:39 sid3k: uh, that's not how working for a company works.

5:39 sid3k: they have shit. they want shit changed. you change shit as described. you don't re-implement the whole backend on a whim.

5:39 sid3k: it's a backend web service, not a high traffic frontend that needs to be evented.

5:39 sid3k: callen-nyc: in my previous job, I used django for just administration panel, it's the only thing django does well

5:39 callen-nyc: sid3k: don't make lib recommendations to people when you don't have a clue what they're working on.

5:39 sid3k: we don't even use the ORM, the database is couchdb. :P

5:40 brehaut: man, i totally love couch now

5:40 callen-nyc: it's actually one of the largest clusters of couch that are publicly known.

5:40 brehaut: im still getting my head around writing the views

5:40 callen-nyc: brehaut: s'okay. it's not great when you need up to the minute stats for the frontend though.

5:40 sid3k: brehaut: btw, what should I do with lein ue what they're working on. [05:40]

5:40 <callen-nyc> sid3k: we don't even use the ORM, the database is couchdb. :P

5:40 ERC>

5:40 fuck, sorry

5:40 callen-nyc: brehaut: it's great for map-reduce + views

5:40 sid3k: stop while you're ahead mate :)

5:41 brehaut: and general ability to do processing during high-writes

5:41 raek: sid3k: in my experience, when your code needs a jar from somewhere else, you'll want to use a project management tool lile leiningen

5:41 callen-nyc: brehaut: but not so great for recent reads.

5:41 raek: ie, everything.

5:41 raek: yes, eventually...

5:41 sid3k: all right, what should I do with lein? which command I need to type?

5:41 brehaut: callen-nyc: im replacing my creeking python+django site with clojure+couch+the cgrand stack

5:41 callen-nyc: sid3k: read the readme/tutorial

5:41 raek: first, do you have the lein script?

5:41 callen-nyc: sid3k: it goes over the basic project pattern.

5:42 sid3k: yeah

5:42 I used lein before for the swank things

5:42 raek: or, first first, do you develop under windows?

5:42 callen-nyc: brehaut: personal sites are good for experimentation like that.

5:42 raek: ok

5:42 brehaut: callen-nyc: absolutely

5:42 sid3k: nope, linux

5:42 brehaut: bbs

5:42 getting dinner cooking

5:42 callen-nyc: brehaut: that said, be aware that couchdb is terrible for ajax stuff that needs to be up to the minute.

5:42 raek: create a new project somewhere by running "lein new <project name>"

5:43 sid3k: all right

5:43 raek: that will create a directory with a project.clj file, and some subdirectories for tge source, etc

5:43 LauJensen: raek: only true, if <project name> is something technomancy approves of

5:43 sid3k: raek: created

5:43 raek: edit the project.clj file and add any dependencies you like

5:43 or change the versions of clojure and contrib

5:43 sid3k: like?

5:44 project.clj contains this line: "org.clojure/clojure-contrib "1.2.0-beta1""

5:44 raek: you could add swank-clojrue: :dev-dependencies [[swank-clojure "1.2.1"]]

5:44 that version is fine

5:44 brehaut: callen-nyc: cheers for the heads up :) up to the minute is not what my blog is about :)

5:44 raek: I think there is a RC1 version now

5:45 brehaut: raek: you are correct

5:45 raek: after you're done with that, run lein deps, standing in the project directory

5:45 sid3k: raek: I've added that

5:45 callen-nyc: brehaut: I know, just letting you know how the battle-lines is

5:46 raek: after that, just run "lein repl" or "lein swank"

5:46 callen-nyc: brehaut: up-to-the-minute type stuff is more mongo // cassie

5:46 brehaut: we might be deploying a cassandra cluster for that very reason soon, since nobody at my company seems to trust mongodb, hahaha.

5:46 sid3k: raek: completed and put Copying 3 files to /tmp/test/lib

5:47 raek: lein repl, will start a repl with those 3 jar file and the src/ directory on the class path,

5:47 sid3k: which command displays classpath in repl?

5:48 callen-nyc: that's an excellent question.

5:48 brehaut: http://clojuredocs.org/leiningen/leiningen.classpath

5:49 raek: (println (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader))))

5:50 callen-nyc: I need to stop eating raw hamburger.

5:50 brehaut: there is also clojure.contrib.classpath

5:50 raek: I hope this will get you started

5:50 if you need another lib, just add it to the project.clj and restart the repl

5:50 callen-nyc: raek: ahem. lein deps first.

5:51 project.clj -> lein deps -> lein repl

5:51 sid3k: tyvm for help, but I get the problem now, finally

5:52 my cli repl already has clojure-contrib directory in its classpath

5:52 problem is in my slime backend actually

5:53 I guess now I can fix it, thank you

5:55 callen-nyc: I'm hard at work on the internet popularizing the use of "The Winchester" for ->>

5:55 defn: callen-nyc: hahaha

5:56 callen-nyc: please try to throw in "whistler's mother" for ->

5:56 callen-nyc: defn: what's the reference for that? Blade?

5:56 defn: it's a famous painting

5:56 callen-nyc: ohhhh

5:56 the painting.

5:56 defn: it's sort of wrong because i think whistler's mother is more like <_

5:56 <-

5:56 callen-nyc: defn: because it roughly matches how she's sitting?

5:56 defn: but the thing is, it's so lonely

5:56 just like whistler's mother

5:56 callen-nyc: defn: so do you want -> to be whistler's mother?

5:57 defn: yes i do

5:57 i want it with every aching beat of my heart

5:57 :D

5:57 callen-nyc: defn: tweeting nao.

5:57 defn: I'll start pestering people on /r/clojure about it too.

5:57 defn: haha that's awesome

5:57 thanks callen!

5:58 callen-nyc: defn: I'm aiming the tweet at Hickey

5:58 it's in the ether.

5:58 defn: people arent going to go for whistler's mother on the -> i dont think

5:58 but they're wrong i tell you

5:58 callen-nyc: defn: I'm just going to hover over discussions of clojure (I have a yahoo pipe that feeds me EVERYTHING) and correct everyone.

5:59 defn: the more people discuss ->, the more likely it'll spread.

5:59 brehaut: i'd rather not bite your app thanks very much :P

5:59 callen-nyc: my cat agrees. our nomenclature is superior.

5:59 brehaut: way to watch twitter.

5:59 brehaut: thats right

5:59 defn: ive discussed this at length with my cat as well

6:00 callen-nyc: my cat has epic whiskers

6:00 defn: great minds, as they say...

6:00 callen-nyc: she looks like a double-barreled winchester.

6:00 esj: Whisters Mother - lol

6:00 callen-nyc: defn: even furry minds.

6:01 defn: i have an idea

6:01 maybe -> is iwogima

6:01 callen-nyc: HAHAHAHA

6:01 no that's

6:01 o\

6:01 defn: hahaha

6:01 callen-nyc: defn: get hickey to let us fuck the reader with macros so we can make o\ Iwo Jima

6:02 defn: I like The Winchester because it describes what the macro does as well as what it looks like.

6:02 brehaut: i just hope nobody ever makes a nighthawks operator

6:02 cause that would be a nightmare to type

6:02 defn: a nighthawk's at the diner operator

6:02 a la Tom Waits

6:03 callen-nyc: :(

6:03 sid3k: arright, fixed finally

6:03 callen-nyc: my kitty just banged her knee :(

6:04 defn: -> is washington crossing the delaware

6:04 sexpbot: java.lang.Exception: Unable to resolve symbol: is in this context

6:04 callen-nyc: defn: no changing mind allowed.

6:04 defn: damn

6:04 callen-nyc: sexpbot: yo symbol don't exist yo.

6:05 sexpbot: bad ns, bad def, bad defn, w/e

6:05 defn: i just got everyone in the office to give me famous paintings of characters facing east or to the right

6:05 callen-nyc: defn: lmfao.

6:08 defn: callen-nyc: so yes, whistler's mum and the winchester

6:08 which reminds me of a cartoon i saw, looney toons from many years ago

6:08 callen-nyc: defn: righto.

6:08 defn: wherein whistler's mother pulled a winchester out from under her skirt

6:08 (-> (->> ...))

6:08 callen-nyc: defn: seriously? that makes it even better.

6:10 LauJensen: Has anybody here got an idea about how to use Rings session middleware? Just decorating a handler only passes around an empty {}

6:10 brehaut: LauJensen: i've only used it via moustache

6:10 callen-nyc: defn: who's thickey? Rich's long lost evil twin?

6:10 LauJensen: brehaut: got a snippet+

6:11 brehaut: i'll make a gist or something

6:11 LauJensen: cool, thanks

6:11 If you have gist.el, just mark the region and hit M-x gist-region

6:12 brehaut: i dont use emacs sorry

6:12 LauJensen: np - there's a webinterface for it then

6:12 brehaut: yup

6:12 its rough and ready http://gist.github.com/504433

6:13 defn: callen-nyc: thickey is tom hickey

6:13 i believe his brother, pretty sure he did the clojure site

6:14 brehaut: LauJensen: sorry about the dreadful code, i'm only a n00b

6:14 callen-nyc: defn: fascinating. programmer or designer?

6:14 defn: callen-nyc: http://1.bp.blogspot.com/_4OYGjUrdllo/STNrCcmik_I/AAAAAAAAMyw/thuhBLYwhN0/s400/whistler.jpg

6:14 callen-nyc: dont really know

6:14 callen-nyc: defn: hahahahaha

6:14 thickey_: what are you?

6:15 thickey_: and don't answer human. we knew that.

6:15 esj: callen-nyc: its Tom Hickey, as defn says

6:15 LauJensen: brehaut: the code looks alright, but Im not seeing any calls to session?

6:15 callen-nyc: esj: what not who

6:15 brehaut: oh sorry the session one in particular?

6:15 LauJensen: Yea its the session middleware which isnt behaving, everything else works alright

6:15 brehaut: ah right. sorry its late here and im getting a little daft

6:15 LauJensen: brehaut: my entire site (bestinclass.dk) is run using only enlive/moustache

6:15 hehe, np

6:15 brehaut: LauJensen: yup, ive read it

6:16 callen-nyc: LauJensen: that's you? nice.

6:16 LauJensen: yea

6:18 brehaut: LauJensen: you editors for clojure article was invaluable when i got sick of textmates support

6:19 * callen-nyc hisses and spits at the unbeliever brehaut

6:19 LauJensen: brehaut: my editors?

6:19 oh that one

6:19 Now I remember - Glad you liked it :)

6:20 callen-nyc: LauJensen: you used the term "IDEs"

6:22 LauJensen: yea

6:22 callen-nyc: LauJensen: ooooh. you baked the site.

6:22 LauJensen: I need dynamic eval demos :P

6:24 LauJensen: Yea its nice and baked. Next step is to make some fancy browsing for the content that is already there

6:25 brehaut: LauJensen: do you do all the form processing yourself or is the a lib worth investigation?

6:26 LauJensen: I did it all myself, and its all on Github

6:26 brehaut: sweet, i'll go have a read

6:26 LauJensen: Somebody submitted a much better way to handle comment/captchas in the comments on that baking article though, cool macro

6:26 callen-nyc: LauJensen: ...baked comments?

6:27 hao?

6:27 LauJensen: naah, just dynamic captchas which produce lisp statements

6:27 But yea, actually the comments are baked in a way

6:27 callen-nyc: ....eeeeeek

6:27 you're dynamically producing code based on user input?

6:28 LauJensen: nope - but it was suggested, and it was good - I just didnt take the time

6:28 callen-nyc: that sounds ridiculously dangerous to me.

6:28 LauJensen: its not

6:28 oh wait sorry

6:29 I misread. The macro spits out a statement like (+ 15 (* 2 (/ 4 2))), and you supply the answer in the captcha

6:29 So its completely safe, and its not based on user-input

6:29 callen-nyc: oh.

6:29 I misunderstood.

6:29 LauJensen: Right now my Captchas are hardcoded

6:30 brehaut: LauJensen: am i correct in my reading of the code that its flat file backed and uses a ref to hold the model in memory?

6:30 callen-nyc: LauJensen: how are the comments stored and rendered?

6:30 LauJensen: what web server are you using to serve your static content?

6:30 LauJensen: sec, phone

6:31 opqdonut: what's a nice way of "calling" another clojure script

6:31 (use 'name.space) seems a bit ugly

6:32 callen-nyc: opqdonut: is it even possible to make it shorter than that?

6:32 opqdonut: load is okay but it wants a path. I'd rather use the name of the namespace

6:32 brehaut: opqdonut: require ?

6:32 opqdonut: require sounds better

6:32 brehaut: i'll load the other file and not polute the current namespace

6:32 opqdonut: use looks too much like an import

6:32 yes

6:33 callen-nyc: opqdonut: my cat agrees, use require.

6:35 defn: callen-nyc: my cat says meow

6:36 callen-nyc: defn: my cat sits in my lap when I code.

6:36 defn: she likes watching my hands, especially when I'm ^ X ^ E'ing.

6:36 she's sitting in my lap right now, but kinda sleepy.

6:36 I've been coding all night, it's 6:36am

6:37 sid3k: callen-nyc: freelancer?

6:37 defn: She's all like "WUT THIS HOTKEY DO?"

6:37 sid3k: or remote conractted?

6:37 callen-nyc: sid3k: contractor, but it was a sunday night, I was coding for pleasure.

6:37 defn: she sits her butt on my keyboard occasionally.

6:37 sid3k: remote contractor, da.

6:37 sid3k: programming is the best hobbie I've know

6:37 callen-nyc: sid3k: picking up a laptop in a couple hours, then working until 8 pm

6:38 and then, passing out more than likely.

6:38 that or hacking moar.

6:38 depends on how whiny the cat gets // wants attention.

6:38 defn: :3 is now the 'kitty key'

6:39 LauJensen: callen-nyc: comments are stored directly in the html, thats the whole point of baking. NGINX is serving statics

6:39 callen-nyc: LauJensen: should've been more than 250% faster unless you have the PHP rig super-cached to hell.

6:40 LauJensen: what processes the comments mate? it has to be dynamic at some point.

6:40 LauJensen: brehaut: comments are held in a memory queue and flushed once in a while to a flat-file, to avoid a race condition on the fs

6:40 callen-nyc: Jetty/Moustache

6:40 brehaut: LauJensen: ah right, nice

6:40 LauJensen: callen-nyc: I think it performs better under higher load, didn't press it

6:40 callen-nyc: LauJensen: was the PHP setup heavily tuned/cached?

6:40 LauJensen: callen-nyc: yea

6:41 callen-nyc: LauJensen: that explains it. regardless if you hammer nginx with high concurrency load it's going to vastly outperform.

6:41 LauJensen: baking might be a better idea for any website that is mostly content.

6:42 LauJensen: one potential idea, to solve race conditions, queue changesets/transactions, feed them into map-reduce on a database, dump from database into flat files

6:42 LauJensen: callen-nyc: Yea, when it dawned on me that both the html presentation and sql data, were both the very same thing, I couldnt resist fusing them. With Enlive you can browse an html file as easily as an sql database

6:42 callen-nyc: LauJensen: that'll solve your reader/writer problem.

6:42 LauJensen: virtually any map-reduce capable database would work.

6:42 LauJensen: callen-nyc: all race conditions are ironed out and dont need databases. The trick is to boil the I/O down to calls to 'mv' which is atomic

6:42 * callen-nyc twitches

6:42 LauJensen: I would really hate to have to get a database back into play

6:43 callen-nyc: LauJensen: the point is that the database is arbitrating change resolution and allowing unblocked reads (async differential dumps to statics) while writes are incoming.

6:43 LauJensen: callen-nyc: this is no different

6:43 you have your data in file1, then you write the next version in file2, then call 'mv file2 file1', which is atomic. Nothing blocks

6:43 callen-nyc: it's quite different, you're using mv wrapped in atomicity as a database.

6:44 brehaut: callen-nyc: http://github.com/LauJensen/bestinclass.dk/blob/master/src/bestinclass/comments.clj

6:44 LauJensen: mv is atomic, Im not wrapping :)

6:44 And yes, the fs is my database, thats the whole point of baking

6:44 callen-nyc: LauJensen: call me paranoid, but it's not something I'd ever do.

6:45 LauJensen: baking sure.

6:45 LauJensen: arbitrating changes via fs. no.

6:45 not for anything even slightly important.

6:45 LauJensen: Is your attitude based on anything rational?

6:46 (not meant sarcastically)

6:46 brehaut: LauJensen: the only down side i can see with your code is the unlikely even that the who JVM dies and you loose 1 minute of comments?

6:46 callen-nyc: LauJensen: personal experience with hacky things I've seen before, so, anecdote, and knowledge of how VMs work such that the notion of streaming writes into anything but something like a database makes me cringe.

6:46 LauJensen: brehaut: thats right, there is no durability guaratees for in-memory storage

6:46 callen-nyc: LauJensen: frankly, I take reliability pretty seriously and if I lost data I'd be really mad.

6:46 xkb: hi all

6:46 callen-nyc: (not (.contains url ".."))) <--- nice protection :P

6:46 LauJensen: callen-nyc: Ive never lost data - This is not less secure than a database.

6:47 callen-nyc: hehe :)

6:47 callen-nyc: LauJensen: what do you usually work in?

6:47 xkb: What would be the most idiomatic way to retrieve JSON from a web-server?

6:47 callen-nyc: xkb: ask nicely.

6:47 LauJensen: callen-nyc: You mean clothes-wise? :)

6:47 xkb: I'm using readers now :)

6:47 callen-nyc: LauJensen: field, specialty, ken.

6:47 LauJensen: callen-nyc: Best In Class is my consultancy company, specializing in Clojure

6:47 callen-nyc: LauJensen: so webapps?

6:47 LauJensen: Among other things

6:48 callen-nyc: LauJensen: I appreciate that the cavalier infrastructure you're using for your blog/whatever site is working fine

6:49 LauJensen: but please, for the sake of your clients, do not inflict a "filesystem as database" webapp on any of them.

6:49 LauJensen: callen-nyc: My clients usually respond best to rational arguments, based on performance, maintenance cost, development time etc, sometimes fs as db is the best, often its not

6:50 callen-nyc: LauJensen: I've done a lot of data (base) wrangling in the past, and I've dealt with hacky setups that just wrote to the fs as a means of persistence, and it was a horror.

6:50 LauJensen: it's simply irresponsible.

6:50 LauJensen: regardless of what you think is logical.

6:50 LauJensen: callen-nyc: I dont see how - You're afraid the fs will be corrupted? What do you think happens to a db situated on a corrupted fs?

6:50 callen-nyc: you're missing the point by a mile.

6:51 LauJensen: repeat it please

6:51 callen-nyc: you aren't grokking the myriad directions data loss can come from

6:51 no.

6:51 you're an axe to grind.

6:51 you've got your personal roof to thatch and I'm not going to go on a crusade for sake of people whom I'm not responsible for.

6:51 LauJensen: hehe

6:51 callen-nyc: if you won't listen, it's not my angry clients.

6:51 LauJensen: I don't find this amusing at all.

6:52 LauJensen: callen-nyc: I find it very funny. Im asking you to state your case, and you reply by calling me an axe and saying I wont listen :)

6:52 callen-nyc: LauJensen: I've had total data loss with 3 synced copies of data before.

6:52 LauJensen: comprende? I've seen the "worst case scenario" before

6:52 LauJensen: wow, and you're calling me irresponsible? :D

6:52 callen-nyc: LauJensen: shut the fuck up

6:52 LauJensen: haha

6:52 callen-nyc: LauJensen: it wasn't my setup, I inherited it

6:52 LauJensen: Come on - That was funny

6:52 callen-nyc: LauJensen: I had to do data recovery

6:52 LauJensen: I don't find this funny at all, get serious or stop talking to me.

6:52 LauJensen: it was a horrifying week.

6:53 LauJensen: I had three hard drives of different makes and ages die at the same time, on two different computers.

6:53 LauJensen: that's absurdly improbable, more so than the kinds of odds you're playing with a fs-as-database

6:53 LauJensen: it's a stupid design for data you even slightly care about.

6:54 I refuse to even deploy mongodb for a client with 3 machines plus a back-replication.

6:54 LauJensen: Im just not seeing where leaving out the actual database is elevating the risks? If I rsync the /bestinclass/ folder to 3 different systems - how is a database more safe?

6:54 callen-nyc: without

6:54 LauJensen: your know-nothingness is not my problem. I'm done chasing the troll.

6:54 LauJensen: If anything, the database adds its own concerns

6:54 callen-nyc: back to coooode.

7:38 Bjering: I left for a long lunch-meeting, but now back and perhaps I missed a solution to my problem. Sadly it remains her on my end, how to I call a java method with this signature? public static ChannelBuffer wrappedBuffer(byte[]... arrays)

7:38 (to-array '((byte-array [(byte 0)]) (byte-array [(byte 0)]))

7:38 )

7:39 gives me Object[], and it needs byte[][]

7:40 Chousuke: Bjering: first of all, you don't want to quote the list like that; you'll get an array that contains a list

7:41 Bjering: you want (to-array [(byte-array [0]) (byte-array [0])]) or something

7:42 (there's no need to convert the 0s to bytes, literal vectors can't contain them anyway)

7:42 esj: would into-array be better as it figures out the type ?

7:43 Chousuke: multidimensional arrays are horrible to use from clojure ;/

7:43 I think mostly because multidimensional arrays are horrible, and java just tries to hide that from you

7:43 esj: good point indeed

7:44 too bad the mathmeticians are so into them :)

7:44 callen-nyc: Chousuke: alternatives to multi-d arrays?

7:44 Bjering: (to-array [(byte-array [0]) (byte-array [0])]) throws ClassCastException

7:44 callen-nyc: Chousuke: clever key names? :P

7:44 Chousuke: what byte[][] actually is in java IS a Object[]

7:44 and the Objects are byte[]s :P

7:44 esj: aaah

7:45 Bjering: Chousuke, what I really want todo is call the vararg method listed above, google let me thing to-array was the way todo it with clojure.

7:45 Chousuke: hmm

7:45 (doc to-array)

7:45 clojurebot: "([coll]); Returns an array of Objects containing the contents of coll, which can be any Collection. Maps to java.util.Collection.toArray()."

7:45 Chousuke: okay so that one is not the problem

7:45 (doc byte-array)

7:45 clojurebot: "([size-or-seq] [size init-val-or-seq]); Creates an array of bytes"

7:46 esj: ,(doc into-array)

7:46 clojurebot: "([aseq] [type aseq]); Returns an array with components set to the values in aseq. The array's component type is type if provided, or the type of the first value in aseq if present, or Object. All values in aseq must be compatible with the component type. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE."

7:46 esj: i've successfully used this for Java varargs functions

7:46 Chousuke: to-array should work just as well

7:47 esj: ok

7:47 Chousuke: and I can't see why byte-array doesn't

7:48 Bjering: ,(to-array [(byte-array [(byte 0)]) (byte-array [(byte 0)])])

7:48 clojurebot: #<Object[] [Ljava.lang.Object;@fc990c>

7:48 Chousuke: that looks correct.

7:48 Bjering: ,(to-array [(byte-array [0]) (byte-array [0])])

7:48 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Byte

7:48 Chousuke: hm.

7:48 oh, right, duh

7:48 callen-nyc: static typing system biting you in the balls.

7:48 why in good ole' C, it'd just let you shoot yer arm off :P

7:49 Chousuke: the casting decides which object it gets boxed at.

7:49 as

7:49 Bjering: now the real problem is it doesnt match this Object[] to the right overload (the byte[]... vararg one)

7:49 Chousuke: you might want to call (byte-array 1 0) instead so you can avoid the casting and vectors :P

7:50 Bjering: so it has multiple varargs overloads? :/

7:50 Bjering: yes

7:50 Chousuke: are there any other parameters?

7:50 Bjering: in some of th overloads yes, not in this one.

7:51 Chousuke: I have no idea how to typehint that :P

7:52 ,(class (byte-array 1 0))

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

7:52 callen-nyc: and just a reminder to everyone why you're here instead of #haskell: http://www.haskell.org/haskellwiki/Zygohistomorphic_prepromorphisms

7:52 Chousuke: ,(class (byte-array 1 [0]))

7:52 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Byte

7:52 Chousuke: ,(class (byte-array [(byte 0)]))

7:52 clojurebot: [B

7:54 Bjering: Chousuke: Here is the API I am trying to use, if it helps to know what overloads wrappedBuffer has: http://docs.jboss.org/netty/3.1/api/org/jboss/netty/buffer/class-use/ChannelBuffer.html

7:56 defn: callen-nyc: still awake?

7:56 esj: ,(class (into-array (byte-array [(byte 0)])))

7:56 clojurebot: [Ljava.lang.Byte;

7:56 Chousuke: hmm"

7:57 ,(Class/forName "[[B")

7:57 clojurebot: [[B

7:57 Chousuke: so it looks like byte[][] is a special class after all

7:58 ,(into-array (Class/ForName "[[B") [(byte-array [(byte 0)]])

7:58 looks like clojurebot got bored of arrays :P

7:59 ,(into-array (Class/forName "[[B") [(byte-array [(byte 0)]])

7:59 clojurebot: Unmatched delimiter: ]

7:59 Chousuke: ,(into-array (Class/forName "[[B") [(byte-array [(byte 0)])])

7:59 clojurebot: Unmatched delimiter: ]

7:59 java.lang.IllegalArgumentException: array element type mismatch

8:00 Chousuke: argh

8:01 (doc make-array)

8:01 clojurebot: "([type len] [type dim & more-dims]); Creates and returns an array of instances of the specified class of the specified dimension(s). Note that a class object is required. Class objects can be obtained by using their imported or fully-qualified name. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE."

8:02 Chousuke: I think that's your function

8:02 then you just need to populate it manually

8:02 Bjering: into-array works :)

8:03 Chousuke: fortunately java arrays are mostly an interop problem ;/

8:04 Bjering: yes, its not code I'll write often, but appearantly I need it sometimes.

8:04 my finished function: https://gist.github.com/7c931dbedfb6eb488131

8:10 Chousuke: Bjering: I suggest using the sugared interop syntax instead of .

8:11 ie. (ChannelBuffers/wrappedBuffer ...)

8:12 Bjering: yes, nicer

8:12 Chousuke: Using . should be reserved for code generated by macros.

8:15 esj: I got one ?

8:15 * esj jumps up and down

8:16 noidi: ,(= (double (float 0.123)) 0.123)

8:16 clojurebot: false

8:16 noidi: ,(type 0.123)

8:16 clojurebot: java.lang.Double

8:16 noidi: what's up with that?

8:17 ah, rounding errors

8:17 ,(double (float 0.123))

8:17 clojurebot: 0.12300000339746475

8:17 noidi: man, I hate floating point :P

8:18 ,(float 0.123)

8:18 clojurebot: 0.123

8:18 esj: (- (float 0.123) (double 0.123))

8:18 ,(- (float 0.123) (double 0.123))

8:18 clojurebot: 3.3974647539736225E-9

8:18 esj: so annoying

8:19 noidi: I didn't expect any error to be introduced when moving to a larger type (float -> double)

8:22 raek: floating point numbers are inherently inexact; (non-approximative) equality does not make much sense for them

8:23 ,(+ 1.0 10000000000000000000000000.0 -10000000000000000000000000.0)

8:23 clojurebot: 0.0

8:24 esj: hahahah

8:29 xkb: If I want to use butlast from contrib, what should I require?

8:29 I keep getting errors

8:29 classpath wise

8:30 LauJensen: xkb: the butlast in core isnt good enough?

8:31 noidi: raek, in my case it sort of does, I serialize and deserialize floats so in my tests I want to check that they're read back correctly

8:31 xkb: hmm might also work

8:31 LauJensen: let me try

8:31 LauJensen: if not, you only need the contrib.jar file on your classpath, and then require the lib containing the fn, in this case its seq-utils IIRC

8:31 defn: is this a good example of val?

8:31 ,(map val {:a 1 :b 2})

8:31 clojurebot: (1 2)

8:31 defn: or am i missing something more idiomatic?

8:32 Chousuke: that's good I think

8:32 LauJensen: defn: looks fine to me

8:32 defn: cool, thanks

8:32 LauJensen: IIRC it only works with MapEntries

8:32 defn: im trying to fill up clojuredocs :)

8:34 could someone explain force to me?

8:34 hircus: LauJensen: works for a map-style vector too -- (map val (into [] {:a 1 :b 2}))

8:34 ,(map val (into [] {:a 1 :b 2})

8:34 clojurebot: EOF while reading

8:34 defn: hircus: good example

8:34 may i use it?

8:34 hircus: ,(map val (into [] {:a :b 2}))

8:34 clojurebot: 3

8:34 LauJensen: ,(map class (into [] {:a 1 :b 2}))

8:34 clojurebot: (clojure.lang.MapEntry clojure.lang.MapEntry)

8:35 LauJensen: hircus: Its the same thing, element wise

8:35 hircus: ah

8:35 defn: ah, yeah, good point, i dont want to extrapolate on every example by providing an into i dont think

8:35 Chousuke: hmm

8:35 defn: will just get bloated that way

8:35 Chousuke: ,(val [1 2])

8:35 clojurebot: java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.util.Map$Entry

8:35 hircus: defn: certainly. code snippets are too silly to claim copyright on :)

8:35 defn: hircus: it's polite to ask :)

8:35 hircus: you're welcome

8:35 defn: it's idiomatic in this community to ask i should say

8:35 :)

8:37 xkb: Aha, the butlast in core does something else as I wanted to

8:37 but last in str does (butlast 3 "sander") => "san"

8:38 as in all but last #

8:42 n2n3: ,(eval)

8:42 clojurebot: DENIED

8:42 n2n3: ,(eval 'hello)

8:42 clojurebot: DENIED

8:43 hircus: n2n3: eval is dangerous :)

8:43 defn: ,(read (eval 'hello))

8:43 clojurebot: DENIED

8:45 LauJensen: Chousuke: Did you work out why your call to val failed ?

8:46 raek: noidi: you might want to check whether the difference between the original value and the read value is under a certain value (or the percentage of their mean value)

8:47 certain float values don't have exact decimal represenations and vice versa

8:47 Chousuke: LauJensen: in the vector case? I suppose two-element vectors aren't map entries :P

8:48 LauJensen: Chousuke: (into [] {:a 5 :b 10}) => [[:a 5] [:b 10]], sending that to map val work. Manually calling (map val [[:a 5] [:b 10]]) fails like yours did, although the class is the same.

8:48 Chousuke: LauJensen: it's not.

8:48 LauJensen: map entries print as vectors, but vectors aren't map entries.

8:48 raek: ,(class (first (seq {:a 1}))

8:48 defn: how do i properly use the :validator option on a ref?

8:48 clojurebot: EOF while reading

8:48 raek: ,(class (first (seq {:a 1})))

8:48 clojurebot: clojure.lang.MapEntry

8:49 LauJensen: ,(class (into [] {:a 5 :b 10}))

8:49 clojurebot: clojure.lang.PersistentVector

8:49 LauJensen: ,(class [[:a 5] [:b 10]])

8:49 clojurebot: clojure.lang.PersistentVector

8:49 LauJensen: ,(into [] {:a 5 :b 10})

8:49 clojurebot: [[:a 5] [:b 10]]

8:49 Chousuke: LauJensen: you're not calling val on the vector, but its contents

8:49 raek: but conj accepts both MapEntries and vectors?

8:49 Chousuke: LauJensen: which are map entries

8:49 LauJensen: Ah right - Good morning all :9

8:50 Chousuke: raek: mapentries immplement the vector interface

8:50 hircus: ,(class (first [[:a 5] [:b 10]]))

8:50 clojurebot: clojure.lang.PersistentVector

8:50 raek: *(conj a-map a-vector/a-map-entry)

8:50 Chousuke: defn: isn't it a function of the value that the ref would hold?

8:50 defn: Chousuke: hrm...

8:50 hircus: Chousuke: so (into [] a-map) basically is a no-op, just return a pointer that's tagged as a vector?

8:51 defn: Chousuke: what does it look like though?

8:51 Chousuke: hircus: no

8:51 hircus: the map can only be converted into a seq of map entries, not directly into a vector of map entries

8:51 raek: ,(into [] {:a 1, :b 2})

8:51 clojurebot: [[:a 1] [:b 2]]

8:51 defn: do you refer with :validator (...) somehow to the value of the ref? does it apply to the in-trans. value?

8:51 Chousuke: hircus: into transforms that seq into a vector

8:52 raek: return a vector of MapEntries

8:52 defn: is :validator like a :pre or :post?

8:52 hircus: *ah* ok

8:52 Chousuke: defn: only the value that would be committed

8:52 defn: and it's a function, it needs to take a parameter

8:53 defn: Chousuke: so (def myref (ref [] :validator (< 4 %))???

8:53 hircus: ,(map val (vector (clojure.lang.MapEntry. :a 5)))

8:53 clojurebot: (5)

8:53 hircus: neat :)

8:53 Chousuke: defn: #(< 4 %)

8:53 defn: err right that's what i meant

8:54 Chousuke: defn: but yeah, just like that

8:54 though the initial value must of course pass the validator too :D

8:55 ,(ref [] :validator pos?)

8:55 clojurebot: java.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number

8:55 defn: Chousuke: haha yes

8:55 Chousuke: ,(ref 1 :validator pos?)

8:55 clojurebot: #<Ref@a9a4f: 1>

8:55 defn: ahhhhh

8:55 thanks Chousuke

9:05 cpfr: hey my code is giving a java exception that is being cutoff

9:05 how can i pipe it so i can see the full error

9:07 n2n3: ,

9:07 clojurebot: EOF while reading

9:08 n2n3: ,def

9:08 clojurebot: java.lang.Exception: Unable to resolve symbol: def in this context

9:08 n2n3: ,(println)

9:08 clojurebot:

9:08 cpfr: anybody?

9:09 raek: cpfr: are you in the repl?

9:09 cpfr: raek, nope running on the command-line

9:10 i use swank for most of my dev work

9:10 but when actually running the code, there is pain

9:10 raek: so, the exception does not happen in the swank repl thread?

9:10 where is it printed from?

9:11 xkb: hmm if I call read-json on a previously opened BufferedReader I get a class-cast exception, LazySeq cannot be cast to PushbackReader

9:11 any way to fix this?

9:11 raek: if you get an exception in the repl, it is bound to the variable *e

9:11 cpfr: raek, not sure how to get it to print

9:12 raek: but something prints it? or how do you see it cut off?

9:13 xkb: are you sure that you pass the buffered reader to read-json?

9:13 cpfr: im pasting right now

9:13 xkb: raek: I take away 2 substrings before passing it

9:13 raek: does that change anything? I can paste the code in pasty if u like?

9:13 cpfr: http://paste.lisp.org/display/113066

9:13 raek: xkb: a paste would help

9:14 how do you do substring operations on readers?

9:14 cpfr: I am trying to extend a class method that returns boolean[]

9:14 raek: cpfr: heh, that's the internal JVM notation of vectors

9:14 [type

9:15 xkb: raek: http://paste.lisp.org/display/113067

9:15 happens on calling userbooks

9:15 its my first attempt at anything beyond hello world btw :P

9:15 cpfr: raek I used the code (into-array [true true])

9:16 doesn't that get me to type boolean[]

9:21 xkb: raek: any tips? :)

9:22 cpfr: raek, so how do I get the risk of that exception error

9:29 xkb: hmm my problem appears to be in strip-header-var function

9:30 which should be generalized anyway :P

9:31 aha.. because drop is lazy

9:36 raek: cpfr: you're trying to use an array of boxed booleans as an array of primitive booleans

9:36 cpfr: ah, how do I stop doing that

9:38 raek: well, I'd have to see the code where you make the arrays in order to know that

9:38 cpfr: hmm will (into-array Boolean/TYPE [true true]) work?

9:39 raek: xkb: you need to do a (apply str ...) on the results to make them a string again

9:39 xkb: raek: Ok, will try, thanks

9:39 seq != String

9:40 good to know

9:40 wee cool, it worked

9:40 raek: xkb: there are some goodies in clojure.string

9:41 those are preferred when working on strings

9:41 ,(into-array Boolean/TYPE [true true])

9:41 clojurebot: #<boolean[] [Z@ca00a>

9:41 raek: ,(into-array Boolean [true true])

9:41 clojurebot: #<Boolean[] [Ljava.lang.Boolean;@ea369a>

9:42 raek: cpfr: yes, your example works

9:59 sid3k: is metadata feature of clojure is an operator overloading approach? since my attention is very distracted now, I couldn't understad it

10:00 Chousuke: overloading?

10:00 metadata is just metadata, what about it makes you think of operator overloading?

10:01 sid3k: lua's approach is metatables, just this naming resembling made me think of o.l

10:02 speaking of that, does clojure support operator overloading or sth like that?

10:03 I guess it's an impossible feature for a lisp dialect

10:03 dnolen: sid3k: metadata is one way to put ad hoc type information on supported data structures. useful when dispatching on multimethods

10:03 Chousuke: sid3k: operators don't really exist in Clojure

10:03 sid3k: Chousuke: right

10:04 Chousuke: though the generic term for the thing at the head of a list can be called "operator"

10:04 dnolen: sid3k: tho it's easy to exclude fn's like + from your namespace and define your own if that's your cup of tea.

10:04 Chousuke: that term encompasses special forms, macros and functions

10:05 sid3k: dnolen: what if we need to execute > function on different data structures?

10:06 Chousuke: sid3k: then the > function needs to be replaced with a polymorphic one

10:06 most likely though a new function will be introduces

10:06 introduced*

10:06 sid3k: you mean, clojure team is already working on that?

10:07 dnolen: sid3k: no you can do that now if you want.

10:07 Chousuke: the new protocol stuff gives you a very efficient way of doing polymorphic functions

10:07 but it has always been possible.

10:07 with multimethods.

10:08 sid3k: this is what I'm going to code now, here my first blog post comes

10:08 Chousuke: or manually via java interfaces and conditionals; eg. the "seq" function

10:08 sid3k: :)

10:09 Chousuke: seq is one of the functions that will most likely be changed into a protocol eventually

10:09 the API stays the same though, which is nice.

10:10 raek: sid3k: http://richhickey.github.com/clojure-contrib/generic.arithmetic-api.html :)

10:11 sid3k: what I think is to code a function executing a method named "gt" by passing second element as argument

10:11 raek: checking out

10:12 raek: thanks this is what I was talking about

10:12 tyvm everyone

10:27 cpfr: raek, sorry my connection is faulty, but I got it working, thanks!

10:30 otfrom: I've been frustrated by google today. Too many results and not enough answers.

10:31 If I generate a pom.xml using leiningen, what maven command could I use to create an uberjar similar to lein uberjar?

10:31 (I need it to work with some collaborators on windows who are clojure noobs)

10:34 noidi: otfrom, http://gist.github.com/504728

10:35 otfrom, that's a snippet from my pom.xml (hand written though, no leiningen)

10:36 oops, that was a bit too much though, that conf also generates a .zip that contains the .jar

10:37 otfrom: noidi, thanks. I'll give that a try. I might have to look at the pom task and see what is going on though. It should generate that.

10:38 noidi: http://gist.github.com/504728

10:38 I stripped the irrelevant bits

10:38 ack, still too much, the property was only used by the .zip generation

10:39 anyway, with that conf for the maven-assembly-plugin, the command "mvn package" should generate an equivalent of a lein uberjar

10:40 otfrom: noidi, cool. thanks again.

10:40 noidi: no problem

10:41 otfrom: noidi, the your.main.class will need to be the generated class name rather than the clojure namespace won't it?

10:41 noidi: yes

10:41 xkb: is spit still in clojure.contrib.duck-streams?

10:41 1.1.0?

10:43 otfrom: noidi, ok. so for my kala.core with a main it will be <mainClass>core$_main.class</mainClass> I'll give that a go. Thanks again.

10:43 noidi: no, it will be kala.core

10:43 if you define the namespace with (ns kala.core (:gen-class))

10:43 mefesto: Is the clojure-contrib link on the clojure.org site going to the github readme file, instead of github pages, by mistake?

10:44 otfrom: I do. OK. Thanks for that. I think you just saved me an hour of head scratching. :-D

10:44 noidi: yeah, maven's a bit of a pain when you're just getting started

10:45 but once you get the hang of the basics, it's quite nice

10:50 raek: xkb: spit will be available in duck-streams for backwards compability

10:50 clojure.contrib.duck-streams became clojure.contrib.io, which became clojure.java.io

10:50 since 1.2.0, clojure.java.io is the one to use for new code

10:52 hrm, ok. 'spit' did not make it into clojure.java.io

10:55 AWizzArd: raek: right, it is in clojure.core

10:56 But why is read-lines not in clojure.java.io?

10:58 raek: read-lines was different from line-seq, rigth?

11:02 otfrom: noidi, that gist works great. Thanks (now to figure out why leiningen isn't creating that by default).

11:04 noidi: otfrom, great!

11:05 xkb: so if I want to write I file, what should I use?

11:05 I now use spit most of the time

11:06 raek: clojure.java.io/writer could be useful

11:07 if you want to write things piece by piece

11:09 xkb: and all at once, cause thats really neat with spit

11:11 fogus: cemerick: I'm totally going to steal your defrecord+defaults macro

11:13 cemerick: fogus: have at it :-)

11:13 I think the kwarg override next step would be a big winner.

11:14 raek: when dealing with very large files, you might want to read and write in a lazy manner

11:15 so that the whole file does not need to reside in memory at one time

11:15 fogus: cemerick: I was thinking more along the lines of defining invariants that the RecordRecordAbstractFactoryFactoryFunction checks, but yes, I agree with your next step

11:18 cemerick: fogus: something like slot-specific asserts/preconditions?

11:18 fogus: yes

11:19 Of course that only works if you go through the factory-fn, but I'

11:19 cemerick: fogus: I think we'd have to have interface/protocol impl mixins for that to work well (i.e. to "wrap" the default record assoc impl)

11:22 fogus: cemerick: Do you mean something that is called automatically?

11:23 cemerick: fogus: yeah, I thought that was where you were going. e.g. (assoc foo :slot some-illegal-value) -> AssertException("some-illegal-value is not within the acceptable range of [-π π]"), etc

11:24 (along with applying the same invariants at ctor-time

11:25 fogus_: cemerick: I thought there was talk of some such factory fn capability in a future Clojure, but I am not sure if the goal was to make it such a hook

11:26 It would be ideal if it were

11:26 cemerick: No, I don't think it was.

11:26 Though, if some interface impl mixin facility comes to fruition, that can be used freely by any macro.

11:39 fogus_: I could always be evil and add a hook to assoc/etc. automagically :-P I might lose my Clojure membership though.

12:12 cemerick: http://gist.github.com/504861

12:25 AWizzArd: Why does (seq (.iterator (org.apache.commons.collections.set.ListOrderedSet.))) not work?

12:26 http://commons.apache.org/collections/api-release/org/apache/commons/collections/set/ListOrderedSet.html says it returns a java.util.Iterator and I thought seq can traverse such structures?!

12:26 wwmorgan: ,(doc iterator-seq)

12:26 clojurebot: "([iter]); Returns a seq on a java.util.Iterator. Note that most collections providing iterators implement Iterable and thus support seq directly."

12:29 AWizzArd: wwmorgan: thanks

13:30 slyrus: hmm... I suppose in clojure the price of a map where each key has itself as its value is pretty low.

13:32 somnium: slyrus: I think those are called sets

13:32 slyrus: somnium: yeah, but if I do it this way I have the option of using a name as the key, or the value itself as the key.

13:34 this is for keeping track of nodes in a graph. sometimes I want a node like "5". It's pretty self explanatory. 5 is the value, the name, etc... Other times I might want "carbon-atom-34" as the name. I could keep a separate map of names to objects, but it might by easiest to just do it this way.

13:37 somnium: slyrus: whatever works, works

13:40 slyrus: indeed

13:46 somnium: and the clojure API is nice enough that if I just use conj I can let the user decide which to use. even better!

13:58 therealni: is there a way to distribute access to the STM across a network? Like can STM be used an in-memory database.

14:04 gigamonkey: Are Clojure's proxies a separate mechanism from java.lang.reflect.Proxy?

14:06 slyrus: hey gigamonkey

14:08 gigamonkey: Yo, slyrus.

14:10 dpritchett: Hey I was just rereading Steele's chapter in Coders at Work this morning. Do you have any new books on the way?

14:11 gigamonkey: dpritchett: no books but I'm working on this: http://www.codequarterly.com/

14:11 More at http://codequarterly.wordpress.com/ and http://twitter.com/codequarterly

14:12 dpritchett: That's new to me, thanks for sharing the link!

14:13 gigamonkey: Feel free to spread it around! (And we're always looking for writers. And we pay!)

14:13 (How much, exactly, TBD.)

14:14 ObClojure--I've got a guy working on a Q&A interview with Rich Hickey.

14:14 AWizzArd: gigamonkey: yes, Clojures Proxies are a bit different

14:14 gigamonkey: AWizzArd: any particular reason?

14:14 I notice you can subclass which you can't with j.l.r.Proxy.

14:14 AWizzArd: yes

14:15 under the hood Clojure uses Classes from the j.l.r package

14:15 gigamonkey: But to make a subclass it must cons up a .class on the fly, no?

14:15 AWizzArd: http://github.com/richhickey/clojure/blob/master/src/clj/clojure/core_proxy.clj

14:16 gigamonkey: Based on the occurence of ClassWriter, I'm guessing what I just said is true.

14:16 AWizzArd: yes

14:17 gigamonkey: And so is the ability to subclass the reason for doing it that way? Or are there other benefits?

14:18 AWizzArd: There was the need for being able to subclass and to implement interfaces. That was before reify was added to Clojure.

14:18 Proxy is very general, while reify is working on Interfaces, but more efficient.

14:30 Drakeson: how can I wrap a call with System.exit trapped?

14:34 AWizzArd: (System/exit 15)

14:36 (Class/staticMethod arg1 arg2 ...)

14:38 pjstadig: is it possible to dispatch a multimethod on the types of its arguments, where one of those types is a primitive array?

14:38 ,(second (map type [ "test" (byte-array [ (byte 1) (byte 2) (byte 3) ]) ]))

14:38 clojurebot: [B

14:39 pjstadig: how could I do (defmethod something [String [B ] @body)?

14:40 AWizzArd: (defn foo [^String s, ^"[B]" x] ...)

14:40 "[B"

14:40 without the closing ]

14:40 pjstadig: k thanks, i'll try that

14:41 wait no

14:41 that won't work, i want to do a multimethod

14:41 i want to dispatch based on the type of the args

14:43 _fogus_: pjstadig: (defmethod foo (Class/forName "[Ljava.lang.String;") [a] ...)

14:44 pjdstadig: (defmethod foo (Class/forName "[[[[I") [a] ...) ;; for prim int

14:44 pjstadig: _fogus_: thanks, that looks like it might work, i'll try

14:45 _fogus_: pjstadig: That last example was a 4-d array however. ;-) "[I" would be a 1-d

14:48 LauJensen: _fogus_: You got that book wrapped up yet ? :)

14:49 _fogus_: mostly. the indexing is torturous but we hand it off to production, and the technical reviewer, in 1-2 days

14:50 LauJensen: Cool

14:50 replaca: _fogus_: wow! congrats. The parts I've read so far are very cool.

14:50 _fogus_: replaca: thank you

15:19 defn: 'lo all

15:24 slyrus: hmm... could there be a bug in multi-arg dispatch for protocol methods implemented by records where a record in a different ns attempts to implement a protocol method from another ns?

15:24 single arg functions seem fine

15:26 I suppose it's more likely that I've screwed something up

15:31 jarodluebbert: would clojure be a good choice for writing a web crawler?

15:33 qchamaeleon: Hi all... Got a question regarding import of java classes/interfaces.. Is it possible to import a java interface that happens to be inside a java class? Haven't had any luck with it at all.

15:33 The particular case I'm looking at is creating a proxy for an interface in Piccolo2D, edu.umd.cs.piccolo.activities.PActivity.PActivityDelegate, where PActivity is a class containing the interface PActivityDelegate.

15:39 _fogus_: qchamaeleon: Try something like this: (import 'java.util.Map$Entry)

15:40 qchamaeleon: Ah. Thank you. Using $ worked. Have I missed it in the docs somewhere?

15:40 _fogus_: Not sure where to find it.

15:40 qchamaeleon: Apparently I have. Found it on the java_interop page..

15:41 _fogus_: hmm, I guess that would make sense. :-)

15:41 qchamaeleon: Thanks a bunch for the insight. Been driving me nuts.

15:43 cemerick: _fogus_: nice addition. A lot simpler than what I was thinking of initially, aligning the kw vals so that they go into the ctor instead of the default expr.

15:44 _fogus_: i went down that path at first

15:44 cemerick: It'll make a lot more sense if one were to add support for lexical ctor arg references as in hugod123's flavour.

15:45 _fogus_: I haven't seen that version

15:46 cemerick: _fogus_: http://github.com/hugoduncan/atticus/blob/master/src/main/clojure/atticus/factory.clj

15:46 _fogus_: I started playing around with my version in trammel but got sidetracked.

15:46 oh cool, thanks

15:47 I'll try to digest this later

15:48 cemerick: The downside of that impl is that (IIUC), an instance of the record is essentially reduced through the non-default args, which would be a perf killer for me.

15:51 defn: Here is a picture of Whistler’s mother with a Winchester: (-> (->> ...))

15:53 _fogus_: defn: That reference just shot over my head

15:56 defn: _fogus_: which one?

15:57 _fogus_: -> ->>

15:57 sexpbot: java.lang.Exception: Can't take value of a macro: #'clojure.core/->>

15:57 defn: http://en.wikipedia.org/wiki/Whistler's_Mother and http://web.blogs.clarin.com/lenovision/files/winchester1200.jpg

15:58 _fogus_: Well, I know what the words mean, but not put together like that

15:58 cemerick: I saw it kicking around twitter this morning. I don't get it either.

15:59 defn: it might not actually make sense

15:59 but im enjoying calling them that

15:59 :D

16:08 slyrus: d'oh! bit by the fields aren't accessors notion again.

16:25 arkh: do I need to be in a non-default namespace if I want to import java classes at a repl?

16:28 nvm - even within a namespace I get the following when trying to import a java class: java.lang.ClassNotFoundException: java.net (NO_SOURCE_FILE:6) Why?

16:30 ,(import 'java.util BitSet)

16:30 clojurebot: java.lang.ClassNotFoundException: java.util

16:30 danielfm: I think it's (import '[java.util BitSet])

16:31 arkh: danielfm: that was it - thank you

16:32 danielfm: I have a silly question about function naming convention, maybe you guys know the answer

16:32 there are some functions that ends with an exclamation mark, e.g. 'swap!', because such functions have side effects, right?

16:33 so, why 'alter' doesn't end with an exclamation mark? Am I missing something?

16:37 dnolen: danielfm: probably because they must appear inside of dosync

16:38 danielfm: dnolen, yeah, I misunderstood the docstring

16:38 "Must be called in a transaction. Sets the in-transaction-value of ref to..."

16:38 that "sets the in-transaction-value" answers my question

16:39 arkh: there's also io!, which is called in a transaction but given an ! for "opposite" reasons

16:39 danielfm: , (doc io!)

16:39 clojurebot: "([& body]); If an io! block occurs in a transaction, throws an IllegalStateException, else runs body in an implicit do. If the first expression in body is a literal string, will use that as the exception message."

16:40 arkh: that's a horrible explanation

16:41 danielfm: arkh, yeah, the function itself doesn't have any side effects, but it avoids that you do some nasty stuff inside a transaction, which may be replayed several times

16:41 arkh: it should be something like "If IO occurs within io!, within a transaction, throw an IllegalStateException, etc.

16:42 rhudson: See http://www.assembla.com/wiki/show/clojure/Clojure_Library_Coding_Standards

16:42 "Use the bang! only for things not safe in an STM transaction."

16:42 arkh: rhudson: you get +1 clojure credits for finding the canonical explanation ; )

16:43 danielfm: rhudson, thanks!

16:43 tomoj: arkh: but wouldn't that be incorrect?

16:43 dsantiago: io! is your declaration that something in the body is doing IO.

16:43 tomoj: ->(dosync (io!))

16:43 sexpbot: java.lang.SecurityException: Code did not pass sandbox guidelines: ()

16:44 tomoj: err

16:44 arkh: oh ..

16:44 tomoj: ,(dosync (io!))

16:44 clojurebot: java.lang.IllegalStateException: I/O in transaction

16:44 arkh: I sit corrected :)

16:44 tomoj: of course, an io! block with no IO would be kinda silly..

16:45 danielfm: tomoj, in this particular case, even if the io! function itself is safe, the function it wraps is not

16:45 so I understand why this function ends with a !

16:47 tomoj, but I got your point :)

16:48 tomoj: seems like io! is only useful if you use it every time you do IO

16:48 dsantiago: I think it's for writing libraries.

16:48 So you can help people keep troublesome functions out of their transactions.

16:48 tomoj: that makes sense

16:48 does anyone actually use it, though?

16:49 danielfm: dsantiago, indeed

16:53 I don't see much use for io! because according to the coding conventions, is enough to just mark unsafe functions with a !

16:54 io! just makes sure that such functions can't be used inside dosync

16:55 but that's a whole another discussion...

16:55 rhudson: The only uses of io! in core.clj are in await and await-for

16:59 danielfm: hm, that's what dsantiago told about avoid the misuse of certain functions inside transactions

16:59 so probably 'io!' is not the best name for such function..

17:01 i don't know :P

17:01 rhudson: fwiw (dosync (spit "/tmp/foo" "foo")) executes without exception

17:02 tomoj: if you always put io! around every bit of code that does IO, you will never accidentally do IO in a transaction

17:02 that's the use I see

17:03 but no one does that, so..

17:06 danielfm: tomoj, I actually didn't know about that function, but indeed its use is something to consider

17:06 specially in libraries

17:07 thank you all!

18:46 defn: how would you rework this: http://gist.github.com/505467

18:47 confounds: i'd move the download link a little to the right

18:48 and maybe change the background to an off-white

18:51 tomoj: defn: why dorun?

18:52 and why (let [rec (read r)] rec) instead of (read r) ?

18:52 clojurebot: click

18:52 tomoj: guess those aren't the kind of comments you're looking for, sorry :(

19:31 defn: tomoj: no very good ty

19:57 gfrlog: ,clojure.core.json

19:57 clojurebot: java.lang.ClassNotFoundException: clojure.core.json

19:57 gfrlog: ,clojure.core.json.read

19:57 clojurebot: java.lang.ClassNotFoundException: clojure.core.json.read

19:58 gfrlog: ,clojure.contrib.json.read

19:58 clojurebot: java.lang.ClassNotFoundException: clojure.contrib.json.read

19:58 gfrlog: ,clojure.contrib.json

19:58 clojurebot: java.lang.ClassNotFoundException: clojure.contrib.json

20:11 TakeV: Is there a way to extend a struct, so that I have, say, Struct02 with all the keys of Struct01, as well as it's own keys?

20:16 notsonerdysunny: is there a binary file format write s-expressions?

20:16 dnolen_: TakeV: not really, though you could write some macros, I did that once. But I'm not convinced there's much advantage to just merging two maps.

20:17 notsonerdysunny: I am sorry I typed that in a hurry ... is there a binary file format to store s-expressions? I intend to use s-expressions to store large simulation data ..

20:19 TakeV: dnolen_: Hmm, a macro would work nicely. Thank you.

20:21 dnolen_: notsonerdysunny: I haven't heard of anything like that.

20:21 notsonerdysunny: I just found out from the #lisp that there is something called cl-store .. which has a binary backend ..

20:22 I am still looking for a clojure equivalent ...

20:22 brehaut: notsonerdysunny: i believe the clojure core structure types all support java's serialisability

20:23 i cant speak for the quality of that

20:23 but it might be half way to what you want?

20:24 notsonerdysunny: I am new to serialisability thing .. but is there something like binary-serializable .. which would make reading large "serialized-data" really quick

20:25 brehaut: notsonerdysunny: no idea sorry, ive never wanted to look at javas serialisation support

20:31 qbg: I can read in a serialized list of 10000 integers in 138 msec on my machine

20:34 The downside of serialization is that you shouldn't serialize functions/closures

20:34 That includes lazy sequences

20:36 brehaut: notsonerdysunny: the other caveat re:serialization is that it is intended to be used with short term storage only

20:36 notsonerdysunny: http://www.assembla.com/spaces/clojure/tickets/281?page=1#comment%3A17

20:39 notsonerdysunny: qbg: I only intend to use serialization for storing data

20:39 qbg: so what you are saying is a non-issue .. I want to be able store large simulation-related data as s-exps .. since it is a simple extendable way of doing it

20:41 brehaut: notsonerdysunny: do you want the data to be able to survive releases of clojure?

20:42 notsonerdysunny: yes .. I want it as a file format which can be easily read into clojure that is all...

20:42 brehaut: notsonerdysunny: then plain java serialisation is not for you (as per link above)

20:42 KirinDave: notsonerdysunny: Write a function to read a line, then make a lazy sequence out of a file.

20:43 notsonerdysunny: Clojure makes lightweight formats like tsv as easy as any lightweight text processing lang i've ever seen. Especially if you adopt clojure literals.

20:44 Has anyone written a yaml-clojure yet?

20:45 notsonerdysunny: KirinDave.. I don't want simple ascii .. since I intend to store large uniform array-like simulation related data ...

20:45 apage43: http://github.com/lancepantz/clj-yaml

20:45 notsonerdysunny: it needs to be binary

20:45 lancepantz: oh don't look at that

20:45 that was my learning clojure project :)

20:45 apage43: xDD

20:45 KirinDave: ;)

20:45 technomancy: pssh--back in my day we only had one value for a bit.

20:45 brehaut: if its uniform and array shaped, why not just write a reader using javas binary IO layers

20:46 lancepantz: that just deserializes anyways

20:46 apage43: you could ostensibly use most java yaml libraries with relative ease

20:46 KirinDave: apage43: Bleck tho.

20:46 brehaut: technomancy: haha

20:46 lancepantz: right, the clojure wrapper isn't even neccessary

20:46 KirinDave: Yeah but eff those.

20:46 lancepantz: just use snakeyaml directly

20:46 apage43: http://github.com/joshua-choi/fnyaml

20:46 fnparse yaml

20:47 lancepantz: i always either use clj-json or protobufs

20:47 KirinDave: let me look at snakeyaml. C# has taught me to distrust static typing implementations of heterogenous serialization formats.

20:47 lancepantz: json is human readable enough imho

20:48 KirinDave: json is great.

20:48 But yaml is less of a pain to type.

20:48 That can be an important consideration.

20:48 lancepantz: fair point

21:47 mister_m: how do I make sure somethign is in my classpath, so I can (load x) it

21:47 or (require )

21:48 from the REPL

21:50 tomoj: are you asking how you can see what your classpath is?

21:52 mister_m: tomoj, and I guess how to add a folder to it

21:52 tomoj: don't add folders to your classpath

21:52 well.. how are you starting the repl?

21:53 from the repl you can see your classpath with (System/getProperty "java.class.path")

21:53 mister_m: I just type clojure at my command prompt

21:53 tomoj: ..where'd you get that 'clojure' script?

21:53 rhudson: mister_m: Check out cljr -- that makes it very easy to control your repl classpath.

21:54 http://github.com/liebke/cljr

21:56 tomoj: jeez, I need to get cljr just for clojars searching

21:56 lancepantz: there is also a lein plugin

21:57 don't remember what its called

21:57 tomoj: but then you have to add it to all of your :dev-deps, eh?

21:57 lancepantz: right

21:57 KirinDave: Why is add-classpath still around? I thought it was deprecated?

21:58 rhudson: It's still deprecated

21:59 mister_m: tomoj, you know I don't even know

21:59 tomoj: cljr looks like the way to go until you start making projects with lein

21:59 mister_m: where I picked up running the repl with 'clojure', probably through my trying to get it to work with emacs or soemthing

22:01 tomoj: for emacs you'll want `cljr swank`

22:02 KirinDave: Didn't java-utils or repl-utils used to have a classpath convenience function?

22:03 Oh it's just classpath now. Haha, shows how often I have to do stuff w/out lein ;)

22:10 mister_m: thanks for the cljr tip guys

22:12 qbg: github question: Is there any way to reopen a closed issue without create a new one?

22:14 lancepantz: heh, is it the read issue? :)

22:14 qbg: That worked

22:14 lancepantz: yay!

22:15 qbg: But I still can't read if I just (flush)'ed before hand

22:15 For example, (do (print "> ") (flush) (read))

22:18 tomoj: in what context? just curious

22:18 qbg: If I run 'cake repl' and try to evaluate that, the problem presents itself

22:19 tomoj: ah, cake

22:20 lancepantz: qbg: ninjudd reopened it

22:20 qbg: It seems weird; Clojure's repl seems to work fine...

22:21 ninjudd: qbg

22:21 qbg: looking into it

22:21 qbg: Okay

22:22 ninjudd: i think you can reopen on github with the "Actions" menu

22:23 qbg: cake's repl is much more compilcated than clojure's because it uses sockets to communicate with the persistent JVM

22:23 qbg: But shouldn't the clojure repl be doing essentially the same thing under cake as I am?

22:24 I'm not seeing an "Actions" menu

22:24 ninjudd: qbg: i guess it is only for the repo owner...

22:27 qbg: The project that I'm testing this on works fine under my nailgunized clojure repl

22:27 ninjudd: qbg: i reopened the ticket for you

22:28 qbg: yeah the issue is actually with readline. working on a fix

23:41 qbg: i just checked a fix in to github. let me know if it works when you get a second

23:42 qbg: Yay! It works!

23:42 Thank you ninjudd

23:42 ninjudd: sweet!

23:43 qbg: thanks for finding that bug. it was a tricky one

Logging service provided by n01se.net