#clojure log - Sep 07 2010

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

0:04 thunk: (with-db (init-db))

0:04 haha

0:04 yeah.

0:05 nm

0:22 llaarrll: anybody home?

0:26 seancorfield: not many ppl at 9pm pacific on a US public holiday :)

0:27 actually it always amazes me how many ppl seem to be on this channel... over 200...

0:28 llaarrll: wow, its a holiday in the States?

0:28 Ive been away for too long, it seems

0:28 seancorfield: Labor Day - when folks do no labor...

0:28 although i've been working like a dog all weekend... big site launch coming up this week :)

0:29 llaarrll: awesome

0:29 congrats

0:29 maybe you can help me

0:29 is there a way to evaluate an s-exp in a string

0:29 in ruby it'd be "whatever #{2+2}"

0:30 printing as "whatever 4"

0:30 wwmorgan: ,(doc format) ; <- llaarrll

0:30 clojurebot: "([fmt & args]); Formats a string using java.lang.String.format, see java.util.Formatter for format string syntax"

0:31 seancorfield: i guess it must be possible... templating engines must do something like that...

0:31 llaarrll: yeah, actually, thats the goal

0:31 writing a templating library for compojure

0:32 most of the ones Ive seen simply allow you to generate HTML from clojure code...not too good for designers

0:32 replaca: llaarrll: yeah, look at clojure.contrib.strint: http://clojure.github.com/clojure-contrib/strint-api.html

0:33 llaarrll: cool checking now

0:33 replaca: the feature in general is called "string interpolation"

0:33 llaarrll: ahh

0:33 wow, strint is perfect

0:33 seancorfield: i was just about to ask where the name strint came from - thanx!!

0:34 jeez, clojure has so much stuff built-in... the library just keeps amazing me!

0:34 replaca: np

0:34 seancorfield: ok, time for dinner and TV... it's been a long work day :(

0:35 llaarrll: good luck on the launch

3:17 LauJensen: Good morning team

3:19 Raynes: Morning teammate.

4:21 neotyk: Hi *

5:47 does anyone know how to make that happen? http://github.com/neotyk/http.async.client/blob/a45b5e4a68fc46f2832be4c9182eff4bd3a7c41e/src/http/async/client.clj#L43

5:55 LauJensen: neotyk: Im a little unsure what you're trying to do, is it like this? (defmacro with-doc [name doc] `(defn ~name ~doc [] nil))

6:03 abrenk: I'm using clojure.contrib.lazy-xml/emit with :encoding "ISO-8859-1" to write out text containing german umlauts. Unfortunately the umlauts are still written in an UTF-8 2-byte encoding and are corrupt when read back in. What could I be doing wrong?

6:03 LauJensen: abrenk: Could it be the reading that tripping you up ?

6:04 abrenk: LauJensen: no, i checked the just written out xml in a hex editor

6:05 LauJensen: chouser should be here in a couple of hours, he wrote the lib and would be aware of any bugs

6:06 abrenk: Thanks, I'll fiddle around some more and keep idling here.

6:09 neotyk: LauJensen: question was about do-template

6:10 I generate there GET,PUT,... as they I just convenience fns for user

6:10 but are very similar to each other

6:10 they diff in name,and method to be used

6:11 also should diff in docstring

6:11 though I have no idea how to do that with do-template

6:11 LauJensen: isnt it just a matter of iterating through those variations, calling defn with each of them ?

6:12 neotyk: yes, it is

6:12 but I can't generate a docstring for it

6:12 LauJensen: Why not?

6:12 neotyk: I've tried wrapping (defn .. in (let [

6:12 but it didn't work

6:14 LauJensen: (doseq [[name docstring] [["GET" "A Getter"] ["PUT" "A putter"]]] (defn (symbol (str ~name "-" something)) ~docstring [args] ~@body)) ... ?

6:15 hiredman: you can't do that

6:16 LauJensen: you wont allow it?

6:16 hiredman: if that would work you would need to quote symbols passed to defn

6:16 (defn 'foo …

6:18 LauJensen: So they have to be passed directly from the arg list

6:27 neotyk: I must be missing something obvious here

6:28 why (do-template [sym] (let [n (name sym)] (defn sym {:doc n} [a] a)) A B C) doesn't work in repl?

6:28 it says "Unable to resolve symbol: A in this context"

6:42 lenw: anyone else from South Africa here ?

6:57 LauJensen: da-loic: welcome :)

6:58 da-loic: LauJensen, thanks!

6:59 Raynes: LauJensen, da-loic: Wasn't that exchange a bit backwards?

7:00 LauJensen: Raynes: how so?

7:00 Raynes: "You're welcome." usually comes after "Thank you."

7:01 da-loic: Raynes, it was more a thank you for the welcome here

7:01 Raynes: Oh, I see.

7:01 It looked as if you were thanking him for something.

7:01 I mean, you know, something other than welcoming you.

7:01 I digress.

7:02 da-loic: Raynes, you are right, it looked like an unordered list of events

7:02 LauJensen: hehe

7:02 da-loic: Raynes is from alabama, so Im guessing he's a little sleep deprived now?

7:03 Raynes: Not at all. I woke up at 12.

7:03 12AM, that is.

7:03 LauJensen: So you've completely reversed your internal clock now?

7:05 Raynes: I suppose.

8:01 opqdonut: after upgrading from 1.1 to 1.2 I get a lot of reflection warnings from array operations

8:04 Chousuke: array ops give reflection warnings now?

8:04 they used not to.

8:04 they still did reflection though :P

8:08 opqdonut: ah, that explains

8:09 can i hint something as just an array?

8:09 to make alength not reflect, for instance

8:11 Chousuke: I think you can do ^objects

8:11 LauJensen: opqdonut: http://bestinclass.dk/index.clj/2010/03/functional-fluid-dynamics-in-clojure.html

8:11 Read the top, and the link to christophs blog if you like

8:13 opqdonut: ^objects probably won't work on float[]

8:14 LauJensen: opqdonut: My approach can work with any primitive type you like

8:15 opqdonut: yeah, I see

9:08 cemerick: I've been working on a design for a new hosted/remote Clojure REPL impl. Your input very welcome. http://bit.ly/a1SRtU

9:09 jave: I have a compojure app. one of the pages is more like a html+js blob where a string array is going to be replaced by clojure. what would be a convenient way?

9:09 I already have the blob as a html file

9:11 LauJensen: jave: I always use Enlive/templates for such tasks, but I guess if you needed a really dirty hack you could run a .replaceAll on the html :)

9:12 jave: LauJensen: I havent used enlive, but I'm considering it for this. but is it possible to select an expression within a js blob inside the html?

9:13 LauJensen: I dont think so. Enlive uses selectors similar to CSS selectors. But your template could emit something like "<script type=""> var data = " yourdata "</script>" and then your JS could just get that

9:21 jave: I think "strint" will be ok for my purposes here

9:31 * Raynes managed to lock up his computer with an applet.

9:39 LauJensen: On the things I really love about my Clojure baked site, is that I can reboot the backend without any users being affected

9:45 mrBliss: LauJensen: read this? http://ceondo.com/ecte/2010/09/productivity-conkeror-instapaper-kindle (mentions your article)

9:46 LauJensen: mrBliss: Yea, whenever somebodies links me, I see it in the admin panel on Best In Class. Its da-loic who wrote it

9:46 mcav: LauJensen: are you running two servers and load balancing?

9:46 mrBliss: okay

9:47 LauJensen: mcav: No load-balancing, but since the site is baked, everything except the comment box and the admin panel are run by nginx. The rest is run on a Jetty instance, so I can reboot one and not affect the other. Since the site is static, it should be able to handle at least 4 - 5000 requests per second, so I doubt I'll need a load balancer in this life time

9:47 mcav: oh, cool.

9:50 LauJensen: yea, bestinclass is web scale :)

9:52 cemerick: What was that piece of software again, that you used for screencasts, and is it available for Windows?

9:52 cemerick: You mean what I've used in the past? Screenflow.

9:52 Not sure if it's available on windows.

9:52 LauJensen: Yea - You switched

9:52 http://vincesamios.com/internetmarketing/screenflow-on-windows-xp

9:54 Yea - You switched?

9:57 cemerick: LauJensen: No, I still use the same thing

9:57 LauJensen: k

9:58 cemerick: It seems the guy was running OSX in a VirtualBox which isnt an option for me, so I'll have to send you the script and then you can reply with the screencast, thanks

9:59 cemerick: I didn't think you could run OS X in a VM at all

10:13 LauJensen: cemerick: Camtasia looks like the closest match. Its 300$ and Screenflow is free right?

10:16 cemerick: LauJensen: No, screenflow's not free, but it's fairly inexpensive. Somewhere in the $50-$100 area, I think.

10:16 LauJensen: Nice

10:38 _fogus_: Before I go further down the defadvice rabbit hole, does anyone know of a library providing :before, :after, :around functionality for Clojure?

10:39 mrBliss: maybe this: http://github.com/technomancy/robert-hooke

10:40 _fogus_: mrBliss: That is a nice framework to build on, but not quite there

10:42 naeu: howdy

10:42 has anyone in here had any experience with the JVM's parallel garbage collector?

10:44 karmazilla: naeu: the default one?

10:44 naeu: karmazilla: I was under the assumption that the default GC wasn't parallel

10:45 so I've been considering: -XX:-UseParallelOldGC

10:46 karmazilla: the default uses multiple threads for the young generation (at least)

10:46 naeu: karmazilla: interesting, I didn't realise that

10:47 karmazilla: so do you know the difference between the default GC and the one you use with the option -XX:-UseParallelGC

10:48 karmazilla: I don't. But it should be googlable

10:48 naeu: Yeah, that's what I'm up to now. It's just often more conducive to learning to speak to someone with prior knowledge :-)

10:50 karmazilla: the recent HotSpot versions has GC ergonomics, so for most apps you'd typically only need to set the max heap size

10:52 _fogus_: cemerick: Do you happen to have that code laying around?

10:52 neotyk: I'm trying to solve this one for better half of a day, I just don't get it http://gist.github.com/568486

10:54 jave: does the lein project "resources" dir get added to the classpath? how do I conveniently read a file from the dir?

10:58 _fogus_: neotyk: That needs to be fixed... and it also needs to be evaluated. Is there some context that is missing? i.e. Is this the body of a macro?

10:58 neotyk: _fogus_: I'm trying to generate those: http://github.com/neotyk/http.async.client/blob/a45b5e4a68fc46f2832be4c9182eff4bd3a7c41e/src/http/async/client.clj#L43

10:59 and did generate with do-template, though have no idea how to add docstring that is not a lieral

10:59 _fogus_: neotk: Here is some major hackery... I wouldn't do it this way, but it should get you one step closer: http://gist.github.com/568491

11:02 neotyk: _fogus_: there goes easy maintenance of this code, but thank you anyway, it will be easier for users

11:03 _fogus_: neotk: Well, like I said I wouldn't do it that way. ;-)

11:03 neotyk: _fogus_: do tell, how would you do that

11:04 private macro to generate those?

11:11 _fogus_: That would work

11:12 Chousuke: neotyk: can't you add a docstring parameter into the template?

11:13 neotyk: Chousuke: yes, but those doc strings same as fns will share a lot of structure

11:14 Chousuke: what's the problem with (dotemplate [fn-name method docstring] ... {:doc docstring} ...)?

11:14 mrBliss: how do you 'restart' the agents again after calling shutdown-agents?

11:14 Chousuke: hm

11:14 I don't think there's any documented or supported way to do that.

11:15 mrBliss: a shame, now I'll have to rebuild my whole repl state (lot of work)

11:15 Chousuke: hm

11:16 replace your repl function with something that records a transcript :)

11:16 mrBliss: it involved some time consuming operations

11:16 ihodes: strangely, i've never had to do this before…but how do I run a clojure script, passing X args to a function in it? can I specifiy the entry point either when calling the script, or in the script without gen-class/compiling?

11:17 neotyk: Chousuke: I guess nothing, I just wanted to have those doc strings be generated within do-template as they will differ only with method that is used, all args are the same, result also.

11:17 ihodes: or should i just have (THEFUNC X) in the script

11:18 Chousuke: ihodes: I suppose you can pass the script file to the clojure.main class so it runs it, then use -e to eval (thefunc args)

11:18 neotyk: I see.

11:19 neotyk: and the defn macro doesn't evaluate the metadata map?

11:19 neotyk: Chousuke: I couldn't get it to do so

11:19 Chousuke: I suppose it doesn't then.

11:20 neotyk: Chousuke: should I go straight to clojure.core.clj and fix it ;-)

11:20 dnolen: ihodes: I like cake's solution to that problem. You can basically write Clojure shell scripts with it. It passes the command line arguments as well as the shell environment so you can figure what directory the script was run from.

11:21 _fogus_: neotyk: http://gist.github.com/568518

11:21 ihodes: chousuke: dnolen: ah thanks. i do think do a bash script after i finish testing and just wrap it as usual. i may have to look into cake's way of doing things

11:22 Chousuke: _fogus_: there's no need to use autogensyms within unquoted forms

11:23 _fogus_: Chousuke: Habit

11:23 Chousuke: _fogus_: I suppose it's better than forgetting autogensyms entirely :)

11:24 _fogus_: Chousuke: Which is why I like that habit. ;-)

11:27 neotyk: _fogus_: thank you very much, this one I'll be able to maintain

11:38 lypanov: whats current status on clojure in clojure / js clojure

11:38 any movement on the later?

11:40 chouser: no change re: js clojure

11:41 lypanov: ah... someone already posted wrt reactive programming on the mailing list

11:41 http://groups.google.com/group/clojure/browse_thread/thread/8c9085e10c33bbb6

11:42 chouser: I'm (slowly) poking away at the intermediate analysis tree. The pace of that should pick up once finger trees are done -- probably after the October conferences.

11:42 lypanov: on the strees?

11:43 what sort of analysis out of interest?

11:43 any type inference?

11:43 chouser: just what clojure's compiler does now

11:44 lypanov: ah the java -> clojure switch?

11:44 chouser: But the analysis phase currently generates rather messy and opaque pojo's, so I'm trying to convert that to a tree of nice immutable record objects.

11:45 lypanov: chouser: v offtopic. any ideas / goals when joy of will be final?

11:45 chouser: that tree of record objects (what I've been calling the analysis tree) ought to be a perfect starting point for any kind of more advanced static analysis and emitting any sort of code (bytecode, js source, etc.)

11:45 * lypanov is being lame and delaying reading until the epub's are out

11:46 lypanov: chouser: *nod*

11:46 chouser: lypanov: our part is essentially done -- waiting now on copyediting, production, etc. We have essentially no more visibility on that than you do.

11:46 lypanov: i should dig into gwt to see what sort of analysis they do to get the insane speed ups they pulled off

11:47 chouser: we noticed amazon pushed the release back to the end of december -- we're hoping it's not actually going to be that late.

11:47 lypanov: what i'd actually like to do is a rewriting -> js jitter

11:47 but thats probably far too insane

11:48 i have no idea how much static analysis can be done on common clojure code

11:49 chouser: k. figured. will they make a final pdf before publish so people can verify the copy?

11:50 chouser: lypanov: not sure.

11:50 * lypanov wants to build a websockets based reactive web programming system in pure clojure on server and client and can't even code clojure (or anything more than basic uni level scheme), so needs luck :P

11:51 * _fogus_ Was talked off of the yak-shaving ledge by technomancy.

11:51 chouser: hehe. which ledge?

11:53 apgwoz: _fogus_: i've been thinking about how to nicely do "advice" like things recently. i like the idea of `defadvice`, but i'll certainly take a look at robert-hooke

11:53 _fogus_: chouser: The defadvice ledge

11:54 I only needed a subset, but thought... Hey, why not just write a whole library!

11:54 :p

11:55 apgwoz: i guess it does get pretty ugly to start doing `(def newthing (decorate oldthing))`

11:55 pdk: i still never got the decorators idea when i read the explanations of it in python a few years ago

11:56 or how itd be useful, should prob go look at that again

11:57 apgwoz: pdk: it's greatly useful in python for composing functions in interesting ways

11:57 sleepynate: holy exception stack when buildin'g contrib's maven package

11:57 apgwoz: they're a bit awkward to write though sometimes

11:57 pdk: yeah i kinda read about it before i knew about function composition sorta stuff

11:57 so maybe a case of me wearing the blub goggles then

11:58 apgwoz: pdk: :)

12:06 abrenk: chouser: I'm using clojure.contrib.lazy-xml/emit with :encoding "ISO-8859-1" to write out text containing german umlauts. Unfortunately the umlauts are still written in UTF-8 2-byte encoding (I checked in an hex editor). Any hint what I could be doing wrong?

12:06 chouser: hm.

12:07 ihodes: so i'm getting a NPE on trying to compile: it's in my NS declaration: (ns pw.bot (:use [pw.planetwars])) and i have no idea why. planetwars.clj exists and has ns pw.planetwars and they're both in the dir pw/

12:08 abrenk: the legacy system i need to exchange data with only supports latin1. otherwise i'd switch to utf-8 in a heartbeat.

12:08 mrBliss: ihodes: drop the brackets

12:08 ihodes: mrBliss: tried that

12:08 chouser: abrenk: right. I just pass that along to the xml Transformer.

12:09 I'll see what I can figure out.

12:12 abrenk: how are you capturing or writing out what emit produces?

12:13 ihodes: um…so I added some random thing at the end of the file and now it compiles. what the %(#%!?

12:13 abrenk: chouser: I read an existing file and replace nodes using xml-zip with "element" structs I assemble.

12:15 chouser: probably moot anyway. I'm still getting encoding="UTF-8" in the xml declaration it prints.

12:15 abrenk: the declaration is okay

12:17 chouser: you're getting encoding="ISO-8859-1" ??

12:17 abrenk: I'm using clojure-contrib 1.2.0 by the way

12:17 yeah

12:17 chouser: ,(class (.newTransformer (javax.xml.transform.TransformerFactory/newInstance)))

12:17 clojurebot: com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl

12:18 chouser: oh dear. What do you get for that?

12:19 abrenk: I'll check.

12:19 com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl

12:20 chouser: ok

12:20 now I'm seeing the behavior you are.

12:20 which is different than what I was seeing with com.icl.saxon.IdentityTransformer

12:21 abrenk: I've added xerces 2.9.1 to my classpath but it doesn'

12:21 t seem to be the current implementation

12:24 chouser: I can set the encoding to all manner of invalid things and it still gets dumped into the xml declaration without error. :-/

12:27 abrenk: and the document is still written in utf-8 i suppose

12:27 chouser: apparently. I'm concerned about the use of *out* possibly mucking with the encoding.

12:35 abrenk: right. *out* could be responsible. good thought. so as an ugly workaround I could just re-read the file in utf-8 and write again in iso-8859-1 using normal java file io.

12:35 chouser: abrenk: ok, it looks like the encoding of the output stream is controlling.

12:36 (with-open [w (java.io.OutputStreamWriter. (java.io.FileOutputStream. "/tmp/foo.xml") "ISO-8859-1")] (binding [*out* w] (emit {:tag :body :content ["Ö"]} :encoding "ISO-8859-1")))

12:37 I'm getting good results across a couple transformer impls by specifying the same encoding to both emit and OutputStreamWriter.

12:38 it looks like com.icl.saxon.IdentityTransformer essentially ignores the emit option, and writes out the correct header for what the output stream is actually going to do.

12:39 while com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl prints whatever header you give to emit, but then actually does the encoding specified by the output stream, thus allowing for a possible mis-match.

12:40 abrenk: interesting

12:41 I'll try your with-open code instead of duck-streams' with-out-writer.

12:48 Success! (binding [*default-encoding* "ISO-8859-1"] (with-out-writer ...)) works!

12:50 chouser: Thanks so much! I was really stuck. Drinks are on me tonight! ;-)

12:51 chouser: woohoo!

12:52 I wonder if emit could detect and complain if :encoding doesn't match the encoding of *out*

13:03 abrenk: emit would have to unwrap *out* until it finds the OutputStreamWriter and compare getEncoding to the one specified as an option I guess

13:49 cemerick: _fogus_: I'm having a helluva time finding it. I've definitely written defadvice before.

13:50 Bahman: Hi all!

13:52 KirinDave: _fogus_: Hey.

13:52 _fogus_: Have you looked at the error kit stuff yet?

13:55 nickik: does it make sence to use hiccup and enlive? I testing out some webstuff and im not sure if that makes sence.

13:55 LauJensen: nickik: hiccup is for generating html right? And enlive is for generating html and scraping it...

13:59 _fogus_: KirinDave: Not closely, but the other co-author of JoC has. :-)

14:01 KirinDave: _fogus_: I really think that it's possible to re-implement conditions and restarts almost totally.

14:03 _fogus_: KirinDave: I have heard others say the same, but I am not exactly sure what would go into that. My understanding of the CL conditions system is mostly forgotten

14:03 chouser: KirinDave: differently than error-kit does?

14:04 KirinDave: chouser: So, I looked at ek.

14:04 And it doesn't seem to actually provide arbitrary restarts?

14:04 Nested, anyways.

14:04 chouser: hm... I *thought* it did...

14:04 not that anybody uses that.

14:04 KirinDave: chouser: I never saw an example that did it the way I expected.

14:04 Oh I did.

14:04 Let me look again.

14:05 Because I found myself really wanting it last wee.

14:05 chouser: oh, yeah? well, that's good anyway. :-)

14:05 KirinDave: err, week

14:05 Last wee too, truth be told

14:05 chouser: too much truth

14:06 KirinDave: chouser: I'm going to have to experiment.

14:06 I suspect it's going to be a huge pain in the ass to get it just right.

14:06 But I think all the pieces are there to do real restart handling, it is just incredibly tedious .

14:11 Hum

14:11 chouser: Maybe I should have read http://groups.google.com/group/clojure/browse_thread/thread/2d1d91693887a45b rather than just browsed the api doc and source.

14:11 chouser: It's closer than I realized.

14:14 chouser: I've never used CL's condition system, so any failure is likely in my understanding.

14:14 I'd also like to simplify error-kit, if it's worth keeping at all. the object system built in for doing error objects is too weird and heavy.

14:15 KirinDave: It's sorta weird to have the default handler be on the object.

14:15 At least to my sensibilites

14:15 Seems like a with-handler could specify a default handler.

14:16 hiredman: dunno if you've looked at clojure.contrib.condition, but I feel I should mention it

14:16 KirinDave: chouser: Also, seeing your very with-handler implementation

14:16 _fogus_: KirinDave: A little more information http://pragprog.com/magazines/2009-07/when-things-go-wrong

14:16 hiredman: it's even less of cl's condition system

14:16 KirinDave: chouser: Reminds me how much I want macros by example in clojure.

14:17 hiredman: but we use it at work

14:17 KirinDave: hiredman: That, I have seen. It's all good.

14:17 It's just really cool for interactive development to have a good condition/restart system.

14:17 cemerick: I've never grokked that, actually.

14:17 KirinDave: It's also really useful for unit testing.

14:18 Actually, check that. Condition/restart is the most amazing shit for unit testing.

14:18 Because you make your mocks explicit.

14:19 cemerick: I'm not sure I've ever mocked anything, ever.

14:19 KirinDave: cemerick: A good example is time.

14:19 You make a little (mock 'mock-name (lambda ...))

14:19 Which you can do with anything, really.

14:19 But condition-restart was a cool way to do it

14:20 technomancy: cemerick: mocking is a fancy OO-land term for binding, afaict

14:20 KirinDave: technomancy: Sorta.

14:20 cemerick: technomancy: right

14:20 I actually don't often rebind functions either *shrug*

14:20 KirinDave: technomancy: It's not cool to rebind it, in my estimation tho.

14:21 But seriously, having a restart in a function that just says, "No, return this instead."

14:21 That's so amazing for interactive work and unit tests.

14:21 _fogus_: Isn't some of this meant to be addressed by scopes?

14:21 KirinDave: Dunno. Is it?

14:22 * _fogus_ looking for the example...

14:23 KirinDave: You're the one with the google juice on that one. ;)

14:28 _fogus_: Was this your example? http://cl.ly/2I36

14:30 _fogus_: Yeah, that was my example, but not the canonical example. But in any case, I suppose scopes are meant for resource handling scenarios

14:33 KirinDave: It's a good idea

14:33 but it seems very static?

14:33 Like, you must define them at method definition time.

14:34 I can't help but wonder if real :before :around :after support would be better for that.

14:36 _fogus_: KirinDave: I've always been a fan of post-definition overlays of these types of things (i.e. :before/:after, :pre/:post), but that's just me

14:38 KirinDave: _fogus_: If only because you may not be able to know the exact cleanup.

14:38 I mean, the scopes syntax is a good one.

14:38 But it could be implemented in terms of another thing easily.

14:39 raek: hrm, clojure-test-mode does not highlight the line where a is-form failed for me anymore. any ideas?

14:41 _fogus_: KirinDave: My hammer of choice would be to define the scope handlers in a HOF and use that to delegate to the original fn.

14:41 KirinDave: Right.

14:44 _fogus_: My whole impl of Trammel is built around that tiny little thing. :-)

14:50 ssideris: what's Trammel?

14:52 found it...

14:52 * ssideris reading

14:56 raek: nevermind... updated clojure-mode to the latest version and it worked again :D

14:57 now, is there any preferred ordering:

14:58 (is (= expected actual))

14:58 - or -

14:58 (is (= actual expected))

14:59 ssideris: I'm looking at alter-var-root... I tried this:

14:59 (def sq [x] (* x x))

14:59 (alter-var-root sq (fn [x] (do (print x) (te x))))

14:59 but it says that sq is not a var

15:00 what am i missing?

15:02 (i'm guessing the answer is "everything" :-D)

15:03 raek: a small detail: sq evaluates to the value of the var, not the var itself

15:03 rainerschuster: ssiderisyou have to use defn

15:03 raek: use "var quote": #'foo --> (var foo)

15:03 rainerschuster: (ssideris): you have to use defn

15:04 dnolen: is transactional programming actually easier, http://lambda-the-ultimate.org/node/4070

15:04 raek: (alter-var-root #'sq ...)

15:04 dnolen: interesting see the difference between subjective and objective results

15:05 raek: ,[(class conj) (class #'conj)]

15:05 clojurebot: [clojure.core$conj clojure.lang.Var]

15:05 ssideris: if i say:

15:05 (alter-var-root #'sq (fn [x] (do (print x) (sq x))))

15:06 I get: sq cannot be cast to java.lang.Number

15:06 hm

15:06 oh the redefinition is wrong

15:06 _fogus_: As an aside, I do believe that JoC has thrust "truthiness" into the programmer lexicon (with a tiny bit of help by Steven Colbert)

15:06 ssideris: or is it?

15:07 * _fogus_ forgot the ;-)

15:07 rainerschuster: (ssideris): you have to (defn sq [x] (* x x))

15:07 not def

15:07 ssideris: rainerschuster: I have, sorry the paste above was wrong

15:07 but I actually did

15:10 _fogus_: ssideris: The function to alter-var-root is applied to the value of the var to be altered. It's not a direct replacement

15:11 raek: (alter-var-root #'sq (constantly (fn [x] (do (print x) (sq x)))))

15:14 ssideris: raek: I'm not sure if it's just me, but that seems to produce a stack overflow when I call it with (sqr 4)!

15:14 sorry (sq 4)

15:14 _fogus_: sorry, I think I don't understand enough about vars at this stage

15:14 I'll go and read a bit more

15:18 _fogus_: ssideris: No worries. This could be a reference point http://gist.github.com/568890

15:29 raek: dear #clojure, which test style would you use? http://gist.github.com/568900

15:29 cemerick: definitely the latter

15:30 I only use are when the expression involved is significant

15:32 raek: the overlay functionality of clojure-test-mode works much better with the is form, too

15:33 is 2 - are 0

15:34 jave: I'm trying to use the contrib strint lib. it interpolates expressions inside a string but only works for literal strings. how is possible that it doesnt work for a expresion?

15:35 cemerick: jave: can you paste your code?

15:37 jave: (clojure.contrib.strint/<< (str "~(java.util.Date.)"))

15:38 cemerick: jave: right, it only takes a literal string as an argument. Why would that be a problem?

15:38 jave: I'm just trying to understand why only a literal works and not an expression

15:40 cemerick: That's just the way it's implemented. I suppose it could walk a provided expression and process all string literals as necessary, but that would be a different macro that used <<.

16:21 jcromartie: I wonder: what does a system developed in Clojure but tied to a SQL database look like?

16:22 I like Clojure's STM so much that I almost feel like the DB is unnecessary

16:22 but then I realize I'm being silly and smack myself

16:22 arohner: jcromartie: much like you would expect

16:23 jcromartie: we wont start seeing real interesting designs until clojure STM integrates with JXA

16:23 jcromartie: When Clojure and SQL gets together, I feel like Clojure loses.

16:23 hm

16:23 arohner: I have the wrong acronym

16:23 what I meant to say is the java distributed transaction API

16:27 jcromartie: JTA

16:27 ordnungswidrig: XA and STM, will it blend?

16:27 jcromartie: I guess I'm wondering where the need for a RDBMS really comes in

16:27 ordnungswidrig: I meand, STM is about optimistic concurrency, right?

16:28 jcromartie: if I am happy with all of my data in refs, and I can write them to the filesystem and load them back in

16:28 when do I need to "graduate" to a RDBMS

16:28 kencausey: when you start feeling pain?

16:29 The decision as to when that is is variable and up to you.

16:29 ordnungswidrig: jcromartie: any news on fs writes with the STM transactions?

16:29 kencausey: YAGNI applies here as well as elsewhere

16:29 ordnungswidrig: jcromartie: latest information I found was, that this is not quite possible at the moment

16:30 jcromartie: ordnungswidrig: I had some success with it when I tried

16:31 kencausey: not possible? awkward maybe, but it's not impossible

16:31 jcromartie: my approach had way too many writes going on

16:32 basically, for each commit to the STM, queue up an action on an agent to write out a temporary file with the contents of the ref and replace the main data file

16:32 so it was atomic

16:32 and it worke

16:32 worked

16:32 commits were written in order

16:32 but it often meant too many writes

16:33 if you altered the ref 100 times a second, you wrote out 100 files, which was insane with a big data set... it could barely keep up

16:33 so that's where it is :)

16:34 ordnungswidrig: did you write the whole data every time?

16:40 serabe: hi

16:42 i'm having problem translating to clojure a piece of java code, I'm writing an image library ala imagemagick but i cannot get to show the image in a JFrame

16:42 any help available?

16:42 kencausey: post the code, specify where exactly you are having trouble

16:42 serabe: doing that

16:42 sorry

16:42 kencausey: k

16:43 kumarshantanu: serabe: are u drawing onto the Graphics object?

16:43 serabe: the last commit pushed is here: http://github.com/Serabe/rinzelight/blob/master/src/rinzelight/display_image.clj

16:43 making a gist with current code after cleaning it up a bit

16:43 djwonk: I'm relatively new to the clojure community (studied with the HacDC study group last year). Had a couple basic questions about what tools that Mac developers like.

16:44 serabe: current code: http://gist.github.com/569061

16:44 kumarshantanu: yes

16:44 djwonk: 1. what java server do people like for local development (something easy to setup and configure)

16:44 kumarshantanu: serabe: does your java version fine?

16:45 serabe: kumarshantanu: can you rephrase, please?

16:45 kumarshantanu: serabe: **typo -- does the java version work fine?

16:46 serabe: yep, is part of rmagick4j actually

16:46 kumarshantanu: yep, is part of rmagick4j actually (forgot the nickname)

16:46 kumarshantanu: (comment blah) -- looks problematic

16:47 comment that block out using ;;

16:48 lancepantz: djwonk: do you mean what http server do we use?

16:48 serabe: kumarshantanu, complete java code here: http://github.com/Serabe/RMagick4J/blob/master/Magick4J/src/magick4j/MagickImage.java#L278

16:49 kumarshantanu, commenting with ;

16:49 djwonk: lancepantz: right, http server

16:49 lancepantz: djwonk: jetty is probably the most popular with clojure people

16:49 i use jetty6 personally

16:50 but i build everything as servlets (.war files), so they can deploy to any servlet container in production

16:50 djwonk: lancepantz: thanks

16:50 kumarshantanu: serabe: (comment ..) only suppresses the execution, but needs valid syntax of code being commented

16:50 djwonk: question #2. will i be able to get pretty far with textmate or should I embrace another editor now?

16:51 serabe: kumarshantanu, just tried it, i still get a blank jframe (executing code from gist)

16:51 chouser: djwonk: stick with what you're comfortable with

16:52 djwonk: if you later find yourself curious about a more powerful editor, consider switching instead of just adding time and effort to the one you started with.

16:52 kumarshantanu: serabe: are you calling display-fn to draw the image?

16:52 chouser: ...but until then, spend your mental energy on clojure, not on changing your editor. (MnsHO)

16:53 djwonk: chouser: good advice. i'm going to look over http://stackoverflow.com/questions/257333/clojure-editor-ide-recommendations-on-mac-os-x

16:54 serabe: kumarshantanu, yes, i do, here is the code: http://gist.github.com/569075

16:54 djwonk: last question. where are the best resources for finding out what clojure code is up-to-date, actively maintained, etc. I'm from the ruby world -- we have tools like ruby-toolbox.com and http://www.railsplugins.org/ -- anything like those for clojure?

16:56 kumarshantanu: serabe: do you want to wrap the .pack method with brackets in display-fn?

16:57 serabe: kumarshantanu, current version ( http://gist.github.com/569061 ) has them wrapped

16:59 ordnungswidrig: djwonk: most clojure stuff lies on github :)

17:00 djwonk: ordnungswidrig: thanks, i've found some stuff i want to checkout already!

17:01 serabe: kumarshantanu, is strange, because i can write an image correctly to disk

17:01 kumarshantanu: serabe: so, you are saying the BufferedImage is initialized correctly and you can write to the disk?

17:02 serabe: but the same image can't be rendered

17:02 serabe: kumarshantanu, yes

17:03 kumarshantanu, exactly

17:06 kumarshantanu: serabe: i can't see the clojure equivalent of the java threading code in the clj file

17:06 serabe: if (SwingUtilities.isEventDispatchThread()) {                runnable.run();            } else {                SwingUtilities.invokeAndWait(runnable);            }

17:07 serabe: kumarshantanu, i commented it out since it wasn't working, furthermore clojure seems to run it by itself, at least repl doesn't get stuck as in jruby without that code

17:09 kumarshantanu: serabe: does the paintComponent print "Hola" ?

17:09 serabe: yes, it does

17:09 uploading current code to github in a minute

17:11 kumarshantanu, pushed

17:11 kumarshantanu, i guess display-fn is now much clear

17:11 kumarshantanu: serabe: yes

17:13 serabe: I can see that you are disposing the graphics object as soon as you draw on it (unlike Java version) -- is that intentional?

17:14 serabe: kumarshantanu, it was just a (desperate) try

17:20 kumarshantanu: serabe: are you drawing onto the graphics object of the root pane in the Java version? I can see that in the java version you are only assigning a JComponent to the frame

17:21 serabe: kumarshantanu, just another desperate try

17:21 kumarshantanu: the root pane may not show anything if you have more layers on it

17:24 scottj: What's the easiest way to get prettier logging with c.c.logging (right now I get messages like Sep 7, 2010 5:20:54 PM clojure.contrib.logging$eval6686$impl_write_BANG___6689 invoke INFO: Checking email server)

17:25 and by pretty all I really mean is something w/o that ugly c.c.logging$eval..impl_write_BANG...invoke part

17:25 kumarshantanu: serabe: can you try painting on the frame itself? the default is content pane (these days)

17:26 serabe: kumarshantanu, in a minute, sorry

17:32 kumarshantanu, i can't

17:34 kumarshantanu: serabe: I meant (.getGraphics (.getContentPane frame))

17:34 serabe: kumarshantanu, yes, i did it

17:34 kumarshantanu: oh

17:36 nickik: Where do I have to copy the GAE SDK?

17:40 serabe: kumarshantanu, I'm very sorry

17:40 kumarshantanu, really, really sorry

17:41 kumarshantanu, really sorry for wasting your time

17:41 wait, what?

17:42 kumarshantanu, I've been using :img instead of :image

17:42 facepalm

17:42 kumarshantanu: serabe: lol...it's okay

17:43 serabe: kumarshantanu, thank you very much, rewriting old code

17:43 kumarshantanu: serabe: okay

17:49 serabe: kumarshantanu, it is working, thank you again

17:49 kumarshantanu: serabe: cool

18:19 bortreb: what does "default-repos does not exist" mean when wsing lein native-deps?

18:20 technomancy: bortreb: you need the latest version of native-deps. maybe 1.0.2?

18:21 bortreb: lein upgrade doesn't do that?

18:21 technomancy: it doesn't upgrade your plugins for you, no

18:27 bortreb: I guess I just completely don't understand how plugins work at all then

18:29 if a project.clj file works for me then it should work for anyone, right?

18:30 after doing lein deps to install the new native-deps plugin?

18:31 technomancy: not if the project.clj file contains (when-not (= "bortreb" (System/getProperty "user")) (throw (Exception. "dude!")))

18:31 anyway, there are always going to be edge cases where it won't, like if someone else has a old version of leiningen that has some bugs that have been fixed, or if someone has a user-level plugin installed that alters the behaviour of a given task.

18:32 bortreb: I see, but this http://wiki.github.com/ztellman/penumbra/getting-started which was supposedly tested should work without errors right?

18:32 it's extremely basic I think

18:33 serabe: g'night

18:42 dnolen: latest version of native-deps is 1.0.4, which is compatible with lein 1.3.0

18:42 bortreb: ^

18:43 update your project.clj

18:43 bortreb: isn't that unacceptable though? That updating leinengen should invalidate every project.clj out there?

18:44 technomancy: bortreb: native-deps uses leiningen internals that aren't part of its public API

18:45 but in the next release there will be an effort to make it clear what's part of the public API and what isn't

18:45 bortreb: oh so this is a case of native-deps breaking the rules

18:45 technomancy: well... more like there not really being any rules

18:46 let's just say native-deps helped point out the need for a clearly delineated public API.

18:48 bortreb: I find it ironic that I have to figure out a very convoluted network of dependencies involving old versions of leinengen to get my dependency management system to work

18:48 I bet that project.clj worked with leinengen 1.0.1 or whatever

18:50 why not have a :leinengen-version "1.0.1" or something required in every project.clj form now on

18:50 so that my project.clj can be correct now and in a thousand years form now

18:50 and truly capture every dependency

18:51 technomancy: bortreb: one step ahead of you: http://github.com/technomancy/leiningen/blob/master/src/leiningen/core.clj#L187

18:52 it's not required, but if you set it then everyone with an older version of lein will get a warning.

18:53 danlarkin: death from above! technomancy outsmarts the outsmarter

18:58 bortreb: by doing that you're assuming that every newer version of leinengen will be compatible with project.clj's from older versions which is a promise that is almost impossible to make

18:59 it's like using implicit mutable state instead of functions

18:59 technomancy: well having a :max-lein-version would be pretty silly, if that's what you mean.

19:00 bortreb: if that project.clj could say that it needs leinengen 1.0.1 and native-deps 1.0.0 because it works for sure with those programs then it would always work now and forever

19:02 leinengen let's you specify dependencies for everything except leinengen itself, but that's important too, to guarantee consistency

19:03 technomancy: it would be better to guarantee consistency by specifying a public API and requiring plugins to not use internal functions.

19:03 if you really feel strongly about it you could submit a patch for :max-lein-version, but I don't think anyone will use it.

19:04 bortreb: in a perfect world, every library would be written that way and we wouldn't need a dependency management system anyway because newer versions would never break anything

19:05 I want leinengen to be able to manage itself as a dependency actually

19:06 if you're up to leinengen 3.4.5 and I'm still using the 1.0.1 version, I want leinengen 3.4.5 to be able to download leinengen 1.0.1 like any other dependency and then use that to interpret my project.clj file

19:07 if you think that's silly, why? isn't it the exact same concept as specifying a earlier version of a library because it's tested and been proven to work?

19:08 technomancy: the only thing I said was silly was :max-lein-version; I think it's very unlikely anyone would use that key.

19:08 bortreb: definately

19:09 kumarshantanu: hi, is there a shorter form for (into (into [foo] [bar]) [baz]) ?

19:09 technomancy: I think handling itself as a versioned dependency would be a good idea if it weren't for the fact that the "java" launcher is a horrible hack that needs all kinds of boilerplate infrastructure (in lein's case in shell/.bat files) to get useful work done

19:09 bortreb: but a :lein-version key? I'd use it because it let's everyone have the exact same experience I had when I test using my project.

19:10 ah, so it's really hard to get right if it has to figure out how to piece itself together?

19:11 technomancy: right; you can't have one lein shell script that reads project.clj and *then* decides which version of lein to use because by the time lein can read project.clj it's too late; it's already chosen a version.

19:12 so you'd have to remember "oh, for this project I have to use lein-1.2, but for this I use lein-1.3", etc.

19:12 ssideris: how easy is it to do a parallel doseq when the different threads only need to read from a common place but never write back?

19:14 bortreb: if you had every version of lein already there in separate places, the current version of lein could just call the other version of lein on the project.clj file after deciding what version it really is

19:15 you'd pay the price of two jvm statrups for every operation if your lein version didn't match the declared version

19:16 and the convention that reads the lein-version key would have to never change ever, but that's the only thing that different versions of lein would have to promise

19:16 zztr: ssideris: is reading the question, or is parallelization the question?

19:17 ssideris: because clojure collections are immutable, reading really should not be a question

19:21 bortreb: yes, If you're interested, I might be able to actually implement something like that

19:21 what do you think?

19:24 scottj: does c.c.trace no longer show multiple levels? Old fib examples like http://learnclojure.blogspot.com/2010/02/slime-2009-10-31-user-defn-fib-n-if-n-2.html don't show multiple levels for me in 1.2

19:24 technomancy: bortreb: still on the fence; will need to think about it... why don't you post to the mailing list and get some discussion going?

19:26 bortreb: sure. I think the main argument for it is that it gets rid of one more piece of implicit state which is normally a good thing. Let's see what everyone else thinks

19:36 ssideris: zztr: sorry for the delay... the question is about the parallelization

19:37 partitioning the sequence and assigning the parts to different threads

20:10 zztr: ssideris: try this (dorun (pmap (fn [x] (println (.getName (Thread/currentThread)))) (range 9)))

20:25 ,(doall (pmap (fn [x] (.getName (java.lang.Thread/currentThread))) (range 9)))

20:25 clojurebot: ("pool-3-thread-934" "pool-3-thread-935" "pool-3-thread-934" "pool-3-thread-936" "pool-3-thread-934" "pool-3-thread-935" "pool-3-thread-937" "pool-3-thread-935" "pool-3-thread-934")

21:17 quizme: (def x {:a1 42 :a2 {:b1 420} } ) ; is there a short way to make a new map that replaces 420 with 421 ? ... kinda like x[:a1][:b1] += 1 ?

21:19 tomoj: ,(update-in {:a1 42 :a2 {:b1 420}} [:a2 :b1] inc)

21:19 clojurebot: {:a1 42, :a2 {:b1 421}}

21:20 quizme: oh cool

21:20 thanks

21:20 i'll try that

21:20 tomoj: there's also assoc-in

21:20 for when you want to just stick a new value in instead of applying a function

21:20 quizme: thank you.

21:21 cool

21:21 that's way shorter than what i was trying to do

21:21 thanks tomoj

21:21 i love you

21:21 tomoj: :)

22:53 bortreb: what's the right way to fix a typo in core? in deftype, it says, "One constructors will be defined," when it should be "One constructor"

23:23 bmh: When attempting to build my project, it explodes because it can't resolve lein-clojars 0.6 (which is specified as a dev-dependency). I can build my own jar for it, but then it dies when I run `lein push` because my project doesn't depend on com.jcraft/jsch

23:23 I should add that I'm using lein 1.2

23:52 scottj: it seems weird that for foo.bar.tar the testing name space created by clojure-test-mode would be foo.bar.test.tar

23:54 ahh, it must be thinking foo.bar. is a reverse domain, cause for foo.bar.tar.baz it creates foo.bar.test.tar is all

23:57 nm, I didn't realize cursor position mattered

23:58 wwmorgan: what are people using nowadays to launch a vimclojure nailgun server from leiningen?

Logging service provided by n01se.net