#clojure logs

2010-10-05

01:51nathanmarzhey guys, is there a standard way to mark a clojure function as deprecated?
02:03scottjboth clojure and contrib do it with a map after doctring {:deprecated "version number"}
02:05scottjI don't know if that's actually used by clojure or any tools
02:22amalloyscottj: it's used by the API ref, anyway
02:38brehauthello
02:40amalloyhi brehaut
03:05ossarehhey, I'm running lein uberjar, and it's compiling my various clj files - however there is an ns that only becomes available at runtime and as a result the compiler complains that it cannot find the ns. Is this where you're expected to use ' ?
03:06ossarehi.e. 'runtime-ns/var
03:06ossareh?
03:53amalloyi've been poking around at rosettacode tonight; does anyone see an improvement to http://rosettacode.org/wiki/Probabilistic_choice#Clojure? i couldn't find a good way to do either (to-cdf) or (choose)
03:57neotykGood morning
03:57amalloymorning neotyk
03:59neotykIs there something sequence library that would allow me not to write it like here: http://gist.github.com/611192 ?
04:00amalloyneotyk: i think you can use destructuring for this
04:01neotykamalloy: where would it help?
04:02amalloyneotyk: the :or keyword does some magic
04:02amalloyi don't use it often, lemme play around with it to find out the right syntax
04:02neotykamalloy: :or is used when there is no valye provided, right?
04:03amalloyneotyk: sorry, i only sorta scanned your code. sounds like i didn't scan it well enough :)
04:03amalloywhat is it you're trying to do?
04:07neotykmap some properties
04:07neotyksay property :a tp :c
04:07neotyks/tp/to/
04:07sexpbot<neotyk> say property :a to :c
04:09amalloyyes, it's clear that you want to map some properties, but not clear what that means :P
04:09amalloyi guess i'll just run your code and see what it does
04:11neotykyou have props with "old.prop.name" and want to have it's value to "new.prop.name"
04:11neotykand make sure old code works
04:22LauJensenMorning all - I didn't know that America had Giraffes: http://i.imgur.com/nr2Fc.jpg
04:23hiredmanI have three
04:23LauJensen:)
04:24abrenkthree of those!? :-)
05:20esjthat one is three in one
05:32carkh(.toString ^java.net.URI (-> state :request :uri)) i get reflection warning there in 1.2
05:32carkhis it the way it should be ?
05:32carkhif i go (let [^java.net.URI uri (-> state :request :uri)] ..) no reflection warning
05:49raekcarkh: I think the metadata ends up on the (-> state :request :uri) list, which is removed by that macro
05:50raekI don't know if you can typehint arbitrary expressions
05:50carkhit used to be valid in 1.1
05:50carkhohwell i'll make do
05:50raekoh..
05:51carkhactually iirc you could even put type hints inside the -> form
05:52carkhi'll wait for america to wake up and see if i can get hold of a maintainer =P
05:53raek:)
06:53neotykat the end of this month there is a clojure conj, and there is 3rd clojure bday party
06:53neotykis there any milestone that is Clojure birth day?
08:33bartjPlease advise if this scenario requires agents or can be done with something better ?
08:33bartjI have 1M records and need to save them to a database. My idea is to break these into partitions of 500 each.
08:33bartjAnd call a function "save-database" on each partition of size 500.
08:33bartjThe thing is I would like to use agents - but, there is no shared/mutable state
08:33bartjin the above process. The reason I would like to use agents is to spawn
08:33bartjthreads for each save operation; so that they can happen parallely.
08:35chouserif they're all writing to the same database, can they really happen in parallel anyway?
08:35cemerickIndeed, that's going to IO-bound primarily.
08:36cemerickThough, there's no point in thinking about "partitioning". (dorun (pmap save-database 1-meeelion-records)) should do it.
08:36cemerickSort of a waste of 1M perfectly good futures. :-P
08:38chouserheh
08:41bartjchouser, yeah, you are right
08:42bartjI mean these are *new* records, so the database is not locking atleast the *record-level*
08:43bartj*atleast at the
08:43chouserbut is probably locking the table for append, right?
08:43cemerickjeez, I'd hope not
08:44bartjer, this is not a classic mySQL database
08:44bartjit's CouchDB
08:45cemerickbartj: in that case, your time is going to be dominated by writes on the couchdb side due to its durability guarantee. You want to use its bulk_docs api. Clutch supports it directly, FWIW. http://github.com/ashafa/clutch
08:46bartjoh yes, I am using the bulk_docs feature
08:46cemerickthat explains your desire to partition the records :-)
08:46bartjthough, it is actually the bulkCreateDocuments from the jcouchdb lib
08:47bartjok, re: the question -> there is no state here
08:47cemericksure, either way
08:48bartjand I want to start multiple threads...
08:48bartjso is agents the only way to go ?
08:48cemerickThreads are very low-level, and there's generally no reason to touch them in Clojure.
08:48chouseryou want one thread per batch?
08:48bartjmy train of thought is that:
08:49bartjI plan on calling an agent
08:49bartjchouser, yes
08:49bartjcemerick, er, I meant agents
08:49dnolenbartj: you might find this interesting
08:50dnolennot sure if agents are necessary if you just need to load 1M records as fast as possible, batching should do the trick
08:50dnolenIt didn't seem like you could get CouchDB to write much faster to disk, but if you find out different, I'd like to know
08:50dnolenbartj: http://dosync.posterous.com/stm-couchdb-and-pushing-5500-documentssecond
08:52bartjdnolen, yes, I am not sure if agents are necessary; that is the only way I know to spawn threads :)
08:53cemerickdnolen: IMO, not sure why refs are necessary there. An atom or a simple LinkedBlockingQueue would do the job. *shrug*
08:53dnolenbartj: I able to load about 1M tiny documents in about 3 minutes.
08:53dnolencemerick: yeah, I realized that later.
08:53cemerickbartj: agents don't spawn threads
08:53cemerickdnolen: just checking ;-)
08:53chousercemerick: I was looking at that. he's using the insert-queue to create the batches, not really as a work queue.
08:54bartjcemerick, yes you are right
08:54dnolencemerick: actually atom could work right, I need to check the count?
08:54chousercemerick: sometimes agents spawn threads
08:54dnolens/could/couldn't
08:54bartjcemerick, but, at the end of the day you have to "send" something to an agent
08:55cemerickchouser: same-same as .size() & .drain() on LBQ, no?
08:55bartjcemerick, which would definitely spawn a thread.
08:55chouserdnolen: you'd use the return value of 'swap!' to see if you're the one that took it up to 50
08:55bartj, (doc send-off)
08:55clojurebot"([a f & args]); Dispatch a potentially blocking action to an agent. Returns the agent immediately. Subsequently, in a separate thread, the state of the agent will be set to the value of: (apply action-fn state-of-agent args)"
08:55chousercemerick: maybe, but not sure that's easier.
08:55cemerickbartj: send-* *occupies* a thread, but doesn't necessarily allocate one. It's a critical distinction.
08:55dnolenchouser: but in the time to get to a flush couldn't another item have been added?
08:56chouserdnolen: oh, good point. it can be done, but with current atom api it'd be messy
08:56dnolenchouser: I'm actually learning Clojure! :D
08:56chouserthere's been talk of a 'swap!' fn that would return old and new values of the atom
08:57chouserdnolen: of course you are! that's some pretty clean code there, doing something that's actually useful.
08:57bartjcemerick, ok...then my question would be when does it get allocated ?
08:57chouserdnolen: anyway, if you had a swap+!, you could do something like...
08:58dnolenchouser: i've seen you mention something like this before on channel
08:58cemerickbartj: when using send-off, when there's no available threads in the associated threadpool (up to some limit, perhaps). But seriously, you shouldn't even think about it.
08:58cemerickThere's no way to reason about when send-off, future, etc actually allocate threads.
08:59bartjcemerick, thank you...but, my question is not related to the timing of "allocating a thread"
09:00bartjmy question is primarily: " do agents create a thread to change the state?"
09:00AWizzArdcemerick: iirc in earlier Clojure versions future every time created a new thread. Now it uses the same thread pool that agents use.
09:01chouser(let [[oldq] (swap+! insert-queue #(if (== 50 (count %)) [new-item] (conj % new-item)))] (when (== 50 (count oldq)) (send-off ...)))
09:01AWizzArdAnd send-off tries to take an agent out of the thread pool, and if none is available it creates a new thread.
09:01chouserbartj: you are right to notice you don't care about the agent's state and therefore have doubts as to whether they're the right mechanism
09:01AWizzArdDo I remember this correctly?
09:02cemerickAWizzArd: nope, you have it right
09:02chouserbartj: consider 'future' in such circumstances
09:03chouserbartj: or an Executor thread pool of your own
09:04chousercemerick: so I now have maven scratch projects for launching clojure 1.0, 1.1, 1.2 and master REPLs, all with my most happily customized options.
09:04cemerick1.0, even! :-)
09:04bartjthanks everyone!
09:05bartjeverytime I come here, it re-inforces my lack of knowledge :)
09:05chouserthey share a command-line history, optionally use pprint when available (from contrib for early versions, clojure.pprint later), prompt coloring, etc.
09:05cemerickchouser: nicely enough, the next rev of clojure-maven-plugin will add a <packaging>clojure</packaging> option, which will eliminate the need to bind the goals to build phases.
09:06chousercemerick: I haven't yet confirmed that a change in my own clojure proj will be picked up by the master repl, but based on the behavior I saw last night I think it's likely
09:06cemerickchouser: sounds like you have a good basis for packaging some clojure maven archetypes
09:06chouserI have no idea what that means. :-D
09:07cemerickThey're new project templates -- thousands of them out there for various languages, frameworks, types of applications, etc.
09:07chouserI would like to learn at some point how to have maven not spend several seconds deciding it doesn't need to compile and .java files, etc.
09:08cemerickhaving them in central would allow one to do something like `mvn archetype:create clojure-1.2` and get a baseline pom and project structure spit out to disk.
09:08chouseras for clojure and contrib building compilcations, I think the instructions in contrib that rhickey and I have been following may be unnecessarily complex.
09:08cemerickI'd definitely agree on that count.
09:09chousera lot of my logic is outside the pom, since I still mostly hurt myself when I try to change that.
09:09chouserthe distance between a maven feature's docs, it's source, and the xml to interact with it is so large as to cause vertigo
09:10cemerickaside from my work on the clojure-maven-plugin, I don't think I've ever looked at a plugin's source
09:10chouserwell, when the docs fail you...
09:11cemerickBut I'd heartily recommend using an editor with good tag completion + popup documentation for the same.
09:11chousercemerick: as soon as I find one of those with correct key bindings, I'll be all over it. :-)
09:12cemerickOuch. :-(
09:12chouserbut seriously, I wanted to get clojure:repl to run some clojure code before going to the prompt
09:13chouseror alternatively have my own phase/targe/whatever that ran my code instead of clojure-maven-plugin's idea of a repl
09:13cemerickchouser: You've no idea how your asceticism hurts you in that area :-)
09:14chouserI saw nothing in the plugin's rather sparse docs, though looking at it source code there were clearly options available.
09:14cemerickchouser: There's a <replScript> config option, that appears to be what you want.
09:14chouserare you saying if I had been using eclipse or something it would have prompted me with where I could instert replScript?
09:15cemerickYup -- I found <replScript> by putting my cursor inside of the <configuration> element and hitting Cmd-/ (my code-completion binding)
09:15chouseryeah, I found replScript in the source. ...took me another few minutes to learn that it belonged inside <configuration>, inside <plugin>
09:15chousersame for discovering <configuration>?
09:15cemerickchouser: heh, yeah
09:16chousersigh
09:16cemerickDude, it's eclipse, welcome to 2003 ;-)
09:16cemerickit even has vi bindings, IIRC
09:16chouserit's just rude
09:16chousercemerick: yeah, it does sorta.
09:16cemerickha
09:16chouserI may end up there yet
09:16cemerickme, eclipse, or xml?
09:17cemerickI've give you a little demo when we're at the conj
09:19chouseroh, I dunno. I guess the mindset that creates things like java and maven config files -- languages that are painful unless you use a large vertical stack of software to manipulate them even though that's not inherently necessary
09:19chouserjava the language
09:19abrenkchouser: building clojure-contrib with a custom clojure will be easier when stuartsierra applies my patch
09:19rrc7czchouser: but then how would large companies like BEA and IBM make money selling you tools to manage the complexity they create?
09:20chousercemerick: yeah, I'm hoping lpetit's demo will drive me over the edge.
09:20chouserrrc7cz: oh, stop pushing my buttons. :-)
09:20rrc7czchouser: recognize the genius ;-)
09:21rrc7czI recently attended a presentation by some IBM fellow on their WebSphere BPM tool. He showed us Hello World and it was like 200 lines of XML. Seriously.
09:21cemerickrrc7cz: of course, I've never paid anyone a dime for my eclipse or netbeans toolchains
09:22chouserrrc7cz: but think of the flexibility!
09:22Chousuke:D
09:22rrc7cz:-D indeed. Just make sure to clear your afternoon schedule because to run their Hello World you have to boot up WebSphere itself
09:22cemerickI've never grokked the minimalist bent of the hacker ethos, if I may phrase it as such.
09:22rrc7czcemerick: you haven't, but I bet any company running a J2EE stack has paid a bundle for their app server
09:23cemerickrrc7cz: well, we run tomcat *shrug*
09:23rrc7czcemerick: I "got it" when I switched from PHP to J2EE due to a job change. My first reaction to the config, compile-package-deploy-boot cycle was, "are you kidding me? people actually develop like this??"
09:24cemerickOSS has (for better or worse) trained us all to believe that software should be gratis
09:24rrc7czcemerick: for now you do :-) wait till you need JTA/distributed transactions, resource adapters, and the whole bloody lot
09:24cemerickrrc7cz: if your counterpoint to the JVM toolchains is PHP, you've lost me from the start
09:24chouserheh
09:25cemerickwe use couchdb on the backend, I can't imagine
09:25rrc7czcemerick: forget PHP the language and think about "dynamic scripting languages" You could replace it with Ruby, Python, whatever. The development style is the same
09:26rrc7czwhat I was trying to say was: change this line of code and refresh the page. Bam, it's done. I love it
09:26cemerickSuch things are fundamentally targeted at a category of problems that I'm entirely uninterested in. *shrug*
09:27cemerickEh, jetty and tomcat do the same dance. And a remote REPL beats 'em all. :-)
09:27chouserbut that's because of clojure
09:27rrc7czcemerick: agree on the REPL, that's why I'm in love with clj/scala/etc.
09:28cemerickchouser: Indeed, though JRebel is some serious magic too.
09:28cemerickor whatever they're calling it these days
09:28chouseryeah, though that does still require a round of javac each time, doesn't it?
09:28cemerickwait for it....
09:29cemerickchouser: if you're using any of their IDE plugins, it all happens in the background, including the "redeployment"
09:29chouser:-0
09:29chouserer
09:29chouser:-)
09:30rrc7czbut in practice the "redeployment" is of course slower than an interpreted language because you must compile + deploy. You can also run into problems blowing out the PermGen because you keep redeploying these class definitions but the old one never gets GC'd because it lives in PG
09:30rrc7czi guess my feeling is: you can _kinda_ get the same effect.. maybe 80% there
09:31cemerickrrc7cz: You're wrong on both points.
09:31cemerickJust FYI :-)
09:31rrc7czcemerick: try redeploying a WAR 100 times on a running Tomcat
09:31rrc7czdefault install, no jvm switches
09:31cemerickI presumed you were talking about JRebel as well.
09:31rrc7czoh, no, I don't know what that is
09:31chouserhave these people who spend their time adding the same features to multiple IDEs (via plugins) really not carved out some kind of common interface to code to?
09:32cemerick"no jvm switches" is a silly restriction
09:32rrc7czcemerick: probably, so okay: the switches just delay the problem
09:32cemerickchouser: you mean UI-wise and such?
09:32chouserno, not UI-wise
09:32cemerickrrc7cz: re: permgen? Hardly.
09:32rrc7czcemerick: you can bump up the PermGen space to delay the problem. I believe there are some PG sweeps you can enable, but I think each JVM implements them differently and they never solved the problem 100% for me
09:33chousersome programmatic interface that others can use, those of us for whom no IDE UI feels comfortable
09:33cemerickoh
09:34cemerickwell
09:34cemerickyou mean a cmdline interface to an IDE plugin?
09:34chouserI dunno. I guess. Or any other kind of common entrypoint.
09:35cemerickI've never heard of one. Some plugins do have APIs, insofar as they provide hooks for other plugins.
09:35cemerickchouser: I think you're a market approaching one in this area. :-)
09:36chouser:-(
09:36chouserso lonely
09:36cemerickchouser: the hive beckons to you
09:37chouserI *try* to conform, really I do! I know it's hard to believe...
09:37cemerickthat was a ;-)
09:38cemerickConformity carries a buck of connotations. "Power in numbers" is real, though.
09:38chouserI totally agree, which is why I'm not entirely joking
09:40chouserI'm constantly tempted to write replacement tools from scratch, and with constant vigilence manage to mostly overcome the urge (the occasional dabbling with gentoo, textjure, etc. notwithstanding)
09:41chouserbut there is also danger in the complacency of the mainstream
09:42cemerickTools without a community have vanishingly small benefits AFAICT.
09:42chouserA billion MS Foundation Class programmers can't be wrong!
09:42cemerickheh
09:42chousercemerick: my tools have communities, I promise.
09:42cemerickOf course, VS is a *marvel*, so that comment is slightly ironic. ;-)
09:43chouserjust because you're not in them doesn't mean they don't exist. :-)
09:43cemerickI was referring to the "write replacement tools" thing.
09:43chouseroh, right.
09:43chouserwell, the lure there of course is always that if you write a better one the community will form.
09:43cemerickwhew
09:43chouserthe siren song
09:44cemerickSeeing that sort of thing relatively close up with Clojure, the process holds zero appeal for me.
09:44chouserheh
09:44chouseryeah, that's a really good point
09:45cemerickI mean, what would it take to build up a tool with a community like vi or TextMate, or whatever.
09:45cemerickThat's a life's work, it seems.
09:46cemerickmodulo luck, of course
09:46chouserpart of why I try to resist such urges.
09:47chouserbut that leads me to prefer the most flexible tools with communities that most encourage hackery
09:47cemerickWhat we really need are more/better vertically-integrated tools, so that mundane BS like builds can be routine and we can focus on what we have useful/valuable expertise in.
09:47chouserwhich is like the antithesis of IDEs
09:48cemerickYeah, I can see that.
09:48cemerickI've always been (and always will be) behind the hackery curve though, so that's a ratrace I had to opt out of early.
09:48chouserI've never had valuable expertise
09:49cemerickI find that absurdly hard to believe.
09:50chouserno, seriously. This is really interesting -- I've never tried to understand my penchants in these regards
10:13AWizzArdI have a stream from which I want to read a string. I know that the string is one mio bytes long. Is there something like slurp which takes a limit of bytes to read?
10:17chouserAWizzArd: probably best is just use .read
10:18AWizzArdchouser: yes, I will probably essentially reimplement slurp, but for bytes.
10:18AWizzArdslowly filling up a byte array
10:18chouserwhy slowly?
10:19AWizzArdi.e: not simply (.read stream buffer 1000000)
10:19AWizzArdbut instead reading byte after byte
10:19chouserwhy?
10:19clojurebothttp://clojure.org/rationale
10:19chouserI mean, why not simply (.read stream buffer 1000000)?
10:19AWizzArdchouser: it is a GZIPInputStream. I tried to read a mio bytes from it. But it does not deliver that.
10:19chouserdoes it only fill partially?
10:20AWizzArdIn the first read it returned 390k bytes. In the second 528k and in the third read the remaining bytes.
10:20AWizzArdYes.
10:20AWizzArdProbably the algorithm of ungzipping needs a few stops in the middle.
10:20chouserok, it'd be best to ask for the remaining buffer size each time (rather than asking for only 1 more byte)
10:20AWizzArdyes, I can check how much is .available
10:20chouserI'd guess there's no code in clojure or contrib for a fixed-sized buffer like that
10:21AWizzArdright
10:21chouserjust .read and see what it returns
10:21AWizzArdAh yes, .read on the buffer and using its return value, and giving an offset
10:21chouseryes
10:22AWizzArd int read(byte[] b, int off, int len)
10:22AWizzArdyes yes, this sounds good
10:23chouserexactly. (loop [off 0] ... (recur (- 1000 off bytes-read)))
10:23chouserno wait
10:23chousernot that, but you'll get it. :-)
10:25AWizzArdyes yes, I am on it already
10:25AWizzArdbtw, there is an interesting design pattern here, for loop
10:25AWizzArdone of the vars in loop is initialized with an expression that also shows up in the recur call.
10:26AWizzArdFor slurp this is (.read r)
10:26chouseryes, that shows up in many languages
10:26chouseroften it can be refactored to only show up in the the recur
10:27AWizzArdIn my case it is (.read stream result offset remaining) in the loop declaration and the same thing with adjusted values in the recur
10:27chouserit shows up much less often in clojure because explicit loops are less common
10:27AWizzArdYes.
10:27AWizzArdI noticed this however quite a few times already.
10:27AWizzArdWhen using LOOP.
10:31chousercan you loop with the offset starting at 0 instead?
10:34AWizzArd(loop [offset 0, remaining len, n (.read stream result offset remaining)] ...) is what I have
10:34AWizzArdand it works great
10:34chouserbut requires repeating your .read code
10:34AWizzArdchouser: which is not that bad
10:35AWizzArddeserialization of a string of length one mio from a gzipped Store now takes just 10.22 msecs vs 6.8 msecs for a non gzipped :)
10:35AWizzArdfast beast :-)
10:35chousertrue, not bad.
10:36chouseranother option: (loop [off 0] (when (< off (count buf)) (let [newoff (.read r buf off (count buf))] (when (pos? newoff) (recur (+ off newoff))))))
10:36AWizzArdyes, my clojure (de)serialization lib is not drastically much slower than optimized pure java ones
10:37AWizzArdchouser: hmm yes, I could move the read into a let
10:37clojurebotWhy are you asking *him*
10:37AWizzArdinside the loop
10:38alexykis there a way to tell repl to print say 3 digits after the dot for floating-point numbers?
10:38chouserAWizzArd: but perhaps you're implication that a macro could help is correct
10:38alexykin the E notation
10:40AWizzArdchouser: well, for this case your ideas put me on the right track. I now just have one read, in a let as the first form inside the loop, and i only refresh the offset and remaining vars in a recur call. Works great and is a bit simpler.
10:40phenom_how many languages is too many to learn at once? :{
10:40alexykphenom_: 4
10:41chouseralexyk: yes, it's possible. gimme a sec
10:41alexykchouser: kk
10:41kryftHi, what book(s) or other Clojure resources would you recommend to a budding machine learning researcher with a fairly good grasp of imperative and OO programming (mostly with C++ and Python) and a basic understanding of functional programming (I've read some SICP and seen some of the Abel & Sussman lectures)?
10:41AWizzArdchouser: this strategy could be used for slurp too I think, resulting in a (loop [] (let [c (.read r)] ... (recur))
10:42kryftI know I can learn to churn out some kind of code with just about anything, but because I don't know what I don't know about lisp in general and Clojure in particular, I would like to make sure that I learn how to 'think in Clojure' from the get-go.
10:43chouserkryft: I more or less universally recommend the book http://joyofclojure.com/ for reasons that will quickly be obvious to you
10:43kryftchouser: :D
10:43chouser:-)
10:43kryftchouser: I thought your name looked familiar. :)
10:44alexykkryft: I recommend it too as an unbiased clojurer :)
10:44alexykand a machine learning researcher too... check out incanter.org if you haven't already
10:45kryftchouser: That's one of the books I've glanced at, and the free chapter did seem promising.
10:46kryftalexyk: Oh, wow, no I haven't. :)
10:46kryftI haven't actually started learning clojure yet, although I've thought about it for months.
10:46alexykkryft: then just peruse the code as you use it, it's the best practices and ML in one :)
10:48kryftalexyk: Wow, great. :)
10:48kryftalexyk: How mature is it?
10:49alexykkryft: I follow it for about a year, very cool, David Liebke is super-responsive and adds everything you need right there. It got contributions and is very alive; also David is a member of Clojure/core which is the most mature group of clojureres, not in terms of old age though :)
10:50kryftalexyk: Hehe. :)
10:51kryftalexyk: That sounds like a project I might want to add to myself once I hone my clojuration skills a bit. ;)
10:51AWizzArdchouser: loop can maybe extended to support bindings that are *not* part of the loop itself, but get expanded into a let. They will not be set via recur, but instead the form gets reevaled each time later.
10:52AWizzArdThat would free slurps loop from the double (.read r) and could in principle break this pattern.
10:53scottjfor ML http://github.com/bradford/infer is interesting too
10:53chouseralexyk: Clojure 1.2?
10:53alexykchouser: yep
10:54chousernot 1.3-something?
10:54alexykchouser: not on purpose, but if there's a need, why not :)
10:54chousernah
10:54chouseractually, just realized I didn't need to ask
10:56chouser(defmethod print-method Double [n w] (.write w (.format (java.text.DecimalFormat. "0.0##E0") n)))
10:57chouserbut that'll do scientific notation for *all* doubles, not just ones that would use it by default
10:57chouseralexyk: will that do? perhaps you can add an 'if' to fall back to (str n)
10:59alexykchouser: very nice! for now does the trick
10:59kryftchouser: When is the dead tree edition coming out, by the way?
10:59chouserkryft: The plan is December.
11:00alexykchouser: so (str n) was the default, so I can revert to that?
11:00chouseralexyk: yep
11:00kryftOo, I can get 35% off? I didn't think the book was expensive to begin with..
11:00alexykin Good Reader
11:01kryftalexyk: I'm going to get a Kindle (or something similar) once I recover from my current bicycle-purchase-induced poverty.
11:01alexykscottj: I thought flightcaster contributed to incanter, now see it's infer... did they split?
11:02esjkryft: i'm experiencing a joyful kindle induced poverty (not the device, but the books ...)
11:02alexykkryft: my Kindle DX lays idle for months after iPad arrived, and will probably be in niche use
11:02kryftalexyk: Want to sell it? ;)
11:03scottjalexyk: don't know, would guess always separate
11:03alexykkryft: although all the kindle books are now used in the kindle reader. Alas, it was a gift and thus I'll keep using it now that my wife grabs the iPad more and more. :)
11:04kryftParadigm-wise (coming to lisp from imperative languages), is there anything major that I should know about that Joy of Clojure doesn't touch on?
11:04alexykkryft: you can get a refurbished DX for $200+, that's what I do
11:04alexyk'd do :)
11:06kryftalexyk: Does amazon sell them directly?
11:06alexykkryft: yep
11:06alexykkryft: but I'd get the iPad, honetsly
11:06alexykyou can iSSH from it into a clojure box :)
11:06kryft:)
11:07kryftI think I'd rather have e-ink and battery life measured in weeks!
11:08alexykkryft: iPad is surprisingly sturdy in terms of battery, the whole day it lasts; and with all the interruptions of real life, e-ink is good for novels only :)
11:08scottjand so so pdf rendering and a short break on every keypress
11:08alexykplus, PDF on Kindle used to be abysmal, DX barely cut it
11:08alexykwhile iPad rocks
11:09alexykI now keep iPad with a PDF book on a stand next to Mac, no more command-tab awkwardness
11:09kryftalexyk: Abysmal how?
11:10alexykkryft: now easy resizing of small font; iPad is pinch or double-tab
11:10alexyktap
11:10alexyknot easy on the kindle at all
11:12alexykninjudd: wow completion in repl! cake rocks
11:13mabesalexyk: more completion than rlwrap provides?
11:13alexykmabes: rlwrap is from a predefined list?
11:14mabesalexyk: yes, and your history I think
11:14alexykmabes: didn't try history... but cake infers from the namespace for realz
11:15mabesalexyk: I see.. yeah, that is better than rlwrap then
11:15alexykjust hit tab! don't be afraid!
11:18alexykanybody driving to conj from the greater Boston area (~4 hour radius)?
11:18alexykor flying a private plane?
11:23alexykor sailing/rowing a boat down the coast?
11:23arkhis there a way to combine a when-let with cond ? i.e., have the conditional also bind stuff with a let and carry that into the expression paired with the conditional
11:23chouserwow, the code Java uses for default formatting of doubles is even hairier than I'd guessed. http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/sun/misc/FloatingDecimal.java#910
11:24chouserarkh: I've played with a custom cond-let a bit. Doesn't seem useful very often.
11:24alexykchouser: scary stuff!
11:26arkhchouser: it'd be useful now ; )
11:26arkhchouser: you have much more clojure experience so I'll take your word for it
11:27chouseralexyk: so this might be more comfortable: (defmethod print-method Double [n w] (let [s (str n)] (.write w (if (re-find #"E" s) (.format (java.text.DecimalFormat. "0.0##E0") n) s))))
11:30alexykchouser: ok. Although I find limiting mantissa very useful in all floats, being a former physicist. Seeing 20 decimal places in numeric examples makes me angry and sad, usually, and lamenting screen space :)
11:31chouserarkh: this seems to work, if you want to try it out: (defmacro cond-let [[sym] test expr & more] `(if-let [~sym ~test] ~expr ~(when more `(cond-let [~sym] ~@more))))
11:34arkhchouser: thank you - I owe you a beverage of your choice at clojure-conj
11:34chouserarkh: use it like (cond-let [x] test1 expr-that-uses-x-1 test2 expr-of-x-2)
11:34chouserarkh: woohoo!
11:34chouser:-)
11:34carkh(.toString ^java.net.URI (-> state :request :uri)) i get reflection warning there in 1.2
11:35carkhiirc this was not the case in 1.1
11:35kryftchouser: I read a few reviews, and it sounds like JoC is definitely the book I'm looking for. One of the reviews suggested that JoC expects the reader to know some clojure already; is that true?
11:36carkhif i go (let [^java.net.URI uri (-> state :request :uri)] (.toString uri)) no reflection warning
11:36carkhis that intended or a bug ?
11:38arkhkryft: after reading some of JoC, any expectation of clojure knowledge would become irrelevant after a few readings of the book (imho) If you get JoC, I don't think you'll be disappointed.
11:51quizmehow do you define a function during runtime?
11:52quizme(eval '(defn sq [x] (* x x ))) ?
11:52carkhyes, but if you need to do this, it means you're doing something wrong
11:54carkh(most of the time)
11:54quizmewell i'm just wondering how it would be done
11:54quizme(hopefully the right way)
11:56quizmethe book Practical Clojure doesn't mention eval, so I was kinda curious.
11:57carkhmy guess would be that's because it's almost always bad practice using it
11:57carkhi can't think of a use case
11:57carkha meaningfull one
11:57quizmewell
11:58quizmehow about the human mind
11:58carkhheh what about it ?
11:58quizmeto create a new idea is to create a new function that is able to transform one idea into another.
11:59quizmeyou don't have to model it like that
11:59quizmebut
11:59quizmeit seems natural to do so
11:59carkhright, you're taking the high level view
11:59carkhi think that pattern is emergent from very many little state machines (neurons)
12:01quizmei realized another weird thing about clojure
12:01carkhalso that's great thinking about the human mind, but ... at the end of the day, we're not programming such complex things in clojure =P
12:01quizmethat functions are usual defined as constants, rather than refs
12:02carkhfunction are defined (as constant if you will) then assigned to a var
12:02carkhin your example, sq is the var
12:02quizmeyeah
12:02carkh(fn [x] (* x x)) is the function
12:02quizmei think it would be cool use refs
12:03carkhwhy would you need a ref ? you're not going to need transactional access to it
12:03quizmebecause then you could group chunks of dependent functions into a transaction, so that you could update your system in real-time
12:03clojurebotfunctions are maps
12:03carkhah true
12:04carkhbut what of the live data
12:04quizmewhat about it ?
12:04carkhwhat i mean is : hot code swap is hard
12:05carkhthere are not only the functions, but the data upon which they work
12:05quizmeyeah
12:05quizmewell
12:05quizmelet's say it's voice data
12:05quizmeand you implement a new algorithm to process voices more efficiently
12:05quizmethen you could update your system while people were talking
12:06quizmeand people would suddenly notice the quality of their calls getting better.
12:06carkhright there are good reasons to want that, but i'm not sure clojure is the very best tool for that
12:06carkhi'm not sure the JVM is very good at that
12:07quizmei guess it depends on the problem domain.
12:07carkhlooks like you want to use erlang =P
12:07quizmewell i was just trying to make clojure cool like erlang
12:08quizmenot that erlang is cooler
12:08carkhi think they're very different languages both cool, but for different use cases
12:08quizmeyeah
12:09carkhfor your voice example, in clojure, i guess you would have to use some RTP proxy in front of your app, launch the updated version, then reroute to it
12:10quizmeoh my gosh what's an rtp proxy
12:11carkhwell you're talking about voice ... i guess the transport would be rtp =P
12:11carkhi don't know much about all that =)
12:12carkhanyways i have this customer, whith quite a few sub-customers all using the same application of mine, i would never dare hot updating that
12:13alexykcan you do lein repl from several sessions with the same JVM? cake repl apparently does it!
12:14technomancyalexyk: sure; lein repl starts a socket repl; just telnet in
12:14alexyktechnomancy: OK
12:15alexyktechnomancy: when cake fails to gets its own deps, I do lein deps, and the elder brother saves the day, begrudgingly :)
12:15technomancyheh
12:16toshibluehi all--newbie---just trying to do the string-calc kata- and having a lot of trouble running the tests. I have a feeling my 'add' code is not loading properly - getting the following error:
12:16toshiblueERROR in (add_with_empty_string) (core.clj:6)
12:16toshiblueexpected: (= 0 (add ""))
12:16toshiblue actual: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
12:16toshiblue
12:17alexyktechnomancy: how do you blink parens in lein repl?
12:17technomancyalexyk: M-x telnet followed by M-x show-paren-mode I guess
12:18technomancyit depends on the client
12:18alexyktechnomancy: I mean, lein repl just blinks parens in my shell (zsh)...
12:18technomancyI think that would need to be handled by rlwrap; I don't know how to enable that
12:20technomancy,(meta (fn not-so-anonymous []))
12:20clojurebotnil
12:20technomancythat, sir, is weak.
12:22quizmeis there another way to create a function during runtime besides using eval?.... you could write a function that generates functions..... any other (general) way (besides stuff like comp or partial)?
12:24carkhquizme: the usual way is to make closures
12:24carkhthen pass the closure to your call site function
12:25carkhyou surely know of the canonical example
12:25quizmecarkh: you mean using "fn" ?
12:25hugodIts probably come up before, but I can't find an answer: are their plans to get contrib into maven central?
12:25quizmecarkh what's the canonical example?
12:25carkh,(let [adder (fn [x] (fn [y] (+ x y)))] ((adder 3) 4))
12:25clojurebot7
12:26carkhin some way the form (adder 3) "compiles" a function
12:28quizmecarkh: ok. thanks.
12:29carkhthe example is very simple, but you could go wild on that principle
12:29hsuhtechnomancy: clojure-test-mode tells me i had 2 failures but highlights nothing... any idea ?
12:30technomancyhsuh: it's certainly not perfect. if you have a good repro case feel free to open a ticket.
12:30hsuhk
12:30technomancyI haven't really touched it much in over a year; it's due for a refactoring
12:36TakeVHow do you do something like "import java.awt.event.*" in clojure?
12:38chouserkryft: arkh's answer was good. Basically, we didn't have room to be a complete Clojure intro. If you've never done any Clojure or other lisp, the first chapter or two might be at a challenging, but once you've gotten that far we settle down a bit to dig into the meatier points we want to make.
12:38chousera challenging pace
12:38chouserTakeV: no globby imports in Clojure, sorry
12:39chouserTakeV: but you can (import '(java.awt.event Foo Bar Baz))
12:40TakeVchouser: Ah, alright. Thanks.
12:41TakeVHmm, is there a conscious design decision for the lack of global imports?
12:41chouseryes, I believe so.
12:41chouserI for one am grateful. :-)
12:41chouserit bugs me to not know where classes are coming from, what their full name is.
12:42TakeVI can see that. Though it does make it annoying to port certain java code into clojure.
12:42chouseryeah, but I just blame the Java code
12:42carkhhum is there some reason why recompiling defmethods still uses old methods ?
12:43chouserwhich doesn't speed the porting, but makes me feel a little better. :-)
12:43TakeV:P
12:43chousercarkh: not sure what you mean
12:44carkhi have this file where i define a frag multimethod, and 2 frag methods, i put some log statements but they wouldn't show, i had to restart the jvm
12:45carkhand now i removed the logging, but it still show =/
12:45carkhthe multimethod is used at compile time
12:45carkh(from another file)
12:45dakronetoshiblue, what's the source for 'add' look like?
12:45carkhand i recompile everything every time
12:48chousercarkh: I'm still not quite sure what you mean. I redefine using defmethod all the time and start using the new version right away
12:48chousercarkh: perhaps a minimal example that demonstrates the problem would be instructive
12:48carkhi do that all the time too ....but i updated to 1.2
12:48carkhmaybe swank acting up ?
12:49chouseralexyk: (defmethod print-method Double [n w] (let [s (str n)] (.write w (if (re-find #"E|\d{4,}" s) (.format (java.text.DecimalFormat. "0.0##E0") n) s))))
12:56carkhrestarting emacs and everything fixed it =/
12:58kryftchouser: Ok. I've had some scheme exposure (parts of SICP and quite a few of the Abelson-Sussman lectures), so I guess it shouldn't be too hard, especially with the many free (but not-too-meaty) tutorials available online.
12:58chouserkryft: I think you'll find we don't waste your time. :-)
12:59kryftchouser: I appreciate it. =)
13:01kryftchouser: I bought the book already. I noticed a couple of typos in the first chapter, but I assume the book is still being proofread?
13:01chouseryep, going through copyediting as we speak.
13:01chouseralso a final techincal-correctness review.
13:01kryftOh, one of them was actually corrected (cheif -> chief) in the version I just downloaded. I guess the freely available version was older.
13:02kryftOk.
13:03kryftAnyway, seems great overall. :)
13:03chouser:-) thanks. If you find anything worth commenting on beyond what copyediting is likely to catch, feel free to post on the Manning forum.
13:04chouserwe'll get one last shot at making changes before they go to press
13:04kryftOk. Will I have access to the final version of the ebook once the book is published?
13:04chouseryep
13:04kryftGreat.
13:22toshibluedakrone: I think I've got it....I've had a restart of my machine, swank, emacs since yesterday and that seems to have cleared whatever it was.....
13:22toshibluethanks
13:25grettkequestion for you emacs guys... do you use clojure mode with or without SLIME? I don't use slime... I'm too simple.
13:27mrBlissgrettke: look at this cheat sheet to see some of the handy functions you're missing out on: http://www.pchristensen.com/slimecommands.pdf
13:28grettkemrBliss: thanks
13:51raekgrettke: for me, interactive development is essensial. I can't imagine how I would code the way I do now without slime.
13:52raekinstead of having to switch to the repl, type (in-ns 'namespace-of-source-buffer) and paste the code, I simply press C-M-x
13:55raekI can't code without slime... I'm too simple. :-)
13:57grettkeraek: lol point taken!
13:58dnolenraek: are you the one that had those nice .emacs customizations for paredit and clojure-mode in the repl?
13:59grettkednolen: which ones? why are they nice?
13:59raekI use the the master branch of technomancy's clojure-mode
13:59kryftI can't live without vim(-like keybinding - I've considered emacs with vimpulse or whatever it was called)
14:00raekM-x customize-variable RET clojure-mode-use-backtracking-indent
14:00raekmakes defrecord and friends indent correctly
14:01raekas for paredit: this is the inly customization I have: http://gist.github.com/612010
14:03raekit makes paredit insert a matching closing culty bracket in the same way it does with with round and square ones
14:03raekdoesn't seem to work with the ELPA version of paredit though...
14:05alexykwhen do things start at clojure-conj on the 22nd, and when do they end on the 23rd?
14:07alexykthere seems to be no progarm yet on the site...
14:07kryftalexyk: Is that some kind of conference?
14:07alexykkryft: clojure-cong.org
14:07alexykconj.org
14:08alexyksorry for the typos :)
14:08alexykhttp://clojure-conj.org/information
14:08kryftAh. :)
14:10dnolengrettke: just getting rich lisp editing in the REPL
14:25bartj@future doesn't seem to give the output of the last statement in the function
14:25bartjtesting futures code here: http://pastebin.org/30656
14:25bartjI have given the actual output and the intended output
14:25cemerick,@(future 5)
14:25clojurebot5
14:30cemerickbartj: I get your expected output here
14:30cemerickoh, wait, no I don't
14:31cemerickbartj: You want (future (save batch))
14:31bartj:)
14:32bartj, (doc future)
14:32clojurebot"([& body]); Takes a body of expressions and yields a future object that will invoke the body in another thread, and will cache the result and return it on all subsequent calls to deref/@. If the computation has not yet finished, calls to deref/@ will block."
14:33bartjmakes sense
14:33bartjbut, I wonder why (future save batch) even compiled!
14:34cemerick,@(future 1 2 3 4 5 6)
14:34clojurebot6
14:35cemerickit takes any body of expressions, and evaluates them
14:35bartj,@(future blah1 blah2 blah3)
14:35clojurebotjava.lang.Exception: Unable to resolve symbol: blah1 in this context
14:36bartjcemerick, yes...but, I gave (future save batch)....and save isn't defined anywhere
14:36cemerickit is on line 3?
14:37bartjcemerick, sheepish grin
14:37bartjcemerick, thanks a lot
15:18fhdHi. I've asked about a shorter alternative to (require 'long.namespace) (ns long.namespace) yesterday, and I found one:
15:18fhd(require '[long.namespace :as n])
15:18fhd(n/some-function)
15:20fhdJust wanted to share in case someone wanted the same :) Bye
15:48LauJensenGood morning folk - Just got back from hearing Rich and Stu in Aarhus, DK :)
15:49ataggartThey're in Denmark?!
15:49jolywelcome back :) good talks?
15:49ataggartthat explains why they haven't applied my patch!
15:50kotarakataggart: haha. Applying patches is not a tradition in the clojure world.
15:51LauJensenjoly: Yea very good talks - I really get the sense that Rich knows what he's talking about when it comes to Clojure :)
15:51LauJensenAnd Stu was smoking
15:51LauJensenataggart: yea
15:54AWizzArdLauJensen: what did they say?
15:55AWizzArdAnd what was it that Stu was smoking? ;)
15:55LauJensenAWizzArd: Rich talked about 1.3, Statics, Equality and Pods (from questions in the audience, namely me). Stu talked about pitching Clojures OO features to OO addicts
15:56LauJensenCliff Click talked about the troubles of Concurrent programming on many levels, and some interesting solutions
15:56kotarakPfff.. conference attendees know more about Pods than the community itself. :/
15:56AWizzArdkotarak: not really :)
15:57AWizzArdAt least I am a user of them.
15:57AWizzArdI started using Cells only days after they were gisted.
15:57AWizzArdMaybe I am the only user so far.
15:57LauJensenkotarak: did I detect a little whine? :)
15:57jolyIs there a link for a Pods description? I've only heard the term a few times
15:57LauJensenYou have to attend more conference, OR conj labs
15:57kotarakLauJensen: indeed
15:58kotarakLauJensen: indeed a whine, I mean. Will wait for a EU conj.
15:58LauJensenYea dont hold your breath, I asked Rich about it, he said the numbers are vastly on the US side
15:58AWizzArdLauJensen: I would like a switch in the compiler which will try to make ^:static out of every function where possible
15:58LauJensenMan, he demoed the warn on reflection for statics, that stuff was crazy
15:59AWizzArdin what way crazy?
15:59LauJensen** Warning, your loop coerces to Object on var 'accumulation' on recur
15:59LauJensenExtremely accurate
15:59kotarakAh. My uber-loop. :)
15:59AWizzArdyes, good
15:59AWizzArdkotarak: today chouser and I discovered that loop could be improved
15:59LauJensenjoly: He's the description for Pods : http://www.assembla.com/wiki/show/clojure/Cells
16:00jolyLauJensen: cool, I'll check it out :)
16:00ataggartbut the logic is currently a little overconstrained
16:00kotarakAWizzArd: in which way?
16:00LauJensenataggart: in which way ?
16:00AWizzArdkotarak: there is sometimes a pattern in loop in which an expression shows up inside the bindings and in the recur
16:00AWizzArdfor example, see slurp
16:00AWizzArd(loop [c (.read r)] ... (recur (.read r)))
16:01ataggartyou can get WOR emessages that arg is byte when it is expected to be a long, so it boxes everything
16:01AWizzArdToday I stumbled upon this while I was implementing slurp-bytes
16:01nickik@kotarak the conffreaks guy takes for ever to upload that video
16:01AWizzArdyeah, LauJensen should not chat so much but instead better upload a few videos (:
16:02nickikmmmh?
16:02LauJensenAWizzArd: So whats the optimization of that pattern ?
16:03AWizzArdLauJensen: the trick is to move out the var outside of the loop, and put it into a let, directly under the loop
16:03AWizzArd(loop [] (let [c (.read r)] ... (recur))
16:04AWizzArdToday I had the same. I started off with (loop [offset 0, remaining len, n (.read buffer offset remaining)] ...
16:04ataggartExample of "over-constrained": IllegalArgumentException recur arg for primitive local: i is not matching primitive, had: byte, needed: long
16:04ataggartthat bytes aren't allowed to fit into a long is a bug imo
16:04LauJensenataggart: no auto promotion of any kind is possible with primitives
16:04AWizzArdin the recur I would have to have something such as: (recur (+ offset n) (- remaining n) (.read buffer (+ offset n) (- remaining n))
16:04ataggartit is possible
16:05ataggartjust not implemented
16:05LauJensenataggart: not according to Rich, he said so explicitly today
16:05kotarakAWizzArd: yo. Used that strategy before.
16:05AWizzArdthis means doubling the (+ offset n) thing, also for remaining
16:05AWizzArdkotarak: good
16:05AWizzArdWhat I did was moving the .read out of the loop and put it into a let, directly under the loop
16:05AWizzArdloop over let is the name of this design pattern
16:06ataggartWell, I submitted a patch that allows for full widening conversion of primitives
16:06AWizzArdnamed after its inventor, me :)
16:06LauJensenAWizzArd: Excuse me for asking, its been a long day, whats the gain in that ?
16:06AWizzArdanyway, there could be a loop2 that expands into the correct pattern, or a non-breaking extension to loop
16:06AWizzArdLauJensen: the gain is that the code becomes more readable and one can save to repeat things
16:07AWizzArdAs you see, i have a .read in my loop bindings *and* in the recur
16:07jolyLauJensen: don't need to repeat (.read r) in multiple places
16:07alexyktechnomancy: when I was asking about two lein repl against the same JVM, I mean, can you say lein repl in another shell while in the same directory as the original one and get another repl against the same JVM like cake?
16:07AWizzArdslurp is doing the same, it has (loop [c (.read r)] .. and (recur (.read r)))
16:07bmhIf I'm using a namespace and qualifying it 'as', what's the crumulent syntax for throwing an except in there?
16:08bmh(:use [clojure.contrib.io :as io :except spit]) didn't seem to do the trick
16:08AWizzArdI noticed that this pattern shows up from time to time when using loop. Now chouser and kotarak confirmed that they too stumbled upon this
16:08ataggartrequire goes :as, use goes with :only
16:08ataggartbmh: ^
16:08kotarakAWizzArd: I think the point is, that (.read r) is independent of the loop. So it doesn't need to be there.
16:08AWizzArdkotarak: yes
16:08bmhataggart: Thanks
16:09kotarakAlways be minimal.
16:09AWizzArdit’s just that it often is the first idea to put it into the loop
16:09hiredmanAWizzArd: in some cases you can replae with something like (take-while identity (repeatedly #(.read something)))
16:09AWizzArdand if one does not want to, one needs this loop-over-let-pattern
16:09AWizzArdhiredman: yes, it is often nicer when I can go without the loop and use a higher-level construct
16:11nickikhas anybody used lazytest?
16:12LauJensennickik: I think stuartsierra has :)
16:13nickik@LauJensen don't think he likes it :)
16:17nickikthis just dosn't work --> java -cp "src:test:classes:lib/*:lib/dev/*" lazytest.watch src test
16:27bartjI have triggered a bunch of "futures"
16:27bartjand I don't really care about the return val of those futures
16:28bartjbut, I want all of them to finish executing
16:28bartjone option is for me to do a: @future
16:28bartjcan I also do a call to (await)
16:29bartjor is await used only in the case of agents and should not be used for futures
16:35LauJensenawait is for agents
16:35LauJensenderef is for blocking until future returns
16:36freakazoidit's slightly scary that deref sometimes blocks
16:37LauJensenmakes sense though
16:37freakazoidhaving stuff in general that never blocks with some types and may block with other types is scary.
16:37freakazoidI like having functions/syntactic forms that I can just tell with my eyeballs will not block.
16:40tomojLauJensen: https://gist.github.com/d3efe42b44bb0385c69f
16:40tomojexamples of paredit-convolute-sexp usage
16:40tomojwhat do you think?
16:40LauJensenfreakazoid: if your eyeballs can tell a future from another ref type, you should be good to go
16:41LauJensentomoj: the video isnt playing :)
16:41dnolenLauJensen: future and promise
16:41tomojheh
16:41tomojI'm working on the video
16:41tomojhave to take notes on what to record
16:42LauJensentomoj: Its hard for me just to read, not knowing the functions individually, so I think I have to get par-edit going and tag along :)
16:42freakazoidLauJensen: your eyeballs can determine types in a dynamically typed language without having to look at every place a function is called from?
16:42LauJensenAlso, just looking at the conversion Im thinking, that'll take me 2 seconds to re-write with just standard emacs commands, how long does that sequence take you to hammer out?
16:43LauJensenfreakazoid: The semantantics for blocking/non-blocking are completely different
16:43tomojLauJensen: 2 seconds?
16:43tomojthat's why I posted it
16:43freakazoidLauJensen: I agree it's not a huge deal, since it's unlikely someone will pass in a future when you expect a ref
16:43tomojhow do you do the conversion?
16:44tomojin actuality I hardly ever use paredit-convolute-sexp
16:44LauJensenC-k C-n M-f^3 C-y something something
16:44LauJensen:)
16:44tomojand then you have to fix your parens?
16:44LauJensentomoj: but that only takes the last 0.1s
16:45tomojI'm just collecting facts
16:45LauJensenAnd I appreciate it. Im just telling you the reason for my hesitance. But if your screencast shows me that you're faster than me, Im switching to paredit, no doubt about it :)
16:46tomojdo you use rainbow mode or something like it
16:46tomojor just show-paren-mode?
16:46LauJensentomoj: just show-paren
16:46LauJensenI would never, ever, use rainbow parens :)
16:47LauJensenkotarak asked me, does clojure-mode have rainbow parens? I said no. But why? he asked. I said "because mostly its men who use it"
16:47LauJensenSo he stopped bragging about vim-clojure for a little while
16:48kotarak-.-
16:48kotarakLauJensen: you have to accept your feminin side. Geez...
16:49LauJensenhaha
16:49LauJensenSo un-kraut like
16:49tomojyou can change the colors so they're not rainbow :P
16:49tomojI just use show-paren-mode too though
16:49tomojbut I never have to balance
16:54tomojLauJensen: mind if I continue to ping you for comment?
16:54LauJensennot at all
16:54scottjtomoj: cool didn't know about convolute. it has a small bug though as at (foo (bar|)) with no space between r and ) it yields (bar(foo ))
16:57esjLauJensen: "...men who use it" LMAO.
16:57LauJensen:D
16:58LauJensenesj: Its all good fun, a couple of weeks from now kotarak will treat me to some roasted apples in the heart of Frankfurt, right old buddy? :D
16:59kotarakLauJensen: yup. :)
16:59esjLauJensen: I think you may be on the hook for some weissbier first
16:59kotarakesj: bleh. Weißbier. :( Äppelwoi!
17:00esjoh dear, if its anything like cider....
17:00lancepantzroasted apples eh? that sounds tasty
17:01kotarakesj: yeah. roughly. But cider has a sweet taste. Äppelwoi / Apfelwein is more sour.
17:01kotaraklancepantz: yup. :)
17:01lancepantzi need to go to europe
17:01LauJensenlancepantz: come to the next conj labs :)
17:01lancepantzi wonder if i could get work to pay for it :P
17:02esjlancepantz: yeah - roast apfels. No rainbows, though.
17:02LauJensenlancepantz: If you cant, give me their phone # and I'll talk to them
17:02LauJensenIts a sensible investment
17:03lancepantzi can just see the expense report $1,500 -- roasted apples
17:03LauJensenhehe, then you KNOW that kotarak was involved
17:04lancepantz:P
17:04LauJensen$1,500 roasted apples in funny colors
17:04kotarakBut tasty!
17:04LauJensenI wish I could talk about some famous danish meal, but we have no tradition for food :)
17:05esjkotarak: you gotta tell me how to roast these apples, i've got hundreds in my garden right now, and there's only so much apple pie 1 man can eat.
17:05lancepantzoh man, i used to have plumb three in my 2m x 4m yard
17:06lancepantzduring plumb season i couldn't even throw them away fast enough
17:06LauJensenesj: haha
17:06lancepantzi ended up bags full of them in the freezer
17:06LauJensenlancepantz: you should make smoothies
17:06lancepantzthe best was sangria :)
17:07kotarakesj: you can get some ideas here: http://bit.ly/96QcNb
17:07esjSangria !
17:07lancepantzbest i've ever had
17:07kotarakAlthough the english translation looses a bit in details
17:07esjhmmm..... that's german.
17:07esji think i can speak german when very drunk
17:07esjbut am assured by all those who can, that I am mistaken
17:08esjkotarak: all the recipes my anglo-google know for roasting apples seem to include a duck as well.... can't be correct.
17:08LauJensenesj: nobody can master german, not even german people
17:09LauJensenIn 'high school' I had a german guy do my homework for me, he failed a least one of my papers
17:09LauJensen(german homework, that is)
17:09esjLauJensen: yeah, I can do dutch, and when drunk the hamming distance to german seems less
17:09kotarakesj: there is also an english translation in there. (in red) But it really is much less details :/
17:10esjkotarak: I'm going to get to the bottom of this !
17:15bartjkotarak, if it means anything, I use vimclojure
17:16bartjLauJensen, thanks for the clarification re: futures
17:16LauJensennp
17:17kotarakbartj: nice. I hope you find it useful.
17:19bartjkotarak, I think it doesn't add the closing parenthesis like paredit - which has been my biggest gripe
17:20kotarakbartj: It doesn't. There are a plethora of plugins like autoclose and friends. There is no real need for vimclojure to provide that. Although the "close inner form" functionality is on my radar.
17:21bartjkotarak, would you consider doing a screen-cast / tutorial of how your vim + clojure setup looks like ?
17:22bartjkotarak, the way LauJensen did with his emacs setup ? Clojure users who use vim would love it.
17:23bartjkotarak, which plugin do *you* use for auto closing parens ?
17:43lypanovimagine a hypothetical situation, you lose your job, and want to do something useful for clojure within a 1-2 month period.
17:44lypanovso, what should i do? :P
17:44technomancylypanov: that happened to me
17:44technomancyI wrote the Clojure PeepCode that month. =)
17:45lypanovtechnomancy: +1
17:46lypanovup to now i'm debating: playing with getting a prototype clj -> js translator working for a minimal subset to learn more about how that might be done in the future
17:46lypanov: getting clojure running on top of llvm.
17:46lypanovor um... playing with some sort of pallet based thing.
17:47freakazoidhow about writing a MOO?
17:47lypanovfreakazoid: a game hater is probably not the best person for that hehe
17:48maaclastoddard: Did you ever get anywhere with org-babel-clojure
17:48freakazoidMost MOOs were social
17:48freakazoidand I just meant the platform
17:48lypanovhehe
17:49lypanovfreakazoid: i would like to make a clojure / websocket based wave client.
17:49lypanovhugod: i'd like to make a self healing thing.
17:49freakazoidgoogle wave? isn't google abandoning that?
17:59jjidoI am thinking of using metadata to hold type-related information
17:59lypanovfreakazoid: google maybe. but the idea rocks.
18:00jjidodoes metadata get lost when passing a variable around?
18:01jjidoand using assoc or merge on a record
18:03freakazoidlypanov: I agree. Google just didn't seem to have a coherent vision around it.
18:04duck1123the emacs wave client has some clojure in it, but the maintainer gave up when google did
18:05freakazoidhard to blame them
18:05freakazoid(the maintainer)
18:05duck1123well, it had some clojure, it appears to be all emacs lisp now
18:06freakazoidHow did it run the clojure bits? It depended on your having a JVM?
18:06dnolenjjido: using metadata for type info is supported
18:06dnolen,(type (with-meta {:foo 'bar} {:type ::my-type}))
18:06clojurebot:sandbox/my-type
18:07dnolenjjido: metadata is sticky
18:08jjidodnolen: I can put whatever I want there right? and if I put a keyword type makes it into a variable?
18:09dnolenjjido: not it's just a namespaced keyword not a variable, but you can put whatever you want there in the metadata map
18:11kotarakbartj I don't use auto-closing. I personally find it more annoying than helpful. Hitting the closing paren repeatable is good enough for me.
18:11jjido,(type (with-meta {:foo 'baz} {:type :last}))
18:11clojurebot:last
18:17jjidois it costly if I put a large record in there?
18:18dnolenjjido: dunno, but with a profiler you'll be able to easily see if that's a problem
19:28tomojis there an asynch-io based DataInputStream?
20:00amalloytomoj: java.nio has it. i'm not sure if there's a clojure wrapper
20:02amalloyhttp://download.oracle.com/javase/6/docs/api/java/nio/package-summary.htm - it uses "Buffers" and "Channels" instead of streams, since the stream interface is blocking
20:04tomojrigh
20:04tomojshoot
20:04tomojaleph wraps it some
20:04tomojbut I'm not sure if in the right ways
20:04hiredmanuh
20:04tomojI wasted all this time writing to DataInputStream
20:04hiredmanא wraps netty
20:04hiredmanwhich is not the same thing as nio
20:06tomojhiredman: ok
20:06tomojdoes netty wrap nio?
20:06tomoj"nio" is ambiguous between java.nio and some kind of class of software which includes java.nio and netty?
20:07hiredmannio is java.nio
20:08hiredmannetty maybe be built on nio
20:08tomoj"Netty - the Java NIO Client Server Socket Framework"
20:08tomojok
20:08tomojso aleph maybe wraps it indirectly
20:08hiredmanthere are also nio "replacements" like xnio and things that correspond to netty for those
20:09tomojah
20:09tomojI will stick with netty for aleph
20:10ossarehhey, I need to look up a var def'ed in a namespace that doesn't exist at compilation time. How can I get around that?
20:11ossarehor, more accurately, how can I tell the compiler to not try to eval it until runtime? lein uberjar is compiling all the files and it dies when looking up that var.
20:12technomancy,(doc ns-resolve)
20:12clojurebot"([ns sym]); Returns the var or Class to which a symbol will be resolved in the namespace, else nil. Note that if the symbol is fully qualified, the var/Class to which it resolves need not be present in the namespace."
20:12ossarehthanks phil!
20:12technomancysure thing
20:13tomojooh, that is nifty
20:13tomojI never thought about it before
20:13ossarehits how I'm achieving per jvm conf files for various clients
20:14tomojinteresting idea
20:15tomojhow do you pass the ns/var to use when loading the conf?
20:16ztellmantomoj: what are you trying to do with nio?
20:17tomojimplement a proprietary tcp protocol
20:18ztellmantomoj: well, I'd hope that aleph could do whatever you need
20:18tomojthat data is like <packet-1-byte><..DataOutputStream style fields determined by packet-1-byte><packet-2-byte><....>
20:18tomojyes
20:18tomojme too
20:18ztellmanif not, please let me know
20:19tomojunfortunately I don't understand it yet
20:19ossarehtomoj: does it have to be nio? I found blocking to a) be easier to prototype with, and b) perform better is a very important set of circumstance (i.e. not thousands of connections)
20:19tomojhmm
20:20ossarehsounds like you're at some degree of investigation stage, I'd definitely work using blocking first
20:20tomojaleph is just so cool that I want to use it
20:20ossarehhaha =) fair enough!
20:20tomojI wrote a blocking parser already
20:20tomojbut no server implementation
20:20ztellmanha
20:20ztellmantomoj: what do you mean no server implementation?
20:20tomojI mean, I can read logs of the tcp data going between server and client
20:20tomojbut I cannot be a server or client yet
20:20ztellmanah
20:20tomojjust a proxy
20:21ossarehtomoj: the ns is loaded via (load-script "./config") which reads the file - important thing for me is that the file is outside of the jar.
20:21tomojah, hmm
20:21tomojI was just thinking about that
20:21tomojI was thinking you might specify a config file when building
20:21tomojbut outside of the jar would be nice for chef
20:22ossarehyeah, exactly
20:22ztellmantomoj: hopefully the wiki will give you some idea of how aleph is meant to be used
20:22tomojyeah, just need to reread it. eventually I hope I'll achieve enlightenment after reading through the wiki?
20:22ztellmanif not, send any questions you have to the mailing list
20:23ztellmantomoj: if there are things that are confusing after you've read through it, let me know what they are
20:23tomojI'm just dumb
20:23ztellmanthe wiki's nowhere near as good as I'd like it to be
20:24ztellmanunderstanding how you're confused will help me make it better
20:24tomojoh, great
20:24tomojI was confused about how to use a tcp-client
20:24tomojnow I see the wiki explains
20:24ztellmanyeah, that's a recent addition
20:24tomoj:D
20:24ztellmanlike I said, the documentation is a work in progress
20:25tomojI quite like the documentation made so far
20:25ossarehtechnomancy: quick question for you, is there some way I can switch on debugging or something in lein - it takes about 4 minutes to copy 12 jar files when doing uberjar - it reports that the files are going into lib/dev and the files that are in there... are not 4 minutes worth of copying.
20:25tomojare pods or cells relevant to aleph?
20:25tomoj(both are mysteries to me)
20:25ztellmannot especially, I think
20:26tomojwell, as there seem to be no huge performance difficulties with the way aleph is now, great
20:26ztellmanas far as I understand them, pods are about making things immutable even when dealing with mutable data structures
20:27ztellmanaleph is all about side effects
20:27ztellmananyways, I've got to run
20:27tomojthanks for the help
20:27ztellmanbut don't be shy about questions
20:28ztellmanthey really do help me
20:29tomojI think documentation writers should make it a habit to put use:only/require statements at the top of introductory examples
20:30hiredmanit's a problem in the java comunity too, examples always leave out the imports
20:30tomojI end up digging into project's sources over and over to remember where the functions are
20:30tomojyeah
20:30tomojand no .* in imports, dammit
20:30tomojin examples
20:30ossarehwhats the beef with .*?
20:30tomoj(analogously no :use without :only)
20:30moogatronictomoj: I run into this problem with ever new language i'm learning as well. =)
20:31tomojossareh: I'm looking at the example in which several functions are used. I want some of them
20:31ossarehi understand from a clj pov
20:31ossarehI didn't from a java pov
20:31tomojwith .* it's the same
20:31tomojjust classes instead of functions
20:31tomojand packages instead of namespaces
20:31tomojif it's only one .*, that's not so bad
20:31tomojbut if it's more than one, you have to guess or look up which package a class comes from
20:32ossarehah, right - I see your angle now.
20:32tomojI just want to know by looking at the readme so I don't have to mine down to ~/code/clojure/xxx/src/main/java/com/yyyy/foo/bar/
20:33tomojbut hey, ambiguous examples are better than no examples
20:34technomancyossareh: no debugging hooks exist right now unfortunately.
20:34technomancyif you can make the project.clj public you could open an issue on it
20:34technomancyor if you can repro on a project.clj that you can paste somewhere public
20:35ossarehI think I can do one of those for sure
20:35ossarehthanks!
20:35technomancysure; I'll see what I can do
20:36ossarehI'm gearing up to write a hook soon - excited :->
20:42tomojI am thinking of building a dsl which compiles to a dsl, am I crazy?
20:42jcromartieyes
20:42tomojthink of thrift
20:43tomojwell, maybe not
20:43tomojI was thinking of writing a language you'd use to write things like thrift clients/servers
20:43tomojbut not necessarily thrift, could be other binary formats
20:43ossarehyou mean like protobuf?
20:43tomojcould be protobuf too
20:44tomojyou'd use this language to write implementations of protobuf, thrift, whatever in clojure
20:44ossarehsounds meta++
20:44tomojand whatever the format, they all share some protocols
20:44tomojwhich let you use them in e.g. aleph
20:45tomojcrazy, eh
20:53KirinDaveDoes anyone know how to make slime's complete-symbol more namespace-aware?
20:53tomojwhat is missing?
20:54KirinDaveIt's not completing symbols from outside the current namespace?
20:54tomojyou mean like "bar/ba|" TAB completes to bar/baz?
20:54KirinDaveIt doesn't, for me.
20:54tomojright
20:54KirinDaveBut also, uses from other namespaces
20:54KirinDaveLike I have a .syntax namespace that holds the macros
20:55tomojI definitely get completion on uses from other namespaces
20:55KirinDaveI currently don't.
20:55tomojdid you load the file?
20:56tomojdoes the file's ns declaration have an ns docstring?
20:56KirinDaveNo.
20:56tomojto which?
20:56tomojyou must load the file
21:01tomojhow does leiningen insert <git> and tag info into the pom?
21:01tomoj"Your branch is behind 'origin/master' by 258 commits, and can be fast-forwarded."
21:04KirinDavetomoj: I did load the file.
21:05KirinDavetomoj: I can get completion to work on the repl, but not in the buffers.
21:05technomancytomoj: it does a partial parse of .git/config; see src/leiningen/util/maven.clj
21:05tomojKirinDave: C-h k the key you're using to complete
21:05tomojtechnomancy: cool
21:06KirinDaveslime-complete-symbol
21:06tomojdoes a leiningen client have access to that info for dependencies?
21:06tomojI mean a "client" to the dependencies, not building them
21:06technomancytomoj: you can always open the jar up and read the pom; that's the only way
21:07technomancygotta jet; feel free to ask on the mailing list
21:07tomojthanks
21:07KirinDavetomoj: https://gist.github.com/c9c8d6cb47fdc5416993
21:10tomojKirinDave: swank-clojure version?
21:10tomojI am having success with 1.3.0-SNAPSHOT
21:11KirinDaveI'll try 1.3.0
21:14KirinDavetomoj: I wonder what I did to offend slime. Doesn't work for me.
21:15tomojKirinDave: when you type C-c M-p in the buffer, what namespace is displayed by default?
21:15tomoj(the buffer's namespace?)
21:15KirinDaveC-c M-p prompts me for a package name
21:16tomojright
21:16tomojdo M-: (slime-current-package)
21:16KirinDavethere is no default
21:16tomojthis is the problem
21:16tomoj(do that while in the buffer)
21:17tomojKirinDave: how did you load the file? C-c C-k?
21:17KirinDave(user)
21:17KirinDaveWhile in that buffer.
21:17erikcw1I've been playing with work ( http://github.com/clj-sys/work ) -- trying to setup a thread pool that will work through an SQS queue. I have the pool size set to 10, but from my logs it looks like only a single thread is running. Does anyone know what I may be missing?
21:20tomojhmm
21:20tomojdoes your protocol-machine macro mess with namespaces?
21:20KirinDaveNo.
21:21tomojdid you get slime from ELPA?
21:21KirinDaveYes.
21:21tomojversion?
21:21KirinDaveI think so anyways.
21:21tomojwow, I'm using 20091016
21:22tomojI'm surprised mine works and yours doesn't
21:22KirinDaveI was too
21:22KirinDaveI am updating.
21:34KirinDavetomoj: I updated, but it still fails. It's like it doesn't understand it's not in user. :\
21:35tomojhow'd you update without restarting emacs?
21:36KirinDaveI restarted emacs. :)
21:36tomojoh
21:36tomojI just assumed you used erc
21:37KirinDavetomoj: It's like it doesn't get it http://cl.ly/2iKv :)
21:39tomojhmm, aquamacs
21:40tomojcould that be the problem?
21:40tomojor, wait
21:40tomojis that gnu emacs on mac?
21:40KirinDaveYes.
21:40KirinDaveIt's not aquamacs
21:40KirinDaveI wonder if I have slime incorrectly set up.
21:40tomojdunno, then
21:41tomojthere is no set up
21:41KirinDaveI have to slime-mode every buffer. :\
21:41tomojah
21:41KirinDaveThat isn't the way it used to be.
21:41tomojright
21:41tomojI've seen that before
21:41tomojmysteriously
21:41tomojdon't know now where I've seen it
21:41tomojor how I fixed it..
21:41tomojeven if I fixed it
21:43KirinDaveThis is why emacs sucks so hard.
21:43KirinDaveAnd why any language that depends on it in any way is pretty much doomed to minority status.
22:02chouserKirinDave: good thing clojure works great with vim, then. Majority status here we come!
22:02KirinDavechouser: Vim is at least as terrible. :\
22:02chouser:-D
22:03moogatronic... i spend more time playing with either vim or emacs than I do actually writing code.
22:03moogatronicas much as I hate it, eclipse works better for me.
22:04moogatronicvim is my rst / python editor of choice for the most part. Getting CCW working in eclipse took me all of 5 minutes... Emacs + anything still not working.. I spent a whole day trying to get vimclojure to work with the nailgun server and just gave up.
22:04moogatronica day == a few hours
22:04moogatronic=)
22:05chouserI don't use vimclojure/nilgun stuff myself. I'm glad it works for some people, as I am glad people that like IDEs can use them with Clojure.
22:06chouserI need to be talked into liking eclipse. I'm hoping that happens for me at clojure-conj.
22:06moogatronicmy problem is that i don't like big bloaty IDE's, but they seem to have the features I like.
22:06moogatronicwithout screwing around forever to get it to work.
22:07moogatronici'm only a clojure hobbyist... I get paid to use eclipse and write boring business logic oriented webapps in java/eclipse.
22:08moogatronicI would be surprised if anyone talked you into "loving" eclipse... at least appreciating it maybe!
22:08gowlineclipse would be sweet if its text editor wasn't so bad.
22:09moogatronicmy mission tonight was to find a portable sane way to reduce the glare of the bright white background in eclipse, to little avail.
22:10moogatronicf.lux helps a lot actually, other equiv's for other os's...
22:10grettkemoogatronic: my co-worker loves Eclipse
22:13moogatronicgrettke: I think for java it's great. Other than i feel that I need a 2560x1600 screen to fully use it. =)
22:13grettkemoogatronic: lol
22:14moogatronicI honestly think I'm using "editors" as a scape goat to prevent myself from fully diving into a non-java/python language.
22:15grettkemoogatronic: you might like emacs if you like eclipse
22:17moogatronicI want to like emacs. I've just had so many years of emacs and vim that it's difficult. I like the philosophy behind emacs.
22:17moogatronicbut even when configuring my init.el, I find myself using vim to do it.
22:18moogatronicmeant to say "eclipse and vim'.. =)
22:19rich_holygoatheh, I do the same thing -- vim ~/.emacs
22:19rich_holygoatguess I think of Emacs as a programming environment and Vim as a text editor
23:00scottjIf you want to read more than one thing from a string, is (read-string (str "(" "a 2" ")") ) the way to do it?
23:03chouserscottj: that's the easiest way
23:03scottjis that lazy?
23:03chouserotherwise you need to set up a StringReader, etc.
23:03chouser,(class (read-string "(a 2)"))
23:03clojurebotclojure.lang.PersistentList
23:03chousernope
23:04scottjfunctions are only lazy if they return a lazyseq?
23:05chouserI wouldn't go that far, but a PersistentList is definitely not lazy
23:13don-cobraBy default, using starter-kit and installing clojure-mode, etc. it looks like clojure 1.0 is installed. What is the easiest way to point to compiled version of master?
23:14don-cobraNewbie here trying to get emacs setup w/ latest clojure.
23:32freakazoiddamn, I made a gist of the relevant section of my .emacs for don-cobra and everything.
23:34technomancymmm... new John Rose blog post.
23:34technomancybrain food... om nom nom.
23:37technomancyhttp://blogs.sun.com/jrose/entry/larval_objects_in_the_vm
23:38freakazoidthat dude needs a better picture
23:39technomancyhe's a JVM superhero; the grainy picture is just there to protect his true identity
23:40freakazoidOhh
23:45technomancyis it pretty reasonable to assume a resolution of 1024-786 for conj presentations?
23:46defnNo offense to Stuart Sierra, but does he not look a lot like Matthew Broderick?
23:48defnAlso, I am not very familiar with how one might tackle writing to a file with Clojure in two separate processes. My friend is working on a project for a Java class where he has to handle the locking of a file so he can write to it from two different threads. On OSX apparently this works without much work, but on Windows his solution breaks.
23:49defnCould anyone offer any possible avenues one might take with Clojure to accomplish something like this?
23:49defnI mean I can think of a few -- but I'm curious what other folks would suggest...
23:53scottjhave an agent and send it messages from the two threads telling it to spit in the file? (I don't know the right answer)
23:58tomojztellman: ping
23:58ztellmantomoj: what's up?
23:58tomoj.. (siphon ch broadcaster) (siphon broadcaster ch) .. doesn't this blow the stack?
23:59tomojon the Channels wiki entry, the multicast example
23:59ztellmanno, because 'ch' in this case isn't unidirectional, it's one half of a bidirectional endpoint
23:59tomojguess I'm not using it right
23:59ztellmandid you manage to blow the stack?
23:59tomojyeah
23:59ztellmanhmm
23:59tomoj(def a (channel)) (connection-handler a)