#clojure logs

2010-09-07

00:04thunk(with-db (init-db))
00:04thunkhaha
00:04thunkyeah.
00:05thunknm
00:22llaarrllanybody home?
00:26seancorfieldnot many ppl at 9pm pacific on a US public holiday :)
00:27seancorfieldactually it always amazes me how many ppl seem to be on this channel... over 200...
00:28llaarrllwow, its a holiday in the States?
00:28llaarrllIve been away for too long, it seems
00:28seancorfieldLabor Day - when folks do no labor...
00:28seancorfieldalthough i've been working like a dog all weekend... big site launch coming up this week :)
00:29llaarrllawesome
00:29llaarrllcongrats
00:29llaarrllmaybe you can help me
00:29llaarrllis there a way to evaluate an s-exp in a string
00:29llaarrllin ruby it'd be "whatever #{2+2}"
00:30llaarrllprinting as "whatever 4"
00:30wwmorgan,(doc format) ; <- llaarrll
00:30clojurebot"([fmt & args]); Formats a string using java.lang.String.format, see java.util.Formatter for format string syntax"
00:31seancorfieldi guess it must be possible... templating engines must do something like that...
00:31llaarrllyeah, actually, thats the goal
00:31llaarrllwriting a templating library for compojure
00:32llaarrllmost of the ones Ive seen simply allow you to generate HTML from clojure code...not too good for designers
00:32replacallaarrll: yeah, look at clojure.contrib.strint: http://clojure.github.com/clojure-contrib/strint-api.html
00:33llaarrllcool checking now
00:33replacathe feature in general is called "string interpolation"
00:33llaarrllahh
00:33llaarrllwow, strint is perfect
00:33seancorfieldi was just about to ask where the name strint came from - thanx!!
00:34seancorfieldjeez, clojure has so much stuff built-in... the library just keeps amazing me!
00:34replacanp
00:34seancorfieldok, time for dinner and TV... it's been a long work day :(
00:35llaarrllgood luck on the launch
03:17LauJensenGood morning team
03:19RaynesMorning teammate.
04:21neotykHi *
05:47neotykdoes anyone know how to make that happen? http://github.com/neotyk/http.async.client/blob/a45b5e4a68fc46f2832be4c9182eff4bd3a7c41e/src/http/async/client.clj#L43
05:55LauJensenneotyk: Im a little unsure what you're trying to do, is it like this? (defmacro with-doc [name doc] `(defn ~name ~doc [] nil))
06:03abrenkI'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?
06:03LauJensenabrenk: Could it be the reading that tripping you up ?
06:04abrenkLauJensen: no, i checked the just written out xml in a hex editor
06:05LauJensenchouser should be here in a couple of hours, he wrote the lib and would be aware of any bugs
06:06abrenkThanks, I'll fiddle around some more and keep idling here.
06:09neotykLauJensen: question was about do-template
06:10neotykI generate there GET,PUT,... as they I just convenience fns for user
06:10neotykbut are very similar to each other
06:10neotykthey diff in name,and method to be used
06:11neotykalso should diff in docstring
06:11neotykthough I have no idea how to do that with do-template
06:11LauJensenisnt it just a matter of iterating through those variations, calling defn with each of them ?
06:12neotykyes, it is
06:12neotykbut I can't generate a docstring for it
06:12LauJensenWhy not?
06:12neotykI've tried wrapping (defn .. in (let [
06:12neotykbut it didn't work
06:14LauJensen(doseq [[name docstring] [["GET" "A Getter"] ["PUT" "A putter"]]] (defn (symbol (str ~name "-" something)) ~docstring [args] ~@body)) ... ?
06:15hiredmanyou can't do that
06:16LauJensenyou wont allow it?
06:16hiredmanif that would work you would need to quote symbols passed to defn
06:16hiredman(defn 'foo …
06:18LauJensenSo they have to be passed directly from the arg list
06:27neotykI must be missing something obvious here
06:28neotykwhy (do-template [sym] (let [n (name sym)] (defn sym {:doc n} [a] a)) A B C) doesn't work in repl?
06:28neotykit says "Unable to resolve symbol: A in this context"
06:42lenwanyone else from South Africa here ?
06:57LauJensenda-loic: welcome :)
06:58da-loicLauJensen, thanks!
06:59RaynesLauJensen, da-loic: Wasn't that exchange a bit backwards?
07:00LauJensenRaynes: how so?
07:00Raynes"You're welcome." usually comes after "Thank you."
07:01da-loicRaynes, it was more a thank you for the welcome here
07:01RaynesOh, I see.
07:01RaynesIt looked as if you were thanking him for something.
07:01RaynesI mean, you know, something other than welcoming you.
07:01RaynesI digress.
07:02da-loicRaynes, you are right, it looked like an unordered list of events
07:02LauJensenhehe
07:02LauJensenda-loic: Raynes is from alabama, so Im guessing he's a little sleep deprived now?
07:03RaynesNot at all. I woke up at 12.
07:03Raynes12AM, that is.
07:03LauJensenSo you've completely reversed your internal clock now?
07:05RaynesI suppose.
08:01opqdonutafter upgrading from 1.1 to 1.2 I get a lot of reflection warnings from array operations
08:04Chousukearray ops give reflection warnings now?
08:04Chousukethey used not to.
08:04Chousukethey still did reflection though :P
08:08opqdonutah, that explains
08:09opqdonutcan i hint something as just an array?
08:09opqdonutto make alength not reflect, for instance
08:11ChousukeI think you can do ^objects
08:11LauJensenopqdonut: http://bestinclass.dk/index.clj/2010/03/functional-fluid-dynamics-in-clojure.html
08:11LauJensenRead the top, and the link to christophs blog if you like
08:13opqdonut^objects probably won't work on float[]
08:14LauJensenopqdonut: My approach can work with any primitive type you like
08:15opqdonutyeah, I see
09:08cemerickI've been working on a design for a new hosted/remote Clojure REPL impl. Your input very welcome. http://bit.ly/a1SRtU
09:09javeI 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?
09:09javeI already have the blob as a html file
09:11LauJensenjave: 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 :)
09:12javeLauJensen: 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?
09:13LauJensenI 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
09:21javeI think "strint" will be ok for my purposes here
09:39LauJensenOn the things I really love about my Clojure baked site, is that I can reboot the backend without any users being affected
09:45mrBlissLauJensen: read this? http://ceondo.com/ecte/2010/09/productivity-conkeror-instapaper-kindle (mentions your article)
09:46LauJensenmrBliss: Yea, whenever somebodies links me, I see it in the admin panel on Best In Class. Its da-loic who wrote it
09:46mcavLauJensen: are you running two servers and load balancing?
09:46mrBlissokay
09:47LauJensenmcav: 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
09:47mcavoh, cool.
09:50LauJensenyea, bestinclass is web scale :)
09:52LauJensencemerick: What was that piece of software again, that you used for screencasts, and is it available for Windows?
09:52cemerickYou mean what I've used in the past? Screenflow.
09:52cemerickNot sure if it's available on windows.
09:52LauJensenYea - You switched
09:52LauJensenhttp://vincesamios.com/internetmarketing/screenflow-on-windows-xp
09:54LauJensenYea - You switched?
09:57cemerickLauJensen: No, I still use the same thing
09:57LauJensenk
09:58LauJensencemerick: 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
09:59cemerickI didn't think you could run OS X in a VM at all
10:13LauJensencemerick: Camtasia looks like the closest match. Its 300$ and Screenflow is free right?
10:16cemerickLauJensen: No, screenflow's not free, but it's fairly inexpensive. Somewhere in the $50-$100 area, I think.
10:16LauJensenNice
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:39mrBlissmaybe this: http://github.com/technomancy/robert-hooke
10:40_fogus_mrBliss: That is a nice framework to build on, but not quite there
10:42naeuhowdy
10:42naeuhas anyone in here had any experience with the JVM's parallel garbage collector?
10:44karmazillanaeu: the default one?
10:44naeukarmazilla: I was under the assumption that the default GC wasn't parallel
10:45naeuso I've been considering: -XX:-UseParallelOldGC
10:46karmazillathe default uses multiple threads for the young generation (at least)
10:46naeukarmazilla: interesting, I didn't realise that
10:47naeukarmazilla: so do you know the difference between the default GC and the one you use with the option -XX:-UseParallelGC
10:48karmazillaI don't. But it should be googlable
10:48naeuYeah, that's what I'm up to now. It's just often more conducive to learning to speak to someone with prior knowledge :-)
10:50karmazillathe 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:52neotykI'm trying to solve this one for better half of a day, I just don't get it http://gist.github.com/568486
10:54javedoes 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:58neotyk_fogus_: I'm trying to generate those: http://github.com/neotyk/http.async.client/blob/a45b5e4a68fc46f2832be4c9182eff4bd3a7c41e/src/http/async/client.clj#L43
10:59neotykand 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:02neotyk_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:03neotyk_fogus_: do tell, how would you do that
11:04neotykprivate macro to generate those?
11:11_fogus_That would work
11:12Chousukeneotyk: can't you add a docstring parameter into the template?
11:13neotykChousuke: yes, but those doc strings same as fns will share a lot of structure
11:14Chousukewhat's the problem with (dotemplate [fn-name method docstring] ... {:doc docstring} ...)?
11:14mrBlisshow do you 'restart' the agents again after calling shutdown-agents?
11:14Chousukehm
11:14ChousukeI don't think there's any documented or supported way to do that.
11:15mrBlissa shame, now I'll have to rebuild my whole repl state (lot of work)
11:15Chousukehm
11:16Chousukereplace your repl function with something that records a transcript :)
11:16mrBlissit involved some time consuming operations
11:16ihodesstrangely, 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:17neotykChousuke: 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:17ihodesor should i just have (THEFUNC X) in the script
11:18Chousukeihodes: 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:18Chousukeneotyk: I see.
11:19Chousukeneotyk: and the defn macro doesn't evaluate the metadata map?
11:19neotykChousuke: I couldn't get it to do so
11:19ChousukeI suppose it doesn't then.
11:20neotykChousuke: should I go straight to clojure.core.clj and fix it ;-)
11:20dnolenihodes: 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:21ihodeschousuke: 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:22Chousuke_fogus_: there's no need to use autogensyms within unquoted forms
11:23_fogus_Chousuke: Habit
11:23Chousuke_fogus_: I suppose it's better than forgetting autogensyms entirely :)
11:24_fogus_Chousuke: Which is why I like that habit. ;-)
11:27neotyk_fogus_: thank you very much, this one I'll be able to maintain
11:38lypanovwhats current status on clojure in clojure / js clojure
11:38lypanovany movement on the later?
11:40chouserno change re: js clojure
11:41lypanovah... someone already posted wrt reactive programming on the mailing list
11:41lypanovhttp://groups.google.com/group/clojure/browse_thread/thread/8c9085e10c33bbb6
11:42chouserI'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:42lypanovon the strees?
11:43lypanovwhat sort of analysis out of interest?
11:43lypanovany type inference?
11:43chouserjust what clojure's compiler does now
11:44lypanovah the java -> clojure switch?
11:44chouserBut 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:45lypanovchouser: v offtopic. any ideas / goals when joy of will be final?
11:45chouserthat 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:46lypanovchouser: *nod*
11:46chouserlypanov: our part is essentially done -- waiting now on copyediting, production, etc. We have essentially no more visibility on that than you do.
11:46lypanovi should dig into gwt to see what sort of analysis they do to get the insane speed ups they pulled off
11:47chouserwe noticed amazon pushed the release back to the end of december -- we're hoping it's not actually going to be that late.
11:47lypanovwhat i'd actually like to do is a rewriting -> js jitter
11:47lypanovbut thats probably far too insane
11:48lypanovi have no idea how much static analysis can be done on common clojure code
11:49lypanovchouser: k. figured. will they make a final pdf before publish so people can verify the copy?
11:50chouserlypanov: not sure.
11:51chouserhehe. which ledge?
11:53apgwoz_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_fogus_I only needed a subset, but thought... Hey, why not just write a whole library!
11:54_fogus_:p
11:55apgwozi guess it does get pretty ugly to start doing `(def newthing (decorate oldthing))`
11:55pdki still never got the decorators idea when i read the explanations of it in python a few years ago
11:56pdkor how itd be useful, should prob go look at that again
11:57apgwozpdk: it's greatly useful in python for composing functions in interesting ways
11:57sleepynateholy exception stack when buildin'g contrib's maven package
11:57apgwozthey're a bit awkward to write though sometimes
11:57pdkyeah i kinda read about it before i knew about function composition sorta stuff
11:57pdkso maybe a case of me wearing the blub goggles then
11:58apgwozpdk: :)
12:06abrenkchouser: 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:06chouserhm.
12:07ihodesso 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:08abrenkthe legacy system i need to exchange data with only supports latin1. otherwise i'd switch to utf-8 in a heartbeat.
12:08mrBlissihodes: drop the brackets
12:08ihodesmrBliss: tried that
12:08chouserabrenk: right. I just pass that along to the xml Transformer.
12:09chouserI'll see what I can figure out.
12:12chouserabrenk: how are you capturing or writing out what emit produces?
12:13ihodesum…so I added some random thing at the end of the file and now it compiles. what the %(#%!?
12:13abrenkchouser: I read an existing file and replace nodes using xml-zip with "element" structs I assemble.
12:15chouserprobably moot anyway. I'm still getting encoding="UTF-8" in the xml declaration it prints.
12:15abrenkthe declaration is okay
12:17chouseryou're getting encoding="ISO-8859-1" ??
12:17abrenkI'm using clojure-contrib 1.2.0 by the way
12:17abrenkyeah
12:17chouser,(class (.newTransformer (javax.xml.transform.TransformerFactory/newInstance)))
12:17clojurebotcom.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl
12:18chouseroh dear. What do you get for that?
12:19abrenkI'll check.
12:19abrenkcom.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl
12:20chouserok
12:20chousernow I'm seeing the behavior you are.
12:20chouserwhich is different than what I was seeing with com.icl.saxon.IdentityTransformer
12:21abrenkI've added xerces 2.9.1 to my classpath but it doesn'
12:21abrenkt seem to be the current implementation
12:24chouserI can set the encoding to all manner of invalid things and it still gets dumped into the xml declaration without error. :-/
12:27abrenkand the document is still written in utf-8 i suppose
12:27chouserapparently. I'm concerned about the use of *out* possibly mucking with the encoding.
12:35abrenkright. *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:35chouserabrenk: ok, it looks like the encoding of the output stream is controlling.
12:36chouser(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:37chouserI'm getting good results across a couple transformer impls by specifying the same encoding to both emit and OutputStreamWriter.
12:38chouserit 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:39chouserwhile 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:40abrenkinteresting
12:41abrenkI'll try your with-open code instead of duck-streams' with-out-writer.
12:48abrenkSuccess! (binding [*default-encoding* "ISO-8859-1"] (with-out-writer ...)) works!
12:50abrenkchouser: Thanks so much! I was really stuck. Drinks are on me tonight! ;-)
12:51chouserwoohoo!
12:52chouserI wonder if emit could detect and complain if :encoding doesn't match the encoding of *out*
13:03abrenkemit would have to unwrap *out* until it finds the OutputStreamWriter and compare getEncoding to the one specified as an option I guess
13:49cemerick_fogus_: I'm having a helluva time finding it. I've definitely written defadvice before.
13:50BahmanHi all!
13:52KirinDave_fogus_: Hey.
13:52KirinDave_fogus_: Have you looked at the error kit stuff yet?
13:55nickikdoes it make sence to use hiccup and enlive? I testing out some webstuff and im not sure if that makes sence.
13:55LauJensennickik: 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:01KirinDave_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:03chouserKirinDave: differently than error-kit does?
14:04KirinDavechouser: So, I looked at ek.
14:04KirinDaveAnd it doesn't seem to actually provide arbitrary restarts?
14:04KirinDaveNested, anyways.
14:04chouserhm... I *thought* it did...
14:04chousernot that anybody uses that.
14:04KirinDavechouser: I never saw an example that did it the way I expected.
14:04KirinDaveOh I did.
14:04KirinDaveLet me look again.
14:05KirinDaveBecause I found myself really wanting it last wee.
14:05chouseroh, yeah? well, that's good anyway. :-)
14:05KirinDaveerr, week
14:05KirinDaveLast wee too, truth be told
14:05chousertoo much truth
14:06KirinDavechouser: I'm going to have to experiment.
14:06KirinDaveI suspect it's going to be a huge pain in the ass to get it just right.
14:06KirinDaveBut I think all the pieces are there to do real restart handling, it is just incredibly tedious .
14:11KirinDaveHum
14:11KirinDavechouser: 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:11KirinDavechouser: It's closer than I realized.
14:14chouserI've never used CL's condition system, so any failure is likely in my understanding.
14:14chouserI'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:15KirinDaveIt's sorta weird to have the default handler be on the object.
14:15KirinDaveAt least to my sensibilites
14:15KirinDaveSeems like a with-handler could specify a default handler.
14:16hiredmandunno if you've looked at clojure.contrib.condition, but I feel I should mention it
14:16KirinDavechouser: 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:16hiredmanit's even less of cl's condition system
14:16KirinDavechouser: Reminds me how much I want macros by example in clojure.
14:17hiredmanbut we use it at work
14:17KirinDavehiredman: That, I have seen. It's all good.
14:17KirinDaveIt's just really cool for interactive development to have a good condition/restart system.
14:17cemerickI've never grokked that, actually.
14:17KirinDaveIt's also really useful for unit testing.
14:18KirinDaveActually, check that. Condition/restart is the most amazing shit for unit testing.
14:18KirinDaveBecause you make your mocks explicit.
14:19cemerickI'm not sure I've ever mocked anything, ever.
14:19KirinDavecemerick: A good example is time.
14:19KirinDaveYou make a little (mock 'mock-name (lambda ...))
14:19KirinDaveWhich you can do with anything, really.
14:19KirinDaveBut condition-restart was a cool way to do it
14:20technomancycemerick: mocking is a fancy OO-land term for binding, afaict
14:20KirinDavetechnomancy: Sorta.
14:20cemericktechnomancy: right
14:20cemerickI actually don't often rebind functions either *shrug*
14:20KirinDavetechnomancy: It's not cool to rebind it, in my estimation tho.
14:21KirinDaveBut seriously, having a restart in a function that just says, "No, return this instead."
14:21KirinDaveThat's so amazing for interactive work and unit tests.
14:21_fogus_Isn't some of this meant to be addressed by scopes?
14:21KirinDaveDunno. Is it?
14:23KirinDaveYou're the one with the google juice on that one. ;)
14:28KirinDave_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:33KirinDaveIt's a good idea
14:33KirinDavebut it seems very static?
14:33KirinDaveLike, you must define them at method definition time.
14:34KirinDaveI 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:38KirinDave_fogus_: If only because you may not be able to know the exact cleanup.
14:38KirinDaveI mean, the scopes syntax is a good one.
14:38KirinDaveBut it could be implemented in terms of another thing easily.
14:39raekhrm, 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:41KirinDaveRight.
14:44_fogus_My whole impl of Trammel is built around that tiny little thing. :-)
14:50ssideriswhat's Trammel?
14:52ssiderisfound it...
14:56raeknevermind... updated clojure-mode to the latest version and it worked again :D
14:57raeknow, is there any preferred ordering:
14:58raek(is (= expected actual))
14:58raek- or -
14:58raek(is (= actual expected))
14:59ssiderisI'm looking at alter-var-root... I tried this:
14:59ssideris(def sq [x] (* x x))
14:59ssideris(alter-var-root sq (fn [x] (do (print x) (te x))))
14:59ssiderisbut it says that sq is not a var
15:00ssideriswhat am i missing?
15:02ssideris(i'm guessing the answer is "everything" :-D)
15:03raeka small detail: sq evaluates to the value of the var, not the var itself
15:03rainerschusterssiderisyou have to use defn
15:03raekuse "var quote": #'foo --> (var foo)
15:03rainerschuster(ssideris): you have to use defn
15:04dnolenis transactional programming actually easier, http://lambda-the-ultimate.org/node/4070
15:04raek(alter-var-root #'sq ...)
15:04dnoleninteresting see the difference between subjective and objective results
15:05raek,[(class conj) (class #'conj)]
15:05clojurebot[clojure.core$conj clojure.lang.Var]
15:05ssiderisif i say:
15:05ssideris(alter-var-root #'sq (fn [x] (do (print x) (sq x))))
15:06ssiderisI get: sq cannot be cast to java.lang.Number
15:06ssiderishm
15:06ssiderisoh 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:06ssiderisor is it?
15:07rainerschuster(ssideris): you have to (defn sq [x] (* x x))
15:07rainerschusternot def
15:07ssiderisrainerschuster: I have, sorry the paste above was wrong
15:07ssiderisbut 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:11raek(alter-var-root #'sq (constantly (fn [x] (do (print x) (sq x)))))
15:14ssiderisraek: 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:14ssiderissorry (sq 4)
15:14ssideris_fogus_: sorry, I think I don't understand enough about vars at this stage
15:14ssiderisI'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:29raekdear #clojure, which test style would you use? http://gist.github.com/568900
15:29cemerickdefinitely the latter
15:30cemerickI only use are when the expression involved is significant
15:32raekthe overlay functionality of clojure-test-mode works much better with the is form, too
15:33raekis 2 - are 0
15:34javeI'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:35cemerickjave: can you paste your code?
15:37jave(clojure.contrib.strint/<< (str "~(java.util.Date.)"))
15:38cemerickjave: right, it only takes a literal string as an argument. Why would that be a problem?
15:38javeI'm just trying to understand why only a literal works and not an expression
15:40cemerickThat'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:21jcromartieI wonder: what does a system developed in Clojure but tied to a SQL database look like?
16:22jcromartieI like Clojure's STM so much that I almost feel like the DB is unnecessary
16:22jcromartiebut then I realize I'm being silly and smack myself
16:22arohnerjcromartie: much like you would expect
16:23arohnerjcromartie: we wont start seeing real interesting designs until clojure STM integrates with JXA
16:23jcromartieWhen Clojure and SQL gets together, I feel like Clojure loses.
16:23jcromartiehm
16:23arohnerI have the wrong acronym
16:23arohnerwhat I meant to say is the java distributed transaction API
16:27jcromartieJTA
16:27ordnungswidrigXA and STM, will it blend?
16:27jcromartieI guess I'm wondering where the need for a RDBMS really comes in
16:27ordnungswidrigI meand, STM is about optimistic concurrency, right?
16:28jcromartieif I am happy with all of my data in refs, and I can write them to the filesystem and load them back in
16:28jcromartiewhen do I need to "graduate" to a RDBMS
16:28kencauseywhen you start feeling pain?
16:29kencauseyThe decision as to when that is is variable and up to you.
16:29ordnungswidrigjcromartie: any news on fs writes with the STM transactions?
16:29kencauseyYAGNI applies here as well as elsewhere
16:29ordnungswidrigjcromartie: latest information I found was, that this is not quite possible at the moment
16:30jcromartieordnungswidrig: I had some success with it when I tried
16:31kencauseynot possible? awkward maybe, but it's not impossible
16:31jcromartiemy approach had way too many writes going on
16:32jcromartiebasically, 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:32jcromartieso it was atomic
16:32jcromartieand it worke
16:32jcromartieworked
16:32jcromartiecommits were written in order
16:32jcromartiebut it often meant too many writes
16:33jcromartieif 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:33jcromartieso that's where it is :)
16:34ordnungswidrigdid you write the whole data every time?
16:40serabehi
16:42serabei'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:42serabeany help available?
16:42kencauseypost the code, specify where exactly you are having trouble
16:42serabedoing that
16:42serabesorry
16:42kencauseyk
16:43kumarshantanuserabe: are u drawing onto the Graphics object?
16:43serabethe last commit pushed is here: http://github.com/Serabe/rinzelight/blob/master/src/rinzelight/display_image.clj
16:43serabemaking a gist with current code after cleaning it up a bit
16:43djwonkI'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:44serabecurrent code: http://gist.github.com/569061
16:44serabekumarshantanu: yes
16:44djwonk1. what java server do people like for local development (something easy to setup and configure)
16:44kumarshantanuserabe: does your java version fine?
16:45serabekumarshantanu: can you rephrase, please?
16:45kumarshantanuserabe: **typo -- does the java version work fine?
16:46serabeyep, is part of rmagick4j actually
16:46serabekumarshantanu: yep, is part of rmagick4j actually (forgot the nickname)
16:46kumarshantanu(comment blah) -- looks problematic
16:47kumarshantanucomment that block out using ;;
16:48lancepantzdjwonk: do you mean what http server do we use?
16:48serabekumarshantanu, complete java code here: http://github.com/Serabe/RMagick4J/blob/master/Magick4J/src/magick4j/MagickImage.java#L278
16:49serabekumarshantanu, commenting with ;
16:49djwonklancepantz: right, http server
16:49lancepantzdjwonk: jetty is probably the most popular with clojure people
16:49lancepantzi use jetty6 personally
16:50lancepantzbut i build everything as servlets (.war files), so they can deploy to any servlet container in production
16:50djwonklancepantz: thanks
16:50kumarshantanuserabe: (comment ..) only suppresses the execution, but needs valid syntax of code being commented
16:50djwonkquestion #2. will i be able to get pretty far with textmate or should I embrace another editor now?
16:51serabekumarshantanu, just tried it, i still get a blank jframe (executing code from gist)
16:51chouserdjwonk: stick with what you're comfortable with
16:52chouserdjwonk: 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:52kumarshantanuserabe: are you calling display-fn to draw the image?
16:52chouser...but until then, spend your mental energy on clojure, not on changing your editor. (MnsHO)
16:53djwonkchouser: good advice. i'm going to look over http://stackoverflow.com/questions/257333/clojure-editor-ide-recommendations-on-mac-os-x
16:54serabekumarshantanu, yes, i do, here is the code: http://gist.github.com/569075
16:54djwonklast 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:56kumarshantanuserabe: do you want to wrap the .pack method with brackets in display-fn?
16:57serabekumarshantanu, current version ( http://gist.github.com/569061 ) has them wrapped
16:59ordnungswidrigdjwonk: most clojure stuff lies on github :)
17:00djwonkordnungswidrig: thanks, i've found some stuff i want to checkout already!
17:01serabekumarshantanu, is strange, because i can write an image correctly to disk
17:01kumarshantanuserabe: so, you are saying the BufferedImage is initialized correctly and you can write to the disk?
17:02kumarshantanuserabe: but the same image can't be rendered
17:02serabekumarshantanu, yes
17:03serabekumarshantanu, exactly
17:06kumarshantanuserabe: i can't see the clojure equivalent of the java threading code in the clj file
17:06kumarshantanuserabe: if (SwingUtilities.isEventDispatchThread()) {                runnable.run();            } else {                SwingUtilities.invokeAndWait(runnable);            }
17:07serabekumarshantanu, 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:09kumarshantanuserabe: does the paintComponent print "Hola" ?
17:09serabeyes, it does
17:09serabeuploading current code to github in a minute
17:11serabekumarshantanu, pushed
17:11serabekumarshantanu, i guess display-fn is now much clear
17:11kumarshantanuserabe: yes
17:13kumarshantanuserabe: I can see that you are disposing the graphics object as soon as you draw on it (unlike Java version) -- is that intentional?
17:14serabekumarshantanu, it was just a (desperate) try
17:20kumarshantanuserabe: 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:21serabekumarshantanu, just another desperate try
17:21kumarshantanuthe root pane may not show anything if you have more layers on it
17:24scottjWhat'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:25scottjand by pretty all I really mean is something w/o that ugly c.c.logging$eval..impl_write_BANG...invoke part
17:25kumarshantanuserabe: can you try painting on the frame itself? the default is content pane (these days)
17:26serabekumarshantanu, in a minute, sorry
17:32serabekumarshantanu, i can't
17:34kumarshantanuserabe: I meant (.getGraphics (.getContentPane frame))
17:34serabekumarshantanu, yes, i did it
17:34kumarshantanuoh
17:36nickikWhere do I have to copy the GAE SDK?
17:40serabekumarshantanu, I'm very sorry
17:40serabekumarshantanu, really, really sorry
17:41serabekumarshantanu, really sorry for wasting your time
17:41serabewait, what?
17:42serabekumarshantanu, I've been using :img instead of :image
17:42serabefacepalm
17:42kumarshantanuserabe: lol...it's okay
17:43serabekumarshantanu, thank you very much, rewriting old code
17:43kumarshantanuserabe: okay
17:49serabekumarshantanu, it is working, thank you again
17:49kumarshantanuserabe: cool
18:19bortrebwhat does "default-repos does not exist" mean when wsing lein native-deps?
18:20technomancybortreb: you need the latest version of native-deps. maybe 1.0.2?
18:21bortreblein upgrade doesn't do that?
18:21technomancyit doesn't upgrade your plugins for you, no
18:27bortrebI guess I just completely don't understand how plugins work at all then
18:29bortrebif a project.clj file works for me then it should work for anyone, right?
18:30bortrebafter doing lein deps to install the new native-deps plugin?
18:31technomancynot if the project.clj file contains (when-not (= "bortreb" (System/getProperty "user")) (throw (Exception. "dude!")))
18:31technomancyanyway, 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:32bortrebI see, but this http://wiki.github.com/ztellman/penumbra/getting-started which was supposedly tested should work without errors right?
18:32bortrebit's extremely basic I think
18:33serabeg'night
18:42dnolenlatest version of native-deps is 1.0.4, which is compatible with lein 1.3.0
18:42dnolenbortreb: ^
18:43dnolenupdate your project.clj
18:43bortrebisn't that unacceptable though? That updating leinengen should invalidate every project.clj out there?
18:44technomancybortreb: native-deps uses leiningen internals that aren't part of its public API
18:45technomancybut 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:45bortreboh so this is a case of native-deps breaking the rules
18:45technomancywell... more like there not really being any rules
18:46technomancylet's just say native-deps helped point out the need for a clearly delineated public API.
18:48bortrebI 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:48bortrebI bet that project.clj worked with leinengen 1.0.1 or whatever
18:50bortrebwhy not have a :leinengen-version "1.0.1" or something required in every project.clj form now on
18:50bortrebso that my project.clj can be correct now and in a thousand years form now
18:50bortreband truly capture every dependency
18:51technomancybortreb: one step ahead of you: http://github.com/technomancy/leiningen/blob/master/src/leiningen/core.clj#L187
18:52technomancyit's not required, but if you set it then everyone with an older version of lein will get a warning.
18:53danlarkindeath from above! technomancy outsmarts the outsmarter
18:58bortrebby 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:59bortrebit's like using implicit mutable state instead of functions
18:59technomancywell having a :max-lein-version would be pretty silly, if that's what you mean.
19:00bortrebif 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:02bortrebleinengen let's you specify dependencies for everything except leinengen itself, but that's important too, to guarantee consistency
19:03technomancyit would be better to guarantee consistency by specifying a public API and requiring plugins to not use internal functions.
19:03technomancyif 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:04bortrebin 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:05bortrebI want leinengen to be able to manage itself as a dependency actually
19:06bortrebif 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:07bortrebif 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:08technomancythe only thing I said was silly was :max-lein-version; I think it's very unlikely anyone would use that key.
19:08bortrebdefinately
19:09kumarshantanuhi, is there a shorter form for (into (into [foo] [bar]) [baz]) ?
19:09technomancyI 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:09bortrebbut 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:10bortrebah, so it's really hard to get right if it has to figure out how to piece itself together?
19:11technomancyright; 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:12technomancyso 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:12ssiderishow 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:14bortrebif 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:15bortrebyou'd pay the price of two jvm statrups for every operation if your lein version didn't match the declared version
19:16bortreband 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:16zztrssideris: is reading the question, or is parallelization the question?
19:17zztrssideris: because clojure collections are immutable, reading really should not be a question
19:21bortrebyes, If you're interested, I might be able to actually implement something like that
19:21bortrebwhat do you think?
19:24scottjdoes 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:24technomancybortreb: 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:26bortrebsure. 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:36ssideriszztr: sorry for the delay... the question is about the parallelization
19:37ssiderispartitioning the sequence and assigning the parts to different threads
20:10zztrssideris: try this (dorun (pmap (fn [x] (println (.getName (Thread/currentThread)))) (range 9)))
20:25zztr,(doall (pmap (fn [x] (.getName (java.lang.Thread/currentThread))) (range 9)))
20:25clojurebot("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:17quizme(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:19tomoj,(update-in {:a1 42 :a2 {:b1 420}} [:a2 :b1] inc)
21:19clojurebot{:a1 42, :a2 {:b1 421}}
21:20quizmeoh cool
21:20quizmethanks
21:20quizmei'll try that
21:20tomojthere's also assoc-in
21:20tomojfor when you want to just stick a new value in instead of applying a function
21:20quizmethank you.
21:21quizmecool
21:21quizmethat's way shorter than what i was trying to do
21:21quizmethanks tomoj
21:21quizmei love you
21:21tomoj:)
22:53bortrebwhat'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:23bmhWhen 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:23bmhI should add that I'm using lein 1.2
23:52scottjit seems weird that for foo.bar.tar the testing name space created by clojure-test-mode would be foo.bar.test.tar
23:54scottjahh, 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:57scottjnm, I didn't realize cursor position mattered
23:58wwmorganwhat are people using nowadays to launch a vimclojure nailgun server from leiningen?