#clojure logs

2010-02-17

00:16technomancywho's ready for a leiningen release tonight?
00:16danlarkinChoo CHoooooooooo
00:18RaynesAw man!
00:18RaynesMore shit to download, excuse my french. ;)
00:18technomancywell, this will be the last time
00:18technomancysomebody contributed an upgrade task
00:19Raynestechnomancy: Has the "lein new project.clj is all a single line" bug been fixed?
00:19RaynesOh goody!
00:19technomancyRaynes: yup
00:19RaynesYay! I'm all excited now.
00:19RaynesGet to releasing, Doctor Phil!
00:19technomancyit's done with format now instead of pprint, which is lame but not as lame as a one-line project.clj
00:20danlarkinupgrade task? sounds non-friendly to packages
00:20Raynesdanlarkin: Screw you and your packages. >:|
00:21technomancydanlarkin: yeah, you'll want to delete that for homebrew
00:22technomancybut it does check to make sure the bin script is writable before it replaces it.
00:22tomojwhat's this "packages"/"homebrew" thing
00:22danlarkinI'm gonna let that stew for a few days
00:24technomancyoh nice; github has a flash-less upload system now
00:24technomancyso I can use that instead of my dreamhost
00:24RaynesI think somebody needs to relay the whole "git doesn't store binaries well" discussion to Ola Bini. Ioke's git repo is unbelievably huge.
00:25technomancyRaynes: pet peeve!
00:26technomancyI will do it if I see him.
00:26technomancyI got Charlie to agree to rewriting Duby's history in order to remove jars.
00:26RaynesI don't contribute to Ioke simply because downloading the repository on this dial up connection is either impossible, or just not worth the time it would take.
00:27RaynesI might tether up my phone and pull it down over a day or two on a different computer over my phone's 4kb (I live in the middle of nowhere) connection.
00:27technomancyI tried to submit a patch to remove jars from the Katta project, but the patch was so big that Jira refused it.
00:28underdevhi! i'm trying to use clojure-test-mode, but i'm having a problem. If i run code directly in slime-repl, the testing works fine. If i try to C-c C-, from a buffer with the same code, i get an error: Unmatched delimiter: )
00:28RaynesI'm not really sure what makes Ioke's repo so big, but I know that some 300mb is too big for a year old language.
00:28RaynesI mean, even Factor's repo is just 50mb.
00:29underdevanyone else encounter this problem?
00:29technomancyyeah, the problem is that even just removing a jar adds the size of the jar to the repo over again.
00:30technomancyso a series of upgrades is going to be a disaster
00:30technomancyunderdev: no, sounds like the file has a typo
00:31RaynesI wish github showed repository and file sizes.
00:31RaynesI'd like to know just how large this beast is.
00:31underdevbacktrace 0: clojure.lang.LispReader.read(LispReader.java:180)
00:31underdevtechnomancy: which file?
00:32RaynesI know that whatever made the repo so big isn't there anymore, because the actual source without the history is only like 4mb...
00:32Rayneshttp://github.com/olabini/ioke/tree/master/lib/build/ Or maybe I spoke too soon. Appears he is still keeping jars in there.
00:33underdevi had a little trouble installing clojure-test-mode from elpa, maybe its fubared
00:33technomancyunderdev: no, it's probably the file containing the tests
00:33scottjI saw a screencast where clojure-test-mode highlighted the minibuffer (not just lines) in green/red when tests passed/failed and printed in minibuffer what was expected from test instead of just number of failures. anyone know what version of clojure test mode has those features?
00:34technomancyscottj: that'd be tcrayford's. it had a few issues I asked him to resolve before I merged
00:34RaynesAnd this: http://github.com/olabini/ioke/tree/master/bin/
00:35underdevtechnomancy: no, its balanced. its tiny
00:35underdevparedit confirms :)
00:35technomancyunderdev: maybe it's a namespace that it requires then?
00:35underdev(use 'clojure.test)
00:36underdevthat's it
00:36underdev(deftest testing-tests (is (= 2 2)))
00:36scottjtechnomancy: cool, those features will be nice
00:36Drakesoncan I use leiningen to build/install/do-something-to a project that still only has a pom.xml?
00:37technomancyDrakeson: not currently
00:38DrakesonI see
00:39scottjdoes leiningen (or one of it's plugins) have anything for deployment?
00:40technomancyyou guys are full of great ideas
00:40technomancybut they are not in leiningen yet
00:40technomancythink of it as an opportunity to contribute
00:41RaynesAnd be greatful that technomancy knows how to manage a github repo, and the size is quite small.
00:41Rayness/github/git/
00:43scottjI did spend like two hours trying to figure out why recent (since jochu's) swank-clojure M-. doesn't work correctly on Windows but failed miserably.
00:44technomancywindows is ... lightly supported. to put it generously.
00:45technomancyheck, swank-clojure is lightly-supported when it comes down to it.
00:47scottjOther than M-. it worked pretty well I think. I think it's just got / hard coded instead of using File/separator maybe
00:48technomancywhat are the specifics on badditude of single-segment namespaces?
00:49technomancyis it just an AOT-time problem, or is it more general?
00:50hiredmanI think current;ly it is mostly an aot issue, but because we wnat something like unified semantics, it is everyone's problem
00:50technomancyI'll buy that.
00:51technomancyfewer awkward questions down the road
00:51technomancyso lein new will spit out a foo.core ns instead of foo
00:56technomancyhiredman: did you have a use-/bin/sh fix?
00:56hiredmanthe website updates via fork/pull request is a neat idea
00:56hiredmantechnomancy: no :(
00:56technomancyhiredman: I stole that from the Seattle Ruby group
00:56technomancyhiredman: probably a little late in the release cycle to change something like that anyway
00:59underdevhaving backtracked, when i try to install clojure-test-mode from ELPA, it complaims that swank-clojure.el already exists
01:00underdevanyone see that before?
01:00technomancyunderdev: yeah... it's a known bug.
01:00technomancyI've fixed it, but the package.el maintainer hasn't applied my patch yet. =\
01:00underdevhow would i get your copy?
01:00technomancyunderdev: http://github.com/technomancy/package.el
01:00technomancylots of other neat features there too. =)
01:01underdevtechnomancy: ty
01:01underdev!!!
01:01technomancyeh?
01:02underdevthank you
01:02technomancyoh, I thought the !!! was an expression of surprise or alarm.
01:02underdevappreciation
01:02slyphon"Ooooh!"
01:02slyphon"no, 'Arrrgh!'"
01:03technomancy"no, it's more in the back of the throat..."
01:03slyphon:D
01:06Knekkhmm, what's the simplest way to convert a char[] to a list of chars?
01:06technomancyKnekk: call seq on it
01:06Knekkah, that's simple enough, thanks.
01:06slyphonseq and ye shall find
01:07Knekkbrilliant, thanks
01:09underdevtechnomancy: w00t! thank you!
01:10underdevrock on
01:11technomancyshould future versions of leiningen have code names?
01:11danlarkinyes!
01:12underdevDARN IT!
01:13underdevinstalled but still getting that stupid error
01:13technomancylook out for Leiningen "Amazing Horse" 1.2.0, coming to a git hub near you.
01:13danlarkinHeyooooooooooooooooo
01:14technomancydanlarkin: next time I call you I'm going to be thinking about the fact that "hey, pressing this button is going to cause the amazing horse song to be played. neat."
01:14danlarkinHahah
01:15technomancydun dun DUN: http://github.com/technomancy/leiningen/blob/1.1.0/NEWS#L3
01:15danlarkinwell my phone's on silent most of the time, but it's the thought that counts
01:15underdevtechnomancy: do you think i would be better off using the esk? does that have clojure-test-mode integrated into it?
01:16technomancyunderdev: it installs clojure-test-mode via elpa too.
01:16technomancycan you try M-x toggle-debug-on-error?
01:16technomancymaybe that could get you a stacktrace you could paste
01:18slyphongod *dammit*
01:19technomancyslyphon: you could try wall-hack
01:19technomancyin contrib
01:19technomancybut I don't know much about it apart from it's an awesome name that sounds like it could be relevant to the problem at hand
01:19slyphonhah
01:20hiredmanit got renamed
01:20hiredmanin master it is called reflection something or other
01:20hiredmanexcellent
01:21slyphonit seems like gen-class provides a way to do this, i just can't figure out the correct combination of :exposes-methods and :methods or something
01:23hiredmanslyphon: what does :methods have to do with it?
01:24slyphonso, my superclass has a protected setName method, when i (defn -setName ...) and try to do (.setName inst "blah") i get No matching method found: setName
01:25slyphonbasically, i'm throwing stuff at the wall and seeing what sticks at this point
01:26hiredman:exposes {setName private-setName}
01:26hiredmanor something
01:26slyphonyeah :exposes-methods { setName setNameSuper }
01:26slyphonis what i have
01:26hiredmanactually, hypens are not a good idea
01:27hiredmanis this for pircbot?
01:27slyphonyeah
01:27slyphonhttps://gist.github.com/8e989bdceba5fb2b5778
01:27slyphonit's my first project with any language i'm trying to learn
01:27hiredmanI think I wrote wall-hack-method for this purpose
01:28slyphonshouldn't :exposes-methods take care of this?
01:28hiredmanI bet, but gen-class'ing sucks
01:28slyphonhahahaha
01:28slyphonindeed
01:29slyphonhow about proxy?
01:29hiredmanproxy?
01:29clojurebotproxy is <Chouser> proxy teases with its ease of use, then suddenly betrays.
01:29slyphonhah
01:29hiredmanclojurebot uses proxy and wall-hacks setName
01:29slyphonok
01:29slyphoni'll look at that then
01:30hiredmanthe main issue I had with proxy is updating the methods can be a pain
01:30technomancyunless you've got a fair amount of java experience, you might want to avoid these kind of tricky interop things for a first project
01:30RaynesI think an IRC client will be my next adventure after I finally realize that I can't design an email client and give up.
01:30slyphontechnomancy: well, true
01:31technomancythey're not nearly as fun and quick as a more functional project would be
01:31RaynesOh joy. Ted Bundy is coming on. I like me some serial killer.
01:31slyphoni wrote a scalabot using PircBot, so i had something of a structure worked out
01:31technomancybut if you've got something that would be useful then that's a plus too
01:31slyphonyeah
01:32slyphonthis is always the hard thing, trying to figure out what's easy enough to mess with, the middle ground between a toy and something really substantive
01:32hiredmanclojurebot: scala 1+1
01:32technomancyyup
01:32technomancyslyphon: I had a lot of fun with mire: http://github.com/technomancy/mire
01:32clojurebotInt = 2
01:33slyphonhah
01:33slyphoni'm afraid i'm not much of a MUD guy, but yeah
01:34technomancyoh yeah, I didn't actually *play* it. but it was fun to write. =)
01:34slyphonhahaha
01:34hiredmanthe java guys always cry if someone mentions pircbot
01:34slyphonoh yeah?
01:34hiredmanthey all like jerklib
01:34slyphonhah
01:34hiredmanI think that is what it is called
01:34slyphonpircbot is really not that awesome, it's just...i dunno, straightforward in a way
01:35slyphonyeah, jerklib
01:35slyphonhttp://jerklib.sourceforge.net/
01:35slyphonhey, they have The Big Lebowski on their homepage, this *must* be awesome!
01:36hiredman:P
01:37slyphonah, yeah, this is event based, which is what i always wind up having to shoehorn onto pircbot
01:39hiredmanall of the proxy'ied methods in clojurebot end up calling a function that calls a multimethod trampolined in a future
01:39slyphonyou had me at "trampoline"
01:41slyphonyeah, i was basically gonna convert the onFooBar method's arguments into a struct, then figure out some way of calling a bunch of listeners with that struct in a separate thread
01:42slyphonfuture-cancelled? sounds rather...fatal
01:43hiredman(future (trampoline some-function arg1 arg2))
01:43slyphonwhy do you need trampoline there?
01:44hiredmansome times some-function returns a thunk that calls some-function again with altered args
01:45hiredmanand some-function is a multimethod and recur only works with-in fns
01:45slyphon"a thunk" is a curried function?
01:45hiredmana thunk is a no arg function
01:45slyphonah
01:45hiredman#(some-function arg4 arg5)
01:45slyphongotcha
01:45slyphonand trampoline ensures you don't consume stack
01:47hiredmanright
01:47slyphonthat's pretty damn cool
01:50hiredmanthe trampolining is neat
01:50slyphonit's very disconcerting
01:50slyphonat first
01:50hiredman~seen hiredman
01:50clojurebothiredman was last seen in #clojure, 0 minutes ago saying: ~seen hiredman
01:50slyphonhah
01:51hiredmaneverything goes to that "plugin" and once it updates the tracking stuff it just adds an ignore me flag to the metadata and trampolines
01:52slyphonyou're dispatching based on the metadata?
01:52slyphonor that's something trampoline does?
01:52slyphon(the ignore-me bit)
01:52slyphonclojurebot: code?
01:52clojurebotI don't understand.
01:53hiredmaneach plugin defines a function that the multimethod uses to determine who gets a message
01:53hiredmanclojurebot: source
01:53clojurebotsource is http://github.com/hiredman/clojurebot/tree/master
01:54slyphonoooh
01:54slyphonxmpp
01:54slyphon*FANCY*
01:54slyphon:)
01:54hiredmanhttp://github.com/hiredman/clojurebot/blob/master/src/hiredman/clojurebot/seenx.clj
01:55hiredmanI wish there was a pircbot for xmpp
01:55slyphonyeah, all the jabber libs are as confusing as the jabber protocol
01:58underdevno one is using clojure-test-mode
01:58underdevi know this to be true
01:59underdevbecause on both ubuntu and windows, it throws the same error, but after dismissing the error the test results are shown in slime
02:00underdevif others were using it, this behavior would be know
02:00underdevn
02:12underdevi'm going to try fresh with the ESK
02:29RaynesIs there a standard way of shuffling the contents of a sequence?
02:29RaynesMaybe something in contrib?
02:30somnium,(doc shuffle)
02:30clojurebot"([coll]); Return a random permutation of coll"
02:30RaynesWhat do you know.
02:30Raynes:|
02:30somniumc.c.seq-utils for 1.1
02:31RaynesThaks.
02:31RaynesThanks*
02:31somniumWelome
02:40KnekkI am brain-dead... what's the easiest way to return a list with only the first instance of an element removed?
02:40Knekkor any one instance of a particular element removed.
02:40Knekki.e. remove a \a from (\a \a \a \b \b \b) returns (\a \a \b \b \b)
02:41Knekkmaybe I should sleep on it
02:41TheBusbyrest?
02:41clojurebotrest never returns a unicorn
02:42TheBusby,(rest [1 2 3])
02:42clojurebot(2 3)
02:42Knekkrest only works if the element is at the first position, which is not always true
02:42KnekkI could want to remove \b so that I have (\a \a \a \b \b) as the result
02:42TheBusbyahh, so for example (magic 2 [1 1 2 3 3]) would return [1 1 3 3]
02:43Knekkright
02:43Knekkremove at most one instance from the list
02:43TheBusbyer, take-while?
02:43Knekk,(doc take-while)
02:43clojurebot"([pred coll]); Returns a lazy sequence of successive items from coll while (pred item) returns true. pred must be free of side-effects."
02:43TheBusbyin this case, take-while not equal
02:43Knekkit would remove all instances, not just one
02:43Chousukeyou might want to make a custom lazy seq for that.
02:44_mstmaybe: (defn magic [elt coll] (let [[xs ys] (split-with #(not= elt %) coll)] (concat xs (rest ys))))
02:44TheBusbywhen-first?
02:44_mst(mostly untested ;)
02:44Knekklet me try that.
02:45TheBusbyI heartily recommend the "clojure cheat sheet" for running these types of questions down. Not that I know the answer though :)
02:45Knekk_mst: very nice
02:46_msthooray :D
02:49Knekkthanks all
02:49Knekkfun with ProjectEuler problems, but time for bed.
02:51vyConsidering (apply str (line-seq rdr)) expression, does str work eagerly in here?
02:52Chousukeyes.
02:52Chousukestrings are java Strings, so it has to :)
02:55tomojis it evil to have a deftype with a field that points to an atom?
02:55tomojmy use case: I need to implement a java interface with a single message that is called when a message comes in via xmpp
02:56tomojthe deftype will implement that interface, and the method will push (swap!) the incoming method onto the queue
02:56tomojwhen I want to process incoming messages I can then pop (swap!) messages off
02:56tomojseems strange and weird, but maybe beautiful
02:57somnium:volatile-mutable and :unsychronized-mutable just got added as options to deftype fields in master
02:58hamzais reduce lazy?
02:58tomojboth of those sound scary
02:58tomojbut I will take a look
02:58tomojhmm, I don't think they are for me
02:58tomojI want STM
02:59somniumputting an atom in a struct-map doesnt sound terribly evil
03:00tomojgreat :)
03:01somniumis there any docs/discussion on how the &form &env implicit macro args work?
03:19tomojis there a function version of @ ?
03:19somniumderef?
03:19tomojah, of course
03:19tomojthanks
03:34hiredman,(macroexpand '@a)
03:34clojurebot(clojure.core/deref a)
03:34hiredman,(read-string "@a")
03:34clojurebot(clojure.core/deref a)
03:46bosiehow much slower is clojure compared to java? i googled but you find numbers from twice as slow to ten times as slow
03:46Chousukeit depends on what you're doing
03:47hiredmanand how you do it, and how often you do it
03:47bosiealgorithmic nature, data crunching
03:47slyphonhiredman: that's what she said?
03:47hiredmanclojurebot: do something
03:47clojurebotwhat should I do today, it is the weekend and all
03:47hiredmanclojurebot: what timezone is that?
03:47clojurebotIt's greek to me.
03:48hiredmanright, europe, the worker's paradise
03:48slyphonhah
03:48bosieso the 10x is possible when you have a lot of data and have to calculate on it?
03:48slyphonbosie: "how much slower is it" has got to be one of the least-answerable questions in the abstract
03:48ChousukeI think you usually get 10x if you write straightforward, functional code with type hints.
03:49bosieok
03:49Chousukebut you can get significantly better performance through optimisation.
03:49bosieslyphon: i know i know
03:50hiredmanChousuke: really?
03:50hiredman(about the 10x)
03:50slyphonbenchmark it!
03:50Chousukehiredman: well, that's just my pessimistic estimate
03:51Chousukehiredman: I haven't actually benchmarked it :)
03:52Chousukeonly for now, straightforward code (using many lazy seqs, no transients or primitives, etc) is a fair bit slower
03:53hiredmanrhickey's gvec in clojure is supposed to be the same speed as the java
03:53ChousukeI suppose. but I wasn't considering 1.2 yet :P
03:54Chousukealso it's not really number-crunching
03:55Chousukebosie: so in short, I think you probably won't be able to get to 1:1 with java, but close enough for most purposes.
03:56bosieChousuke: considering that a single process of the java version took 15 hours to process the data.... ;)
03:56Chousukebosie: was it multithreaded, though?
03:56bosieChousuke: single process, single thread
03:57bosieChousuke: no
03:57hiredmanpmap
03:57Chousukeright.
03:57bosieChousuke: but if its 15 hours for java, multithreading doesn't help much for clojure either
03:58Chousukewell, assuming you can get clojure to even 2x java speed, then running it with 4 cores should help :P
03:58bosiei have 80 cores
03:58hiredman:D
03:58bosiebut i will run the java code on those 80 cores too ;)
03:59hiredmanhave you seen the clojure widefinder write up?
03:59somniumbosie: have fun synchronizing the java :p
03:59Chousukebosie: you might want to give Clojure a try though.
03:59bosiehiredman: this one? (http://clj-me.cgrand.net/index.php?s=WideFinder%202%20in%20Clojure%20(naive%20port%20from%20Ruby))
03:59bosiesomnium: yea, no fun using threads in java
03:59hiredmanhttp://meshy.org/2009/12/13/widefinder-2-with-clojure.html
03:59hiredman^- that one
04:00hiredmanthe not naive one
04:00bosieChousuke: i would like to, that's why i am reading the book
04:05AWizzArdMoin
04:10bosiethanks guys
04:24cgrandAWizzArd: hallo!
04:25esjmorning all
05:32powr-tocWhat's the idiomatic way of taking everything except the last element from a sequence?
05:32RaynesAutodoc has a bucket load of deps.
05:32the-kennypowr-toc: butlast?
05:33the-kenny,(doc butlast)
05:33clojurebot"([coll]); Return a seq of all but the last item in coll, in linear time"
05:33powr-tocthe-kenny: cheers
05:33powr-tocI knew I'd seen something like that somewhere :-)
05:36metaperl,(def x 5)
05:36clojurebotDENIED
05:36metaperlis it feasible to use the :test keyword of def() to set the allowable range of a variable?
05:36bosiethe-kenny: what's your ',' doing?
05:37metaperlthe kenny?
05:37metaperlyou mean me?
05:37the-kennybosie: , is the prefix-command for clojurebot to evaluate clojure-code
05:37metaperlI was trying to use the bot... Im a novice
05:37the-kenny,(+ 1 2 3)
05:37clojurebot6
05:37bosieah right
05:37the-kennyIt doesn't let you evaluate things
05:37the-kennys/evaluate/def/
05:37triyoanyone have experience with clojure and mongodb?
05:38RaynesMy first experience with a DB will be with FleetDB in my email client.
05:38the-kennytriyo: Someone here uses mongodb with clojure alot
05:40triyothe-kenny: thanks, I'm new to NoSQL and am trying to see how to query embedded docs. A bit of a mind shift.
05:40triyousing congomong clojure lib that is.
05:41triyosomnium: first off, congomongo is cool :)
05:41triyosecond, I need some help
05:42triyoI have following simple case. Events collection with embedded Guests.
05:43triyoHow do I query guest socs within the event doc?
05:43triyoby query I mean also inserts and updates.
05:43triyodo I use clojure conj, merge, etc?
05:44somniumprobably update-in/assoc-in for embedded docs
05:44triyo* socs = docs
05:44tomojit's likely I will be using congomongo at work soon :)
05:44somniumI am so far behind on patches its embarassing :/
05:45triyoI see, this is the route I chose.
05:45triyoHere is even a better q. For a give guest doc, how do I determine the event it is embedded in? :)
05:46bosietest
05:46bosie,(+ 1 2 3)
05:46clojurebot6
05:46somniumtriyo: to search for an imbedded, (find :events :where {:guest.name "..."})
05:47triyothx
05:47somniumtriyo: Im not sure I understad, how can you get your hands on an imbedded doc without knowing what it was imbedded in?
05:48somniumok, maybe ^^ was the answer
05:49triyosomnium: via a browser, a http request was issued with the guest id. So I use guest id to lookup event. So your above where cond will do.
05:49triyosomnium: have you got a change log of patches, whats going in?
05:50somniumgridfs support is the main addition
05:51triyoare you looking to support group and sort?
05:51somniumexperimental stripping out of the .java too, but maybe hold-off on that
05:52somniumtriyo: sure, why not, patch?
05:56somniumtomoj: really, your workplace uses mongodb?
05:57tomojnot yet, but probably soon
05:57tomojI've gotten to use clojure on some prototype stuff, and expect to be using it in production soon :)
05:58triyosomnium: you asking for a patch, if so I'd be happy to have a look at that.
06:05somniumtriyo: sure, atm Im unlikely to add anything to it that I dont suddenly need, but Im happy to merge in useful things. (though Ive been terribly slow about it this month)
06:09triyono worries. If I produce something useful, you can look at it and maybe commit it if you wish at your own suitable time.
07:02rrc7czhow might you make a sorted-map by val instead of key
07:10AWizzArdrrc7cz: (def s (apply sorted-set-by #(compare (:username %1) (:username %2)) [1000-users]))
07:11AWizzArdA a User is something like a (deftype User [username password age city ...])
07:12rrc7czAWizzArd: I was something along those lines: (sorted-map-by #(compare (m %1) (m %2)) m) but it's treating m as a single key
07:12AWizzArdMaybe because (m of-your-obj) does not return a unique value of all your objects.
07:12rrc7czAWizzArd: Then I tried various combinations of apply, like (apply (fn [& keyvals] (sorted-map-by #(compare (m %1) (m %2)) keyvals)) m)
07:12rrc7czhmm
07:12AWizzArdWhen each User has a unique :username then a sorted set is fine.
07:13rrc7czokay
07:13AWizzArdBut if 5 people live in the :city Paris it won't work.
07:13AWizzArdBecause a set treats two things as equal when they are the same over their comparator.
07:13rrc7czMy map is simple string : int, key val pairs, so it should be okay
07:13tomojhmm, that seems kinda crummy
07:14AWizzArdtomoj: even when the two User instances are not the same under identical? it doesn't matter.
07:14tomojdoes no one ever want to have a set, with equality on the actual items, but sorting by some function of the items?
07:14AWizzArdYes.
07:14tomojand, if I understand you, sorted-sets can't do that?
07:14AWizzArdYou will have to emulate SortedMultisets or SortedMultimaps.
07:14tomojah
07:14AWizzArdtomoj: per se it is true, they can not do that.
07:15AWizzArdBut: you can have for example a SortedMap and as the key you use the :age of a person. And the value will be a set.
07:15AWizzArdAll people of age 85 go into the same set.
07:15tomojah, yeah, I can see that
07:16tomojand then to iterate in sorted order, just iterate over each set in order
07:16AWizzArdYes. From a SortedMap you can ask for all Users of ages 30 to 40.
07:16AWizzArdAnd then you will get 10 sets.
07:16AWizzArdInstead of sets it can even be SortedSets, sorted by a unique key of the User deftype.
07:17AWizzArdThen you can have all 20 year old people, sorted by :username.
07:22rrc7cz(apply sorted-map-by #(compare (val %1) (val %2)) m) seems like it should work, but after two comparisons it throws an exception, with m = {:f 1, :j 6, :n 3, :w 2, :m 9}
07:23rrc7czIllegalArgumentException: No value supplied for key: [:m 9]. It does call compare twice on [:n 3] and [:f 1] which seems odd
07:24AWizzArdm is a vector of maps?
07:24rrc7czstraight map
07:25AWizzArdI am not sure if map breaks m up into (map identity m)
07:29rrc7czsomething else I don't understand is why "(sorted-map-by #(compare %1 %2) :f 1 :j 6 :n 3 :w 2 :m 9)" works (sorted by key), but "(apply sorted-map-by #(compare %1 %2) m)" throws an exception
07:30AWizzArdoh, I misread that you want a sorted-MAP and not a sorted-SET
07:30AWizzArd,(apply sorted-set-by #(compare (val %1) (val %2)) {:a 1, :b 5, :c 3})
07:30clojurebot#{[:a 1] [:c 3] [:b 5]}
07:30AWizzArdSo, for sortedSETs this approach works.
07:31AWizzArdFor a map however your comparator gets a different input
07:31AWizzArdyou put MapEntries as input
07:32AWizzArdso, for the key [:f 1] you input the value [:j 6]
07:32AWizzArdwhile in reality you wanted to input :f 1 :j 6
07:32rrc7czbut I thought I was doing that: #(compare (val %1) (val %2))
07:33rrc7czI call val on the MapEntry
07:34AWizzArdYes. But later you compare only with keywords, such as :f
07:35AWizzArdlet's try it with into maybe
07:35AWizzArd,(into (sorted-map-by compare) {f 1 :j 6 :n 3 :w 2 :m 9})
07:35clojurebotjava.lang.Exception: Unable to resolve symbol: f in this context
07:36AWizzArd,(into (sorted-map-by compare) {:f 1 :j 6 :n 3 :w 2 :m 9})
07:36clojurebot{:f 1, :j 6, :m 9, :n 3, :w 2}
07:36AWizzArdrrc7cz: even when you read out the val of your MapEntry, the MapEntry will be the key in the resulting map
07:37rrc7czAWizzArd: I didn't know that. That's probably what's screwing me up
07:37AWizzArdyes, sorted maps and sets need a very different comparator
07:38rrc7cznow the exception makes sense: No value supplied for key: [:m 9]
07:39AWizzArdyes
07:39AWizzArdapply splitted it into MapEntries, while you wanted "the brackets removed"
07:41rrc7czthen I have no idea how I can implement this, except using some hack using sorted-set-by, then building a map from the resulting MapEntries
07:41AWizzArdWhat again do you want to implement?
07:41rrc7cza map sorted by its val
07:41rrc7czinstead of key
07:42AWizzArdCan you make the values the key?
07:42AWizzArdAnd btw, a sorted set could be also fine I guess.
07:43AWizzArdOnly the requests will look a bit ugly
07:43rrc7czI can't make the values a key because they are int counts. So I have many 1, 2, etc
07:43triyoIs there a way, using update-in or similar, to update a specific nested map in a vector thats in a map itself? {:x 1 :y [{:id 1 :name "Bob"} {:id 2 :name "Alice"}]} -> I wish to update where :id is 2
07:43rrc7czyeah
07:43AWizzArdrrc7cz: you could emulate a sorted Multimap
07:43triyoBy "way" I mean a most idiomatic way. Here is my hackish attempt: http://gist.github.com/306565
07:44AWizzArdrrc7cz: it won't help to first build a sorted-set and then make an ordinary map out of it, as this would destroy the order again
07:45rrc7czAWizzArd: I'm just finding that out now...
07:45rrc7czhmm
07:45AWizzArdBut maybe you can have the current values (the int counts) as keys.
07:45AWizzArdAnd the value will be a set of keywords
07:46AWizzArd{1 #{:a :f}, 2 #{:b}, 3 #{:x :y :z}, ...}
07:49rrc7czAWizzArd: that's an interesting idea
07:49rrc7czthey could even be a sorted set of keywords, to default to alphabetical when the counts are the same
07:52AWizzArdYes A SortedMultimapSortedSet ;)
07:52rrc7czI think my head just exploded
07:52AWizzArdYeah, I was fighting with this in the past days for my DB project.
07:52AWizzArdThat's why I am currently fluent in that
07:52rrc7czwhich db proj?
07:53rrc7czI'm constantly on the lookout for a couchdb replacement for my project
07:54AWizzArdWell, I will tell more about it in some weeks, when I publish it. An object DB for Clojure.
07:54rrc7czokay. I'll keep an eye out on the mailing list
07:58djpowellusing mutator methods that return void with cells might be a bit annoying
07:59djpowellare there any plans for a cell for thread safe things?
08:00somniumtriyo: update-in works on vectors and maps, so
08:00somnium,(update-in {:x [{:y 1}]} [:x 0 :y] inc)
08:00clojurebot{:x [{:y 2}]}
08:01tomojbut he needs to pick by value, not by vector index, I think
08:01triyosomnium: oh I see how you have index in key attr section
08:01tomoj(not that I have a better idea)
08:01triyotomoj is right though
08:01djpowellcells seem pretty interesting. in clojure, it is impossible to accidentally forget synchronization; in java it is impossible to tell when you have
08:02triyohere is what I'm looking to prettify: http://gist.github.com/306565
08:03triyoits hackish I'd say since it uses filter to drop the item first then conj to add it again
08:06KjellskiHi there, anyone with a latex listings definition for clojure code?
08:06Kjellski~latex
08:06clojurebotIt's greek to me.
08:07somniumseems like a higher-order 'make-updater fn should be possible, but nothing elegant springs to mind (or a macro that spits out a bunch of fetch-x-by-y-when-z fns possibly)
08:07Kjellski~And you don´t speak greek?
08:07clojurebotTitim gan éirí ort.
08:08triyosomnium: thx, was thinking along similar line.
08:46rhickeySeajure - awesome! http://seajure.technomancy.us/
08:55ohpauleezhaha, finally, someone did it
08:56ohpauleeztechnomancy is awesome, he deserves some sort of community award haha
08:57ohpauleezwhoa, for sure
09:03underdeveerrgghh!
09:03underdevi am desperately trying to use clojure-test-mode
09:04underdevi have installed in windows, ubuntu, and ubuntu
09:04underdevwith emacs starter kit
09:04underdevin all cases, i am getting this error
09:04underdevhttp://gist.github.com/306633
09:05underdevi have one line, 1 set of parenthesis
09:05underdevI SWEAR TO GOD THEY AREN'T UNMATCHED!!!!!
09:07ohpauleezunderdev: so frustrating
09:07underdevyou know it
09:07underdevhow can it possibly be that in 3 different installations, i
09:08underdevim getting the same error
09:08underdevyet it doesn't seem to be a problem anyone else is having??@?
09:09ohpauleezI would fire up a debugger and/or type it in piece by piece on the repl
09:09ohpauleezI'm not a clojure-emacs user, so I can't provide much help beyond that
09:10underdevyeah, im not sure how to break
09:10underdev(use 'clojure.test)
09:10underdevdown any further
09:10ohpauleezgah!
09:10esji have'd had the same error for ages
09:11underdevokay, thank you thank you
09:11underdevfor just acknowledging that
09:11underdevit runs the tests!, and displays output after the error
09:11esji've never had the stomach to figure out what is going wrong
09:12underdevthis is a broken window i'm having a very difficult time ignoring
09:13underdevif it didn't slam the buffer with "you're an idiot", i guess i could tolerate it better
09:14tomojunderdev: elpa?
09:14underdevthis is elpa
09:14ohpauleezcemerick: seriously haha, this channel is 1/3 new features 1/3 emacs and 1/3 (map vector [1 2 3] [1 2 3])
09:15ohpauleez:)
09:15cemerickwell, I've no problem with the first and last thirds
09:15ohpauleezme either
09:15underdevinstalled by site in 2 oses, and once cloned from technomancy's "Emacs Starter Kit"
09:15cemerickI don't have a problem with emacs stuff either, but it seems like having a separate channel for clojure/emacs issues would be more productive for everyone
09:15tomojhmm, I don't see the error :(
09:15ohpauleezI don't even mind the emacs chat all that much, I just feel bad it happens so much
09:16cemerick...and maybe cut down on opportunities for people to start pointless editor discussions ;-/
09:16jcromartieCan we get a "project.clj not found" instead of a massive screen-filling stack trace?
09:16cemerickthat was supposed to be ;-)
09:16jcromartie:)
09:16underdevtomoj, elpa?
09:16tomojyeah
09:16ohpauleeznow now now, who would do that :)
09:16ohpauleezdo we have to talk about window managers again?
09:16cemerickoy
09:16ohpauleez;)
09:16ohpauleezhaha
09:17cemerickyah :-)
09:17underdevso this channel should be about clojure in the abstract and not clojure development in the concrete?
09:17underdevsorry to annoy
09:17tomojunderdev: what's the filename?
09:17ohpauleezunderdev: you're totally fine, dig in. There are certainly people here that can help out
09:17underdevhttp://gist.github.com/306633
09:18underdevtomoj ^^^
09:18tomojbut, what's the filename
09:18underdevwhich filename (sorry)
09:18tomojthe file you wrote "(use 'clojure.test)" in
09:19eevar2tomoj: probably the repl?
09:19underdevtdd.clj
09:19tomojseems doubtful
09:19jcromartieunderdev: I just got testing working for myself
09:19tomojok, tdd.clj should be fine
09:19tomojyou don't have any quotes or anything weird on the path?
09:19tomoj(the path to the file, I mean)
09:19underdevclojure-test-mode-1.3 from elpa is working?!?
09:20jcromartieunderdev: oh, no I'm not using clojure-test-mode
09:20tomojunderdev: yeah
09:20jcromartieit would seem that whatever it loading up that REPL is not using the most recent clojure version
09:20jcromartieif it's clojure-test-mode then I would guess they are using an old clojure 1.0 or something
09:20tomojwait, no
09:20tomojI get the same error as you, now
09:21jcromartiehmm
09:21tomojstrange, must be some weird bug
09:21underdevlololol
09:21underdevi think so
09:21tomojunderdev: (ns foo.tdd (:use clojure.test))
09:21underdevis that my problem
09:22tomojhmm
09:22tomojit seems to only happen when you don't have an ns declaration
09:22jcromartieunderdev: I may have missed something, but are you just trying to eval (use 'clojure.test) from slime?
09:23tomojstrange bug
09:23underdevfrom a buffer, yes
09:23esjno, I have it with an ns too
09:23tomojbut anyway, you should have an ns declaration anyway
09:23tomojhmm, when I add an ns declaration it goes away
09:26jcromartieseems like a bug with clojure-mode?
09:26jcromartieperhaps '-related
09:27tomojI get the same error without '
09:27tomojjust a missing ns causes it for me
09:27tomojI think the bug is in swank-clojure
09:28jcromartiehmm
09:29tomojanyway, it doesn't bother me that much :/
09:29tomojns is a good thing
09:29jcromartieI can C-x C-e a (use 'clojure.test) expression
09:29jcromartieis that what you guys are doing?
09:29tomojno, clojure-test-mode
09:29jcromartieoh
09:29tomojC-c C-,
09:29jcromartieunderdev said he wasn't using that
09:30tomojhmm
09:30tomojI only see you saying you weren't using it
09:30tomoj:)
09:30underdevYEAH!
09:30jcromartieoh wow, I totally read that wrong
09:30jcromartie:D
09:30underdevthank you so much
09:31underdevi was trying to work from d:
09:31underdevLinux tcltk 2.6.18-164.2.1.el5.028stab066.10 #1 SMP Sat Dec 12 18:52:53 MSK 2009 i686
09:31underdevTo access official Ubuntu documentation, please visit:
09:31underdevhttp://help.ubuntu.com/
09:31underdev System information as of Wed Feb 17 07:03:36 EST 2010
09:31jcromartieNOOOOOOOOO
09:31underdev System load: 0.0 Memory usage: 0% Processes: 13
09:31underdev Usage of /: 3.4% of 20.00GB Swap usage: 0% Users logged in: 0
09:31underdev Graph this data and manage this system at https://landscape.canonical.com/
09:31underdev11 packages can be updated.
09:31underdev11 updates are security updates.
09:31underdevLast login: Wed Feb 17 00:26:05 2010 from cpe-98-27-227-21.neo.res.rr.com
09:31cemerickoh gawd
09:31underdevTo run a command as administrator (user "root"), use "sudo <command>".
09:31underdevSee "man sudo_root" for details.
09:31underdevsorry
09:32chouser_shouldn't the IRC clients have this fixed by now?
09:32underdevi'm just so sorry
09:33underdevthere is a tutorial on kakkaya.com that uses examples without namespaces
09:33tomojmaybe the bug didn't exist then, I dunno
09:34tomojanything real needs to have a namespace anyway
09:34underdevrt
09:34tomojthough I guess it might be convenient to be able to C-c C-, on a temporary file
09:34tomojjust to screw around
09:34underdevrt
09:34underdevat least o
09:34underdevi'll know how to advice the next guy
09:36underdevor cemerick can handle it
09:36underdev:)
09:41wthiddenany issues with metadata on functions in 1.2.0-master-SNAPSHOT?
09:51underdevas penance, i have posted a comment in his blog warning others of this problem
09:52chouserHuh. Blog comments in general make a lot more sense now ... I didn't realize they were penance.
09:53underdevin my case it is
09:54chouserthat must be why each blog as its own incompatible and slightly broken comment markup syntax
09:55underdevrt, his comment system crashed firefox twice, chrome handled it though
09:55rhickeyanyone try cells yet?
09:55AWizzArdThey are already available?? In what branch?
09:56AWizzArdSome days ago chouser and I were discussing and it sounded as a feature for the distant future..
09:56rhickeyjust a gist right now: http://gist.github.com/306174
09:56chousernot yet. my use cases are all in code using 1.1
09:57AWizzArdOkay, I must study them. Chris mentioned they may be usable in my DB.
09:57stuartsierraSomeone remind me again what cells are for?
09:57AWizzArdOho, they are implemented in Clojure :)
09:57AWizzArdWhere is the Java code? ^^
09:58chouserstuartsierra: new reference type
09:59AWizzArdOkay, do I need a specific branch to run this? When I compile I get: error: java.lang.RuntimeException: java.lang.IllegalArgumentException: Cannot assign to non-volatile: val (cells.clj:26)
09:59rhickeya cell is a new reference type that arbitrates the possibly multi-step/multi-threaded process of producing a new value
09:59rhickeyencapsulates the use of transients
09:59stuartsierraok, how is that different from transients?
10:00rhickeycan bring POJOs into the sane concurrency story
10:00chousertransients aren't a reference type at all
10:00stuartsierrayes
10:00stuartsierraSo a cell isolates an object on a single thread?
10:01rhickeynote in the examples in the gist, String/StringBuilder are used as Value/Transient duals
10:01rhickeystuartsierra: there are both single thread guaranteed and multi-thread capable cells
10:02rhickeyimagine a future (into "" some-source-of-chars)
10:02AWizzArdIs it okay to use the clojure.jar from build.clojure.org?
10:02AWizzArdTo try cells?
10:03stuartsierraAWizzArd: I think not
10:03chouserhm, hadn't realized pass/fetch would be macros and support object methods.
10:03rhickeyAWizzArd: yes, the latest build there has all you need
10:03AWizzArdok, I will then try this
10:04rhickeychouser: I'm still playing with that. I think it's critical if we want people to put their POJOs in cells that the perf be the same. Right now it can be. But the option for .method ==> fn is still open
10:05stuartsierraSo a cell is a mutable value locked in a thread-safe container?
10:06rhickeystuartsierra: the internal transient isn't a critical part of the story. They are still unique reference types in being coordinated and in serializing activity, not just data succession
10:07rhickeyso, using a cell instead of an atom would differ in that your function would never retry
10:07stuartsierraAh, so it's a means of serializing operations without the overhead of transactions?
10:07AWizzArdHmm hmm, this could be interesting on a lot of levels...
10:08rhickeythey (cells/refs) are at different points in a multidimensional space. Transactions can have arbitrary, discovered footprints, in that nested calls can enlarge the set of affected refs, whereas multithreaded cells have a fixed up-front footprint and don't support nesting
10:10rhickeyfrom a completely different perspective, cells might solve the 'stream' problem (and obviate chunks). I'm working on this now
10:10chouserI somehow thought that the ops for converting to/from the mutable version of the value would properties of the cell itself.
10:11rhickeychouser: that's a to-come option. If not provided would be based on protocol
10:12rhickeyI just haven't decided where to stick them (val/transient fns) and how to make their use fast
10:12chousera protocol that would for example be extended to String?
10:12rhickeythat protocol is in the gist right now, including extension to string
10:12chouserah, I see it
10:13cemerickstuartsierra: same here. :-/
10:13stuartsierraIs there a paper somewhere with the theory behind this?
10:13cemerickI was just going to suggest a assembla wiki writeup or something.
10:13rhickeystuartsierra, cemerick: well, I'd like to help you all understand, as I think this is very important, the missing piece of a complete model for state
10:14stuartsierraok, so why would I create a cell, and what would I do with it?
10:14chouserhave you guys looked at the previous IRC discussions?
10:14stuartsierrachouser: no
10:14rhickeystuartsierra: have you ever used a StringBuilder or transient?
10:15metaperlrhickey: would like write access to the wiki --- I'm bringing up a lot of points about the reference docs that need fixing and am willing to make what contribution I can
10:15cemerickchouser: I think I caught the first one (a few weeks ago?), but it didn't stick either.
10:15stuartsierrarhickey: yes
10:15chouserit makes the most sense to may as applied to transients ... I'm still trying to think through to understand these other possible uses.
10:15stuartsierraboth
10:15rhickeystuartsierra: then you need cells
10:15stuartsierraok
10:15rhickeycells make transients better, and potentially multithreaded. Cells make mutable things like StringBuilders safe and sane
10:16stuartsierraas in, safe to pass around to different functions?
10:16rhickeybasically transients had their polict built in - cells splits it out. Once split out, the policy can be applied bot hto the transient data structures and those less, ... well less
10:16chouseryes! just like all reference type objects
10:16rhickeystuartsierra: yup
10:16rhickeypolicy
10:17cemerickstuartsierra: that's what I said at first
10:17rhickeybut cells preserve a very important part of Clojure's state model, that observing an identity yields a value
10:18rhickeymonads embed serialization in a call sequence, but in doing so thwart parallelization
10:18rhickeymonads are essentially non-cooperative - this monad is mine, mine, all mine
10:18stuartsierra:)
10:19cemerickrhickey: but you can't have multiple threads whacking away at a cell either -- put a StringBuilder or a transient vector in one, and you'll still get garbled results, no?
10:19stuartsierracemerick: That was my next question
10:19rhickeycells stick with the identity/state/value model. They just acknowledge, as transients did, that sometimes creating the next state is a multi-step, and now possibly multi-participant, process
10:20rhickeycemerick: no! multi-threads whacking works!!
10:20rhickeya thread cell will prevent it, and a locked-cell will make it correct
10:20cemerickwell, works in that there's no breakage, or works in that the order of entrance into the cell is defined?
10:20Chousukeso, for creating a new mutable vector you could perhaps have one thread change one branch and another work on the other?
10:20Chousukecould that be coordinated with cells? :/
10:20chouserwould still be serialized in a locked-cell
10:20stuartsierrarhickey: So you're telling me I can make a StringBuilder, put it in a cell, append to it from multiple threads, and get a reasonable result?
10:21rhickeycemerick: what does it mean to define the order of independent activities? then they're not independent
10:21cemerickah...so only non-sequential data structures make sense in cells?
10:21rhickeystuartsierra: as cemerick just said, the sequentiality of Strings might not be useful
10:22chouseror sequential data structures where the order doesn't matter to you.
10:22rhickeybut it really depends on what you are doing
10:22Chousukecemerick: I think the idea is that only non-sequential things make sense in a multithreaded context in the first place :)
10:22rhickeychouser: right
10:22stuartsierraok
10:22cemerickok, so we should not talk about any stringy stuff at all
10:22rhickeygo process these web sites in parallel and ad your results to a vector - you might not care about the order in the vector
10:22cemerickmaps, structs, sets, etc.
10:23rhickeycemerick: if your granularity was lines, still might work for strings
10:23chouserit's important to do all your << inside the >> form, if you using that to build up the value?
10:23cemerickyeah
10:23cemerick...wonky java objects.
10:23rhickeychouser: inside which form?
10:24cemerickrhickey: so, say I'm keeping a reference to an embedded database in an agent right now, and using send-off to serialize access to it. Would putting that reference in a cell help me at all?
10:24rhickeycemerick: it's not just about Java objects - Clojure persistent/transient is made efficient, safe and multi-thread capable
10:25chouserI'm looking at the s4 example in the gist. if (<< .length ...) was done before >> and then its value used inside the >>, it would no longer be correct, right?
10:25rhickeycemerick: yes, it would likely be faster and the embedded DB could be a transient, only creating new values when read
10:26rhickeychouser: no, because you are wither single threaded or in-cells
10:26cemerickrhickey: why faster? Less/no thread mgmt?
10:26stuartsierraGoing back to the identity/state/value model: the 'value' is a mutable object, the 'identity' is the cell object, yes?
10:27rhickeyso, that's the other part of cells, multiple actions can affect the transient, even across calls, across threads, acrross multiple in-cells blocks, before a value is produced
10:27Chousukecemerick: that's still open
10:27rhickeystuartsierra: no - values go in, and values come out. The transient is locked in the cell, an implementation detail of the birth of a new value
10:27Chousukepass/fetch is the other suggested naming scheme
10:27cemerickhrm
10:28rhickeycemerick: pass/fetch are there - I encourage people to try both and give feedback from use
10:28rhickeycemerick: right, no thread dispatch, no message queues
10:28cemerickrhickey: I'm probably biased because of my string interpolation lib, but it is odd that cells get << and >>, but all other reference types have descriptive names for their "actions".
10:29stuartsierraSo a cell is kind of a magician's box: immutable data goes in, becomes something mutable, gets bashed around, then new immutable data comes out.
10:29rhickeycemerick: plus, cells can be coordinated where agents can't
10:29AWizzArd,(doc >>)
10:29clojurebotGabh mo leithscéal?
10:29rhickeystuartsierra: that magician's box thing happens every time you assoc to a Clojure persistent map.
10:29chouserI think it's not uncommon for people to use agents and then await on the results. In such circumstances, cells should definitely be considered instead.
10:29AWizzArdrhickey: how to cooperate?
10:30cemerickoh, I totally get it now. Yeah, cells, baby! :-D
10:30rhickeyAWizzArd: (in-cells [a b c] ...)
10:30wthiddenso this implementation of cells is getting "similar" to Kenny Titton's cells, yes?
10:30AWizzArdno
10:30AWizzArdvery different from, uhm, Tilton
10:30chouserrhickey: ah! ok, glossed over the in-cells. good.
10:30cemerickIf we can get transient sorted maps and sets, then this would make me *very* happy.
10:31AWizzArdcemerick: yes :)
10:31Chousukewthidden: http://gist.github.com/306174 this is apparently the entirety of the implementation for now :P
10:31AWizzArdI would be willing to "insert" in the exact correct order, if it only were faster, going around the comparator check
10:31rhickeywthidden: nothing to do with those kind of cells
10:31cemerickrhickey: yes, what sort of coordination are you referring to?
10:32AWizzArdcemerick: reads out of multiple cells
10:32rhickeyAWizzArd: also modifications of multiple cells
10:32rhickeyas part of a single unit of work
10:34rhickeystuartsierra: does the rationale for transients work for you? http://clojure.org/transients
10:34AWizzArdyes okay, now I just need to see the major difference from refs.
10:34stuartsierrarhickey: yes, and I've used transients successfully
10:35AWizzArdLike refs, but for state which is still in the process of being built?
10:35rhickeystuartsierra: ok, so, cells are a way to take the policy out of the transient data structure and put it in a reusable place, the cell, coupling it with work I had been doing on a lock-based reference type
10:35ChousukeAWizzArd: refs can't work with mutable data.
10:35Chousukeor rather, non-persistent data.
10:35chouseror other side effects.
10:35ohpauleezdoes anyone have the "Are we there yet?" video link on hand, I can't seem to google it correctly
10:35ohpauleezthe one that shows video and slides
10:35stuartsierraOK. Cells are a generalization of transients. Check.
10:36Chousukeohpauleez: add infoq
10:36AWizzArdSo, Cells are closest to refs?
10:36rhickeystuartsierra: but they go further in adding a second policy to single-threaded - lock-based multi-threaded
10:36chouserAWizzArd: I wouldn't say that. They have some properties like several reference types
10:36stuartsierrarhickey: Ah!
10:37rhickeystuartsierra: they also abstract out what it means to be a value/transient dual, and, right now, expose that as a protocol
10:37stuartsierraSo a cell does the work of wrapping access to some piece of mutable state in a lock.
10:37rhickeywhich means you can extend it to String/StringBuilder
10:37chouserAWizzArd: as I said, you might use a cell instead of an agent with a lot of awaits
10:38AWizzArdWith the cell fn being executed in the calling thread
10:38chouserAWizzArd: right.
10:38stuartsierraWhere in C, I would write spin_lock(x), modify(x), spin_unlock(x); in Clojure I can write (let [c (cell x)] (>> modify c))
10:38rhickeystuartsierra: as much as it is a feature of cells, the support for mutability inside isn't essential. In fact, I'd thought of making the default for transient/persistent be identity, so you can use with all Clojure value types
10:38chouserAWizzArd: and I've been doing ugly things with atoms (doing side effects in the update fn) that would be cleaner with cells
10:39AWizzArdchouser: well yeah, I am currently doing something similar. I will see how and where I can apply this now.
10:39rhickeystuartsierra: and as chouser is highlighting, the serialization of activity is a new feature vs refs and atoms
10:39AWizzArdBut a deeper understanding won't hurt :-)
10:40chouserAWizzArd: and yes, multiple cells can be coordinated like refs
10:40stuartsierraBut the basic idea is still a value protected by a lock, right?
10:40chouserrhickey: Is the mutation semantic really a property of the identity?
10:40rhickeyagents serialize activity, for a single reference. Like I said, it really is multidimensional.
10:41rhickeystuartsierra: there are still single-thread cells that throw on access from another thread too
10:41chouserstuartsierra: protected by a Sentry, which may be lock or something else
10:42rhickeystuartsierra: and as chouser says, the sentry abstraction is also broken out
10:42stuartsierraWhat other sorts of Sentries might there be?
10:43chouserhm. would there be any value in a Sentry that uses a real queue instead of just a lock?
10:43rhickeystuartsierra: dunno yet. Lock fairness is exposed tight now already
10:43rhickeyright
10:43rhickeyalso, sentry usage can be hierarchical. Given a cell, you can adopt it as a parent by making a new cell with the same sentry
10:44rhickeythus supporting coarser-granularity locking
10:45Chousukehmm
10:45chouserrhickey: will there never be a situation where I want a single identity to sometimes participate in-cells and other times in a dosync? Or whatever...
10:45rhickeyI'm still amazed at how tiny this was with deftype and protocols - 4 protocols, 2 deftypes, 4 extensions, bunch of macros and factories, 150 lines
10:46stuartsierraOk, some of the code makes more sense now.
10:46rhickeychouser: I think that would be extremely hard
10:46rhickeystuartsierra: yeah, obviously some docs strings are in order :)
10:46chouserYeah, I'm talking more about high-level semantics and design than implementation challenges.
10:46stuartsierraThere are 2 kinds of cells right now: ThreadCell is isolated to a single thread; LockCell uses a Java lock and supports access from multiple threads.
10:46ohpauleezChousuke: thanks a ton
10:46Chousukewonder if you could build a "dependency" system out of cells so that for one cell to yield a value, its parent cell must also be able to yield one. (otherwise it would block or something)
10:47rhickeyChousuke: that's a different notion of cells
10:47bosieis there a way to adjust the number of cores which arer used by agents?
10:49chouserheh. locks sorted by hash. :-)
10:50rhickeychouser: that may change
10:50chouserwhy?
10:50clojurebotwhy not?
10:50raekI think I'm starting to comprehend what cells are about...
10:51raekhow is << used?
10:51rhickeyI've never really stressed identity hash uniqueness, but a failure will be caught
10:51bosiei have 8 cores + 8 hyperthreaded chores. i have to use 16 agents to use my 8 physical cores which is obviously sub optimal
10:51raekit produces an immutable value, right?
10:52rhickeyso, if you look at the slides here: http://wiki.jvmlangsummit.com/images/a/ab/HickeyJVMSummit2009.pdf
10:52rhickeyslide 31 shows the epochal time model
10:53chouserraek: it ends up calling value-of on the "Transient" held in the cell, so yes that ought to return an immutable value.
10:53stuartsierraok
10:53rhickeywhat cells do is allow the Fs (pure functions), to become Ps (processes) that have some extent. This is only possible and correct if observers not involved in the process can only obtain state values (Vs)
10:53rhickeycells ensure that
10:54rhickeyand so, follow the model
10:54rhickeybut instead of saying - pure functions but correct use of transients is ok, makes a reusable construct for processes
10:55stuartsierraHmm. So a process can be bashing away at a value, and an outside observer can still see a consistent state at any time.
10:55rhickeyso, while functional people look at that diagram and see a monad, I never did. I always imagined multiple participants/parallelism
10:56rhickeystuartsierra: there's no such thing as bashing at a value
10:56rhickeyvalues are immutable
10:56stuartsierraarghhh.
10:56stuartsierraright
10:56rhickeythey bash at transients, which are *unobservable* outside of the process
10:57stuartsierraright
10:57rhickeythat's key, just like a transient inside the scope of a single function F would be
10:57AWizzArdWhile the fn is running all derefs in other threads will yield the value of the cell before fn started, yes?
10:57rhickeyonly now, F becomes P and can have some extent, while preserving the unobservability, and transitions of the identity from state to state
10:58stuartsierraSo the cell expands the scope of a transient to multiple processes, ok.
10:58ChousukeAWizzArd: wouldn't that be decided by the sentry?
10:58rhickeystuartsierra: right, or across calls
10:59ChousukeAWizzArd: I suppose sometimes you might want a deref to block instead of returning an old value
10:59rhickeyacross calls being equally critical and useful, especially when multiple cells are involved
10:59stuartsierraNuts, have to go to a meeting, back in a bit.
10:59raekso cells do transient-like stuff, but not limited to single functions, single threads or clojure transients?
10:59chouserAWizzArd: I think that depends on the type of sentry and the scope of in-cells (if that's being used)
10:59rhickeyraek: right
11:01chouserrhickey: any particular reason you don't import java.util.concurrent.locks.ReentrantLock in that gist?
11:01rhickeyAWizzArd: so, still in flux is value production. I've baked in one policy but there are several. Single thread cells produce a value on any deref. LockedCells create a value on any deref in-cells
11:01rhickeychouser: no
11:01rhickeybut there could be other policies - never auto-generate values, only on request for render
11:02rhickeyor, for locked cells, try to generate on deref but don't wait if busy
11:02rhickeyor, always enter the process to see if there is a new value on deref
11:03rhickeyI'm not sure if I will expose all of these. There are other composite ones like yields new value every N edits
11:03AWizzArdMaybe in some complex way they can be exposed, so if people really need such fine granularity it would be there.
11:04AWizzArdAnd some typical use cases for very easy use.
11:04rhickeysome knobs will be useful, as you have very distinct scenarios - heavy writing, any interim value is good, block writing, no interim value is good
11:04rhickeysporadic writing
11:04rhickeywhat is true in all cases is that the last value is remembered and constitutes the observable state
11:05rhickeylike the other refs
11:05chouserbut when the shole cell protocol is described in 12 lines of code, I wonder how many knobs are worth including before you just tell advanced users to write their own cell.
11:05rhickeyreferences
11:05rhickeychouser: could be, but want to avoid multiple implementations of common needs
11:06rhickeyelevensies (tea)
11:10raek>> and << are just synonyms for pass and fetch now, right?
11:10chouserraek: yes
11:16raekan observation: the order of the arguments of >> is not consitent with that of alter, swap!, send etc...
11:17raeki.e. f - ref - args instead of ref - f - args
11:18BrandonWis it wrong that i actually like the enforcement of loop/recur when creating a tail recursive function?
11:18the-kennyBrandonW: No, I like it too
11:19BrandonWgood
11:19BrandonWit just makes it seem more readable to me
11:19BrandonWwas wondering if i was missing something...
11:22chouserraek: that's intentional, to keep conversion of existing persistent code to the use of cells as straight-forward as possible.
11:23chouserhm, I wonder if it would make sense for >> and << to keep the arg order they have now, and make pass and fetch match the other reference fn arg order.
11:27raekchouser: I was thinking about that too...
11:29rhickeychouser: yes, I'm definitely not sold on the different arg order
11:34AWizzArdso far Strings and StringBuilder and some Clojure collections can be edited in Cells, yes? If I want to modify different objects I have to extend on a Protocol?
11:34chouserthat they're macros is another important difference.
11:35rhickeychouser: that could go away with .method fn literals
11:36chouseroh right, you mentioned that. That's mostly blocking on a decision about how they would support hinting?
11:37rhickeyI think I ended up with the generated fn having a type switch for overloads
11:38chouserI don't know what a type switch is
11:38rhickeyif it's a This do this, else if it's a That do that ...
11:39rhickeybut essentially, given .AClass/aMethod, generate a single fn that could deal with any arirty or same-arirty type overloads
11:40AWizzArdare pass/fetch supposed to be used in user code? Or will it be << and >>?
11:40rhickeyAWizzArd: right now, use whichever you prefer and report back
11:41chouserrhickey: oh, I see. I forgot about having the class in the symbol. so then a couple runtime tests would remove the need for any arg hints
11:42rhickeyright
11:42chouserbut I guess that might not produce a consistent return hint
11:42rhickeyalso right, but when used as a higher order fn, that's not really in play
11:43AWizzArdrhickey: do you think the pure Clojure implementation of Cells performs practically equally well, compared to a Java implementation?
11:43rhickeyAWizzArd: yes
11:46DraggorHey hey, so, is Programming Clojure the main book to get?
11:46chouserDraggor: it's the only complete book so far.
11:46AWizzArdRumours say another book is currently written..
11:46chouserDraggor: but some lovely options are on the way
11:47DraggorI've got a brithday coming up, and my programming book library is rather thin, so it's time to beef it up!
11:47chouserDraggor: There's one book from APress and two from Manning that have some chapters available online already.
11:49DraggorOh Apress, knew that was familiar, got PCL from there
11:50rhickeyso, today's wake-me-up-at-4am idea is - the transient dual of a seq is an iterator/stream-like thing. So, given appropriate plumbing, putting a seq in a cell will give you an allocation-free yet safe stream, convertible back to a value at any time
11:51LauJensenwow ... at 4am? :)
11:51mattreplhmm, I thought the variants ending with * (e.g., bound-fn*) were just function variants of macros. but what of list and list*?
11:51rhickeyLauJensen: unfortunately, that's frequently the case - I wake up working
11:52LauJensenSounds a little stressful - Long walks help. Anyway, the idea sounds incredible interesting
11:52Chousukemattrepl: the convention is not limited like that :)
11:52Chousukemattrepl: the * just means "variant"
11:53chouserlike x and x' ("x prime") in math. related in some unspecified way, yet different.
11:54StartsWithKwhat are << and >>?
11:55chouserStartsWithK: operators on cells, a new kind of reference object: http://gist.github.com/306174
12:01eyerisIn the definition of dotimes (or just about any other std macro), why is body deref'd but bindings is not?
12:02chouserthat's not a deref ~@ splices a list into the output, where ~ just inserts an item
12:03chouser,`(1 2 ~[:a :list] 4 5)
12:03clojurebot(1 2 [:a :list] 4 5)
12:03chouser,`(1 2 ~@[:a :list] 4 5)
12:03clojurebot(1 2 :a :list 4 5)
12:03eyerisOh. I see.
12:04eyeris,`(1 2 ~@[:a [:x :y] :b] 4 5)
12:04clojurebot(1 2 :a [:x :y] :b 4 5)
12:04eyerisThanks
12:04dnolenrhickey: so another silly mental model thing. are cells about perf at all the way transients are? using a cell to modify a string (via StringBuilder) will that be faster than modifying a string using Clojure primitives?
12:06rhickeydnolen: no, not about perf, but good perf. Strings can't be modified. Some string transforms could be done with stringbuilders, many not
12:12rhickeyimamgining transient seqs: http://paste.lisp.org/display/95115
12:12rhickeyimagining
12:13rhickeyso, lazy-seqx takes a recipe for a lazy seq and a recipe for a transient seq
12:13rhickeyall seqs on data structures support transient versions
12:14mattreplthis is looking like great stuff for agent-based models
12:15rhickeythen things like reduce and into can simply hoist a stream out of a lazy seq chain
12:15rhickeywithout giving up the ability to get a value at any time. And unlike the stream design, this is restartable/continuable
12:17chouseryou're too far away to hear the sound of my head exploding
12:17dnolenrhickey: for some reason I had gotten the notion that << is expensive, I guess not true?
12:17rhickeychouser: do you see where I am going?
12:17rhickeydnolen: not true
12:17dnolenrhickey: also what you're saying ^ seems to imply that into would be cheap (unlike how it is now)
12:18chouserI think so. still working on "restartable"
12:19rhickeychouser: the only things that wouldn't be restartable, and for which you couldn't use lazy-seqx. are seqs sourced from IO
12:19rhickeybut restartable/continuable means you could grab a val from a transient seq and then call move! on it - no problem
12:19djpowellrhickey: in JCIP he uses a tie-breaking lock of the identity-hashcodes are the same for two objects, and locks that, followed by the two locks in an arbitrary order. would that work for locked-cells - as a fallback
12:20chouserif you have a lazy-seqx obj, you can get either a seq or an Iter+Transient out of it
12:20rhickeychouser: right
12:20rhickeylazy-seqx would implement Editable in terms of a call to the latter
12:21chouserif you take the Iter, you can mutate it safely and at any point capture a lazy-seqx of the remainder
12:21rhickeyso (cell a-lazy-seq) works
12:21rhickeythe Iters are always in cells
12:22rhickeyyou can't directly touch them
12:22rhickeyThis solves the long-standing problems of iterators - you can't safely share them, and can't get values out of them
12:23chouserthe second expr in that lazy-seqx example is returning an Iter+Transient, but you're saying when I can't get that directly -- the lazy-seqx object would give me a cell of it instead (not collc but another cell)?
12:23chousers/when/that/
12:24rhickeywhen you said (cell lazy-seqx), that calls transient-of on it, which is implemented by it in terms of a call to the second expr
12:24rhickeyleaving you with that iter in the cell
12:25chouserok. then I can fetch the Iter and move! it?
12:25rhickeycalling transient-of directly is a no no
12:25rhickeychouser: use the iter through the cell
12:25chouserpass not fetch
12:25rhickeyyou can't get it out of the cell
12:26jlilly(-> world (nth x) (nth y)) ~= ((nth (nth world))) ?
12:26rhickeypass move!, fetch current
12:26jlillyerr. with the right number of parens, that is.
12:26chouserjlilly: (nth (nth world x) y)
12:27jlillychouser: ahh. that makes much more sense. and is apparent now that I reread the docs. thx.
12:28chouserrhickey: and @(cell lazy-seqx) gets me a regular sequence
12:28rhickeyright
12:29rhickeyeven after having move!d it a few times, and ok to move! it afterwards
12:30chouserright! and the cost of inserting a deref into that process is just a couple allocs.
12:30rhickeyright
12:30rhickeybut it means a chain of map filter blah blah turns into a single value-producing factory
12:30chouserthough walking the seq and the seqx would each compute each new value
12:31rhickeywhile in the cell
12:31rhickeychouser: yes, but no [lazy]-seq nodes
12:31rhickeyi.e. the fns produce values, but have to
12:31chouserlazy-seq nodes for the seq, but not for the seqx
12:32djpowellyou can use .method in your fetch/pass call, but usually in Java mutators return void - would calling mutators want any special support?
12:32somniumvery ot, but is there a convention for 'partial-ear-muffs', like choosing *foo vs. foo*?
12:32rhickeyonce you've put the lazy-seqx in a cell, there is no allocation other than that done be the work itself (e.g. map call (f x))
12:33rhickeydjpowell: possibly. The first use case - StringBuilder, happened to return the object
12:33chouserok, but that's an unusual case anyway. perfectly safe and hardly any more expensive than pre-chunk seqs. Most of the time a seq chain is used once.
12:33rhickeychouser: much less overhead than pre or post chunk seqs
12:34tomojsomnium: the only time I've seen that is for foo* as a helper to foo
12:34chouserI meant walking the same lazy-seqx from two different places, one as a seqx the other as a seq. Rare but still safe.
12:35rhickeychouser: oh, yes, the realized/lazy seq has same overhead as always
12:35chouserthat is, rare and each value gets computed twice (once for the seq and once for the seqx), but not terrible perf and a reasonable cost for the safety
12:36rhickeybut the critical thing here is that you can start with a bunch of normal lazy-looking calls in a chain, only to have the end consumer know they will slurp in in one go - they put it in a cell and bam - the seq is completely virtual
12:36rhickeyor reduce or int do that for them
12:36rhickeyinto
12:37chouserright. and a chain that includes links that *don't* use lazy-seqx will still use the cell for the spans of the chain that support it, right?
12:37rhickeyso, this dimension of cells is also quite important, IMO
12:38chouserhm, just the final span I guess.
12:38rhickeychouser: well, lazy-seqx is for computed seqs, but all of the concrete seqs will support editable. If a chain has non-Iter nodes then move! will fail
12:39rhickeyit's a good question
12:39chouser(->> big-vector (map f) (filter g) (partition 2) (map h) (filter i))
12:40rhickeyyes, put that in a cell and the whole calculation is virtual, no cons cells
12:40chouserRight. But in instead we assume map and filter support lazy-seqx, but partition does not ...
12:40chousers/in/if/
12:41rhickeyI understand
12:41rhickeyIO seqs the most likely problems
12:42chouserbah, screwed it up
12:42chouser(->> big-vector (map f) (filter g) (partition 2) (map h) (filter i) (into []))
12:42chouserthere. so if into also supports lazy-seqx...
12:42rhickeyfor ordinary seqs, move! == next
12:43chouserdoes the whole chain go lazy-seq, or can into drive a cell for map h and filter i, while pulling lazy-seqs from map f, filter g, and partition?
12:43rhickeythere is nothing about cells that demands the implementation be mutating
12:43rhickeyso, ordinary lazy-seq implements Iter where current == irst and move! == next
12:43rhickeyfirst
12:44rhickeyvalue-of == this
12:44rhickeydone
12:45chouserbut filter i will returh a lazy-seqx, right? and into would use the cell version of that?
12:45rhickeyoops, transient-of == seq. Now done
12:46rhickey(cell an-ordinary-lazy-seq) will work if ordinary lazy seqs, in the absence of a high-performing mutating impl, have a simple impl of Editable/Transient/Iter as above
12:47rhickeycurrent/first, move!/next, transient-of/seq, value-of/this
12:48rhickeybecause cells capture return values, they work fine with values
12:48chouserok, I'm not getting this detail, but I see how normal usages will always be compatible and sometimes be alloc-free. very cool.
12:48rhickeyand pure fns
12:49chousermuch easier to support than chunks as well, for individual seq library fns.
12:50rhickeyright. I'd still like to make that second expr more succinct
12:50rhickeybut with the above recipe for compatibility, people could add more efficient transient support as needed
12:51rhickeyi.e. lazy-seq looks exactly as it does now and support Iter/Editable as I've described, with no client help
12:51ordnungswidrigaloha
12:51rhickeyswithc to lazy-seqx (or whatever it is called), provide an Iter impl, and you're off to the races
12:53rhickeylazy-seq-iter?
12:54chouserheh. better than lazy-seqx. :-)
12:55jlillyhttp://pastie.org/private/hp1lhudpqpfjozqjlb7cq -- any chance someone can walk me through line 7 of this? Having a hard time with all the alters and assocs.
12:56jlillyor perhaps there's a better explanation of assoc / alter than (doc) ?
12:57arkrostHi! Tell me please what difference between let and let*.
12:57Chousukejlilly: it takes the value of p, and alters it by associng a value to the key :ant
12:57chouserarkrost: let* is an implementation detail. ignore it.
12:58Chousukearkrost: if you're looking at a macroexpansion, just treat let* as let
12:58chouserarkrost: if you're looking at macroexpand output, try macroexpand-1 instead -- might be clearer.
12:58Chousukeexcept that it doesn't support destructuring
12:58jlillyassoc :ant p is basically an equivalent of mymap['p'] = new_p ? (for other languages)
12:59Chousukejlilly: assoc takes the map first.
12:59Chousukejlilly: but in this case, because it's used with alter, it's *alter* that passes it the map, behind the scenes
13:00Chousukeeg: (assoc {:a 1} :b 2) -> {:a 1 :b 2}
13:01Chousukebut (def p (ref {:a 1})), (dosync (alter p assoc :b 2)), @p -> {:a 1 :b 2}
13:03jlillyso just to get all of my noob questions answered..
13:03Chousukejlilly: in most languages there's no direct equivalent for this
13:03Chousukejlilly: since they don't separate values from identities
13:03jlilly@p is really saying "Get me the value of the ref (ref being an indirect pointer to some data) p" right?
13:03Chousukeyes.
13:04jlillyand because that was in a dosync, and we altered p, p's new value should be {:a 1 :b 2} when we finish. right?
13:04Chousukeyes
13:04jlillyor, assuming someone else updates the datastructure out from under us, we'll at least know that p has :b 2 in it, b/c that's what our operation does. right?
13:05jlillymy interpretation of what happens is that it tries to alter the structure, fails, is told to retry, then it runs again on the updated datastructure?
13:05Chousukeat commit, yes. of course, someone might independently update it after the transaction has finished and right before you read it
13:06Chousukesomething like that happens, but it's just the implementation. the semantics are more important than what it actually does :)
13:06jlillyI'm basing nearly all of my knowledge here on ants.clj and the "clojure for java programmers" talk, despite not being a java programmer.
13:06jlilly:-P
13:07Chousukeheh
13:07jlillyI'm assuming that ants.clj is a solid reference for this stuff?
13:07jlillyor at least well written enough to based style and practices from?
13:07stuartsierraants.clj is old
13:07ChousukeI think it should be okay, but it's a bit dated in style.
13:08jlillyis there better example code?
13:08Chousukefor refs and such it's still valid. they haven't changed.
13:15bosieChousuke: but for the agents?
13:16Chousukeprobably :P
13:17bosiei am a bit confused with most of the concurrent programming articles in clojure. isn't refs nothing more than a mutable object?
13:17bosieto run it on multiple cores i always need agents, no?
13:17Chousukeno
13:18Chousukeyou can use threads to run functions on multiple threads :P
13:18bosieyou mean the java class Thread?
13:18Chousukeyeah.
13:19Chousuke,(do (.start (Thread. #(do (sleep 1) (println 'foo)))) (println "bar"))
13:19clojurebotjava.lang.Exception: Unable to resolve symbol: sleep in this context
13:19Chousukeeh
13:19Chousuke,(do (.start (Thread. #(do (Thread/Sleep 1000) (println 'foo)))) (println "bar"))
13:19clojurebotjava.lang.IllegalArgumentException: No matching method: Sleep
13:19Chousuke:(
13:20Chousukeoh well, something like that anyway
13:20stuartsierra,(do (.start (Thread. #(do (Thread/sleep 1000) (println 'foo)))) (println "bar"))
13:20clojurebotbar
13:20bosieThread/sleep
13:20bosieye
13:20Chousukehm, I guess the thing in the other thread got printed somewhere else :D
13:20stuartsierrayep
13:21Chousukeanyway, the thing is that refs are mutable boxes with well-defined concurrency semantics
13:23Chousukewhereas concurrently reading/writing regular mutable variables in a common language usually results in undefined behaviour
13:23Chousukewhich is why you need locks
13:27rhickeylive notes around cells, not docs! http://www.assembla.com/wiki/show/clojure/Cells
13:27ben_mGreetings! :)
13:29ben_mIn Clojure, what would be the best way to concurrently run some functions and then, after they're all done, return a list with the results?
13:29Licenseris there a document about this cell stuff aka what it is suposed to do in the future?
13:30rhickeyben_m: pmap or pvalues
13:31ben_mThanks! :)
13:31_fogus_Licenser: Chapter 8 of "The Joy of Clojure" ;-)
13:31LicenserNow I may sound stupid but what is "The Joy of Clojure?"
13:33Licenserah cells seem to be a way to encapsulate mutable objects in a imutable hull when I get the notes from rhickey right
13:41BrandonWis there some information posted somewhere on this talk of cells lately?
13:41BrandonWit sounds very interesting
13:41rhickeyBrandonW: logs here: http://clojure-log.n01se.net/
13:42BrandonWthanks
13:42ordnungswidrigwas there an agreement on the naming around cells? I left the conversation early the other day
13:48BrandonWwow that does sound useful
13:49rhickeyordnungswidrig: current best names in use now, all subject to change
13:49BrandonWi was just thinking today what the best way to wrap something like the java commons http client
13:50BrandonWif you could put that in a cell and operate on it (and any cookie containers and others objects that would get potentially altered by each use of the client) in a thread-agnostic way
13:50BrandonWjakarta*
13:51BrandonWalthough that might be better served with an existing threading mechanism
13:51ben_mI hate ELPA, it makes my .emacs messy :(
14:03ordnungswidrigoh, nice.
14:04ben_mAnyone using clojure with slime without using ELPA? If yes, could I see your .emacs?
14:04technomancyben_m: if your .emacs is messier with Emacs than without, you're probably confused about how to set it up.
14:05ben_mMight be true
14:05technomancybecause it should be one or two lines
14:06ben_mWhen I last tried it I had to do a lot of config in my .emacs to get stuff to work after I started using ELPA
14:06ben_mSo I got rid of it
14:08maxhodakhey -- i need some help debugging this: http://github.com/franzinc/agraph-java-client/blob/agraph32/clojure/src/com/franz/util.clj
14:09maxhodakbasically what they're doing is using (declare) and then referencing a variable (*with-open-stack*) before it gets bound, leading to fail
14:09maxhodakand i can't figure out the right way to solve it
14:10maxhodakL29 and L49 are the most interesting
14:11maxhodaki've already changed contrib.stacktrace to clojure.stacktrace
14:11rhickeymaxhodak: they document you're not supposed to use those outside the scope of with-open
14:12rhickeymaxhodak: with-open2 binds *with-open-stack*
14:14maxhodakrhickey: hmm, let me find where this is called; it's deep enough inside their logic i'd be surprised if the with-open was needed all the way up
14:15maxhodakhttp://github.com/franzinc/agraph-java-client/blob/agraph32/clojure/src/com/franz/agraph.clj#L28
14:15maxhodakso i call agraph-repoconn on L37
14:16maxhodakdo i need with-open outside of my invocation of that?
14:19Chousukemaxhodak: seems like anything that calls open needs to be within a with-open2 context
14:21Chousukemaxhodak: and that means dynamic scope, so anything that might call open in any way to be wrapped in with-open2 :P
14:21Chousuke+needs
14:22maxhodakChousuke: ok, thanks, i'll try that
14:22maxhodakrhickey: thanks for pointing out "read the obvious doc" too
14:22Chousukemaxhodak: looks like you can use the scope* functions too
14:23Chousukeor macros :P
14:25lancepantzclojure-yaml/clojure-build.xml:86: Could not find clojure.lang.Compile. Make sure you have it in your classpath <----- looking for clojure.jar in my classpath, right?
14:27lancepantzbecause clojure.jar is indeed in my classpath
14:27lancepantzi have no clue what is throwing that error
14:33chouserHuh. From twitter: "Moving from #clojure to #scala, watching as the entire software community passes me going in the opposite direction."
14:34Chousukeheh
14:34rhickeychouser: I saw that - funny
14:34ben_mScala is interesting
14:35ben_mBut it's not a Lisp :D
14:35chouserlancepantz: I've not seen a stack trace pointing at a line in an xml file before. Is that maven or ant or something?
14:35lancepantzant
14:35lancepantzwhich i'm new and unfamiliar with /idiot disclaimer
14:37rhickeynames again - Iter interface: has-item, item, move! ?
14:38rhickeyI don't like has-item
14:39chouserhas-item is the complement of empty?
14:39rhickeykinda
14:39lancepantzso no one can make sense of that ant error? because otherwise i'm going to have to use jyaml :/
14:39lancepantzand i really don't like java :)
14:40Chousukelancepantz: maybe you need to pass ant some parameter that tells it where clojure.jar is :/
14:40Chousukefor contrib it used to be ant -Dclojure.jar=/some/path
14:40lancepantzcool, let me try it
14:41Chousukelancepantz: take a look at the build file and see if it has something like ${clojure.jar} or whatever
14:41rhickeychouser: the protocol is (when (<< has-item cc) (use-it (<< item cc)) (>> move! cc))
14:42jlillysanity check, is #(..) shorthand for defining a macro on the fly?
14:42rhickeyone benefit of has-item is it keys you into the fact that you (must) call it before item
14:43Chousukejlilly: no, a function
14:43jlillygot it. thx.
14:43chouserso has-item/item/move! are used very roughly where one would ahve used seq/first/next
14:44rhickeyright, except the return of has-item isn't useful except in a conditional
14:44jlillyChousuke, and % represents the the args to the function?
14:44Chousukejlilly: the first arg
14:44Chousukejlilly: %n represents the nth arg
14:44chousersure
14:44Chousuke% is short for %1 :)
14:48Chousuke(when (fetch permit cc) (f (fetch item cc)) (pass move! cc)) :P
14:50jlillyChousuke, so I don't have to keep bothering you, is there a place that lists all of these # syntax things? I think I've come across #( #' and now #^
14:50Chousukeclojure.org/reader does I think
14:50jlillyrokk
14:57ben_mWhen editing Clojure code with paredit and I'm typing a closing ], it jumps to the end of the expression. Can I disable that somehow?
14:57Chousukeisn't that what it's supposed to do? :/
14:58ben_m(defn foo [n]), after pressing ] it jumps to the ), so I have to move the point back a character before I can write the rest of the defn
14:58ben_mpoint being at n
14:59ChousukeI think I should fix my paredit. it doesn't work properly in slime.
14:59Chousukeben_m: works for me. :/
14:59ben_m:/
15:00ben_mMaybe my paredit version is old
15:00morphlingben_m: you can move out of [] by typing ), regarding your question: you can find out what ) is bound to and bind ] to the same
15:00ben_m] and ) do the same thing for me
15:00ben_mBut they're bound to different functions
15:01chouserif a sequence isn't made up of items, perhaps it's made up of steps?
15:02chouserstep, do-step!, steps-done? :-/
15:02morphlingben_m: ah, ok, then I have no idea
15:03Chousukechouser: I think it would have to be steps-left?
15:03chouserah, better.
15:04Chousukebut "step" is a common local name already ;/
15:05chouserstep isn't right anyway. There is an action involved, and make next-step would work, but item is supposed to return the result of the pervious step, not the action itself.
15:05rhickeychouser: it has to be really clear which order to call. Both Java and .Net collapse these into 2-method protocols in order to avoid mistakes, and still added foreach. But we can't combine like hasNext/next of Iterator since next needs to return the item and move, but we need to capture the moved iter
15:06chouserJava's .next() freaks me out.
15:06rhickeythe first cut I showed had move! potentially returning nil when done, but was eager, and longer than the 3-method impl
15:07Chousukehow about the "permit" name I suggested? :P
15:07chouserthe counter arithmetic in gvec's ListIterator implementation seems almost completely arbitrary to me.
15:07rhickeychouser: it has one benefit which is you can only call it once. current usually means having to cache. I don't intend to, so multiple calls to current/item mean multiple calls to work
15:07chouserhm, so it is like redoing the current step
15:08rhickeyChousuke: permit doesn't work for me
15:08rhickeychouser: yeah, although I'm not keen on step. These will operate over plain data also
15:09chousersure, but are still logical sequences.
15:09chouserI don't like 'step' either, just trying to get ideas flowing.
15:09rhickeyyes, but step implies 'job/work' to me
15:09chouseritem is so generic
15:10rhickeyyes, item is, but it is just data. first still works, sort of
15:15technomancyoh nice, metadata on fns landed.
15:15technomancythis pleases me. =)
15:43stuartsierraAm I correct in thinking that any class that will be stored in a cell must extend Editable and Transient?
15:44rhickeystuartsierra: there might be per-cell options to specify to-transient and to-value functions, otherwise yes
15:45stuartsierraok
15:49stuartsierraSo: one reasonable use case: I create a date/time datatype, extending transient-of to return a java.util.Calendar. Then extend value-of on Calendar to return my date/type type. Then I can put a Calendar in a cell and roll it, but get a reasonable value back out.
15:51rhickeystuartsierra: you would put the value in, and the cell would call transient-of/value-of as needed. But yes, values in and out
15:53stuartsierraright
15:54stuartsierraIn that case, what benefit does the cell give me?
15:54cemerickrhickey: caught up on logs, I'd say I grok the important bits. Stellar stuff.
15:56chouserseems like it may be reasonable to put a mutable thing in a cell in an agent, when you might now just put the mutable thing in the agent and try to remember to never mutate directly.
15:56rhickeystuartsierra: well, a cell gives you identity (as do all ref types), so if that data was a 'due date' or something that might be associated with different values over time, the same benefits would apply. Processing a date functionally is pretty cheap so no real benefit to the transience. But changes to the date could be coordinated (like refs), and activity serialized
15:56rhickeyalso if you pass it around you will get thread safety checks
15:57rhickeyunlike a raw Calendar
15:57stuartsierraRight, so I'm protected from mutating it from multiple threads.
15:57rhickeyyes, if you want to be. or coordinated across threads if desired
15:58stuartsierraSo a cell is most useful in the case when realizing a persistent value could be expensive.
15:58rhickeyi.e. if any logged in user's thread could change the due date
15:58ben_mHow do I specify a -D argument when starting clojure in Emacs?
15:59stuartsierraben_m: use a shell script
15:59rhickeystuartsierra: I'm not going to let cells be pigeonholed like that. There are a number of use cases related to the serialization of activity that still apply even if the contents are pure values (which will be possible)
15:59chouser(send agt #(>> set! (.field %) val))
15:59rhickeyalso see recent conversation about transient seqs based on cells
16:00stuartsierrayeah, those left me even more confused.
16:00rhickeyhrm
16:00stuartsierraSo: cell guarantees transition going in (transient-of) and transition coming out (value-of)
16:01rhickeyyes, but you could use with Clojure data values by supplying identity for both. It's not just about transience
16:01stuartsierraok
16:02rhickeypeople sometimes need once-and-once only activity coordinated with data change
16:02stuartsierraMore importantly, it guarantees that all operations on the thing inside the cell will be mediated by >>
16:02chouserset! was a bad example -- I was thinking something that took some work thus useful to do in another thread.
16:02ChousukeWas the idea that you could specify two ways of generating a seq: a persistent and a transient one; then a function which knows it's going to consume the entire seq will request the transient version?
16:02rhickeychouser: not sure of the benefits over (future (>> foo! acell))
16:03chouseroh, good point.
16:03rhickeygiven the cell must be lock-based for any thread pool access to work
16:04rhickeyI wonder if a shorthand for (in-cells [c] (>> foo! c)) is in order
16:04chouseryeah, I hadn't thought of using future there. cell instead of agent+await. future+cell instead of agent
16:05rhickeythe diff with latter being a defined order on sends from same threads
16:06rhickeyagent+await should die
16:06rhickeyalmost always a bad design that's avoiding latches or queues
16:07rhickey(pass-in foo! c) ?
16:11chouser(in>> foo! c) ? :-P
16:18powr-tocJust watching Rich's awesome lecture on clojure's philosophy for time management (again)... And I'm wondering where these ideas on the seperation of identity, state, values and time come from... Are there any other languages that share these notions, or is clojure unique?
16:18powr-tocif so are there any references (beyond whitehead etc...) to this?
16:21chouserman, it *so* frustrating to get stack traces that include a line inside a try-block that was somehow never caught
16:21Chousukethere is at least one language where time is a fundamental type. Processing only occurs if you advance time.
16:22powr-tocChousuke: do you have a reference/
16:22powr-toc?
16:22chouserI've seen this before, and it hurts every time. Sometimes it's a wrapped exception thing, but right now I have (catch Throwable e ...) and it's still not catching
16:22Chousukepowr-toc: I think it was this one http://chuck.cs.princeton.edu/doc/language/
16:23hiredmanchouser: maybe a lazy thing, or a delay of some kind
16:24hiredmanmacro re-arranging something?
16:24hiredmanline numbers could be lies
16:24powr-tocChousuke: cheers... what about Rich's critique of OO's confused mix of identity, state and time? Are there any papers or other work mentioning this?
16:25ChousukeI'm not aware of any
16:25chouserhiredman: those are all good thoughts, but I don't think any of them apply here.
16:27hiredmanprintln time
16:27technomancydebug-repl!
16:27chouserI'm catching it successfully at an outer level, where it claims to be a java.lang.IllegalArgumentException
16:27hiredmanprintln at the top of the try and at the bottom
16:27Chousukeyour catch form has illegal arguments! :P
16:27chouserChousuke: :-P no it doesn't
16:28Chousuke(or the try form)
16:28ChousukeI wonder what happens if you do (try foo (catch ...) blah)
16:28underdevpowr-toc: the notions of time/state/identity seem to me more along the lines of kant vs hume than identity
16:29underdevwhiteheads notion of identity, state, and time would be very different
16:29chouseroh, no I'm successfully catching in an *inner* scope.. dang it. my tests have been faulty
16:29chouserChousuke: compile error I think
16:30chouser,#(try 0 (finally 1) 2)
16:30clojurebotchouser: I don't understand.
16:30chouser, #(try 0 (finally 1) 2)
16:30clojurebotchouser: It's greek to me.
16:30underdevie higher order actual occasions would have intrinsic identity, with state changing due to prehensions, with time created to accomodate the change in state
16:30chouser,(fn [] (try 0 (finally 1) 2))
16:30clojurebotchouser: It's greek to me.
16:30powr-tocunderdev: Thanks I might well check that out :-)... but I'm wondering if there is an argument similar to Rich's in cs literature anywhere.
16:30hiredmanclojurebot ignores try's
16:31chouserhmph
16:32chousermight proxy eat an exception?
16:33hiredmanpircbot tends to eat exceptions
16:33hiredmanchouser: what do you mean?
16:33hiredmanmethods on a proxy object, inside methods?
16:34chouserwait...
16:36chouserok, there are a few extra layers of proxy and macro involved here than I was thinking.
16:36chouserwhy do I create such complicated things!?
16:37hiredmanyou are driven by a faustian bargain with management
16:39chouserI can't blame management -- they leave me alone here, to create my own hell...
16:40somniumyay freedom
16:40Chousukeat least it's a hell written in clojure
16:40chouserChousuke: yes!
16:41chouserBut that means I can't blame management *or* the language. Which leaves ...
16:41chouser... google protobuf! *whew* that was close.
16:43jasappchouser: how did you convince management to let you write in clojure?
16:44chouserthey are enlightened :-)
16:44hiredmandepending which faust you read that could work
16:44jasappnice, I'm jealous
16:44chouserit's mostly meant as "prototype" code. We'll see if it stays that way. :-)
16:45chouserwe're hiring!
16:45jasappworking from home ok?
16:46ben_mI'd relocate for a Clojure job
16:46ben_mheh
16:46chouserhttp://www.sentryds.com/company/employment/
16:47jasappI would, but my wife wouldn't
16:47jasappguess she'd just have to deal with it
16:47ben_mtell her it's clojure
16:47ben_mShe'll understand
16:47eyerisIs the complexity of expanding -> linear or better?
16:47chouserMany of us work from home. Some of us write in Clojure.
16:47chousereyeris: -> is all at compile time -- no runtime cost
16:48powr-tocchouser: looks like an interesting company
16:48eyerischouser: Right. I have a program that could be written as one huge -> macro with 1000+ forms.
16:48hiredman:(
16:48eyerisWould it take forever and a day to compile?
16:48chouserha! I have no idea
16:48ben_m"4 year undergrad degree or higher"
16:48ben_mMeh :(
16:48Chousukeeyeris: I think you wouldn't even notice the difference :/
16:48hiredmanthe compiler expands macros recursively (not iteratively)
16:50stuartsierragot to get my resume together
16:50hamzagents, is there a way to check if calling deref on a future object will block or not?
16:50Chousukefuture-done? I think
16:51hamza,(doc future-done?
16:51clojurebotEOF while reading
16:51hamza,(doc future-done?)
16:51clojurebot"([f]); Returns true if future f is done"
16:52hiredmanman, github fails horribly at displaying Compiler.java
16:52hamzaChousuke: thanks a lot, hate it when functions have obvious names :)
16:52hiredmanI guess it could be firefox fails at displaying github displaying Compiler.java
16:54Apage43i'd tell you how IE6 handles it but I don't think it'd be worthwhile to know
16:54stuartsierraSo I was thinking about rewriting clojure.test yesterday.
16:54stuartsierraBut I don't know if it's worth the trouble.
16:56chouserstuartsierra: what would you do to it?
16:56stuartsierraRedesign around first-class objects.
16:56stuartsierraI.e., a Test is a collection of Assertions.
16:57eyerisIndeed, hiredman, a ->> macro with 1000+ forms results in a stack overflow :(
16:57eyerisDarn
16:57stuartsierraa Test runs in one or more Contexts
16:57stuartsierraContexts are nested hierarchically..
16:58stuartsierraRunning a set of tests produces a sequence of TestResults
16:59technomancyI like the idea of more separation between assertions and the setup they require. the intermixing of these is probably the greatest hindrance to test readability in my experience.
16:59stuartsierrayes, that was the big idea
17:00stuartsierraWriting tests as fns is easy, but mixes assertions with setup/teardown.
17:00stuartsierraThat's one thing that object-oriented test frameworks actually do better.
17:00powr-tocIs there an explanation of what Cells are yet... I saw the discussion on this channel about them, but would like to understand more about them
17:01chouserpowr-toc: your most complete and accurate info will be IRC for a while. They're too much in flux to warrant real docs yet.
17:01chouserpowr-toc: there is the implementation and "notes" links -- you saw those?
17:02powr-tocchouser: no, I don't think I did... Are they on assembla?
17:02chouserpowr-toc: src/java/com/sentryds/qdc/rpc/clojure.clj
17:02chouserer
17:02chousernot that
17:02hiredmanit is amazing how fast stuff goes from rhickey saying "I am playing around with idea X" to everyone demanding docs for X
17:02chouserpowr-toc: http://gist.github.com/306174 and http://www.assembla.com/wiki/show/clojure/Cells
17:02powr-tochiredman: lol
17:02Chousukehiredman: heh
17:02stuartsierrahiredman: Because no one understand's rhickey's code.
17:02rhickeyouch
17:03Chousukestuartsierra: I think that only applies to java
17:03stuartsierrarhickey: No offense meant, it's beautiful code.
17:03powr-tocChousuke: yeah I saw that gist... somehow missed those notes though
17:03stuartsierraIt's just so abstract that it's rarely obvious what it's for.
17:05hiredmanrhickey is fluent in the language he is writing while the rest of use running around with dictionaries
17:06stuartsierrahiredman: good analogy
17:06stuartsierraRe testing again, the problem I'm stuck on is how to share values between assertions and setup/teardown.
17:06stuartsierraclojure.test fixtures do it via dynamic bindings, but the syntax is awkward.
17:06powr-tocChousuke: I've found that the java code I've looked at has mostly been very clean and readable... Just very un-idiomatic... I've only skimmed it though
17:07stuartsierraAnd if you're not defining setup and assertions in the same fn body, you can't use let-bindings.
17:08Chousukepowr-toc: I suppose the un-idiomatic feel comes from the functional data structures used and the style in general. at least the reader was like that.
17:08hiredmanstuartsierra: unless you use eval
17:08hiredmaner
17:08stuartsierraBut eval doesn't capture lexical scope, right?
17:08hiredmanforget I said that
17:08hiredman:/
17:09stuartsierra,(let [x 42] (eval 'x))
17:09clojurebotDENIED
17:09stuartsierraAnyway, it throws "x not defined"
17:11chouseryou could put the tests inside the setup/teardown via macros.
17:11stuartsierraI thought about that.
17:11chouserdo you setup/teardown per test?
17:11stuartsierraI want to support both options: once per test and once per test suite.
17:12stuartsierraBut if the assertions are inserted into the setup/teardown code, then there could be a clash of locals.
17:12hiredmanyou can have the assertion creation macro analyze forms for free symbols and generate a function taking a map that does keyword destructuring
17:12stuartsierraAnd setup/teardown contexts are no longer reusable.
17:12chouserdon't you *want* to capture the locals?
17:12stuartsierrano
17:12chouserthen what are you setting up?
17:13stuartsierraOr, I want something that *looks* like local capture, but in a safe manner.
17:13stuartsierrahiredman: That's where I might be headed.
17:13stuartsierraBut it seems so complicated.
17:14stuartsierraI want something that looks more like fn pre/post conditions.
17:14chouser(defwrap foo (let [a ... b ...] (.open b) :insert-tests-here (.close b))) (with-wrap foo (.write a "blah"))
17:14hiredmantree-seq is your friend
17:14technomancystuartsierra: per-test-suite really means per-ns, right?
17:14stuartsierratechnomancy: In the current definition of a suite-as-namespace, yes. But
17:15stuartsierraIdeally, I'd want to support nested suites.
17:15hiredmanwhy?
17:15clojurebotwhy not?
17:15hiredmanclojurebot: thanks!
17:15clojurebotExcuse me?
17:15technomancyif you support nested contexts wouldn't that amount to the same thing?
17:15hiredmannesting :(
17:15stuartsierraNot quite.
17:16stuartsierraI tried to make it possible to run a single test at the REPL by calling a function.
17:16stuartsierraWith fixtures, that doesn't work, because the test function doesn't know which fixtures it needs.
17:16stuartsierraBut if the test retains a reference to the contexts it needs, it can be run by itself.
17:17stuartsierraOr in the context of a test suite, without running fixtures more times than necessary.
17:18ordnungswidrigstuartsierra: oh running single tests would be very nice
17:19stuartsierraclojure.test already supports that, just not with fixtures
17:19technomancyordnungswidrig: clojure-test-mode makes that pretty easy in Emacs
17:19StartsWithKstuartsierra, i used http://paste.pocoo.org/show/179465/ a syntax similar to let form in my tests, is this what you would like to do?
17:20ordnungswidrigtechnomancy: really? I always run all tests using C-,
17:20Raynestechnomancy: Ola Bini apparently heard my cries. He's strongly considering moving Ioke to a new repo with no history. :D
17:20StartsWithKfor once/every i was planing to use memoize over the setup function, but don't need that for now
17:21stuartsierraStartsWithK: That's pretty close to what I had in mind.
17:21technomancyRaynes: high-five
17:22technomancyordnungswidrig: C-c M-,
17:22ordnungswidrigtechnomancy: nice, I'll try
17:27dakronetriyo: neat, is it opensource?
17:28cemerickstuartsierra: did you leave out basic auth in http.connection intentionally?
17:28triyodakrone: well not as of yet. I'm gonna clean up the code a bit over the weekend, hopefully, and put it up on github.
17:28stuartsierracemerick: no, just an omission
17:28dakronetriyo: cool, look forward to it :)
17:29stuartsierracemerick: http.connection is another child of mine that needs to die
17:29stuartsierraNot to sound nihilistic or anything.
17:29cemerickreplaced by?
17:29stuartsierraSomething involving the Apache HTTP client.
17:29cemerickheh
17:30cemerickI suggested that many moons ago, but people didn't like the notion of 3rd party deps.
17:30cemerick;-)
17:30stuartsierraAnother reason why contrib itself needs to die.
17:30stuartsierraBasically, everything sucks. ;)
17:30cemerickThat's funny, since you're probably the leading contributor :-D
17:30stuartsierraI know.
17:30cemerickbut yes, I absolutely agree
17:31stuartsierraIf rhickey could stop revolutionizing computer science long enough to care about menial details like packaging...
17:31stuartsierraOr if Maven 3 really IS a unicorn...
17:32stuartsierratriyo: immigration doesn't work
17:32hiredmanyeah, compojure is hardly a beacon of light for the masses
17:33jasapphiredman: why do you say that?
17:33hiredmanthe use of immigration for one
17:33triyohiredman: once you dive beyond a hello world web apps, it stings.
17:33cemerickstuartsierra: at a certain point, I'm going to have to start caring about what rhickey is doing only once every 3 months or something ;-)
17:33hiredmanthe single segment namespace, but that should be fixed next release
17:34hiredmanI mean it works, and is fine, but it is not a paragon of style
17:34cemerickanyway, binding start-http-connection is a perfectly decent way of adding basic auth to contrib.http :-)
17:34stuartsierracemerick: Ah, good. Glad to be of service. :)
17:35hiredmancemerick: until direct binding bites!
17:35technomancyI thought base64 was added to contrib specifically to support auth in contrib.http
17:35jasappI'm trying to think of web frameworks that are paragons of style
17:35technomancyor was that something other than basic auth
17:35cemerickhiredman: direct binding?
17:35stuartsierratechnomancy: I started base64 but quit before I finished.
17:35hiredmanjasapp: ok, but immagration and single segment namespaces are *grossly* bad style
17:35technomancyheh
17:35hiredmancemerick: no rebinding
17:36jasappagreed.
17:36Chousukesingle-segment namespaces aren't just bad style, they break things :P
17:36cemerickhiredman: totally not following you (not the firs time, tho ;-) )
17:36hiredmanimmigration
17:37hiredmancemerick: as mentioned single segment namespaces break stuff
17:37jasappcan you explain? I have no idea what immigration is
17:37hiredmanand immigration is just icky
17:37triyoagreed
17:37triyoto much magic :)
17:37somniumthe immigration was a failed experiment, but the goal was noble
17:37hiredmanit re-defs stuff in a new namespace basically
17:37jasappahh, ok
17:38hiredmansomnium: road to hell... etc
17:39RaynesI read that as 'rot in hell'.
17:39Raynes:o
17:39somniumhiredman: noble goals are the road to hell?
17:39_mstgood intentions :)
17:40hiredmanhttp://idioms.thefreedictionary.com/road+to+hell+is+paved+with+good+intentions
17:48kylesmithIs anyone here good at writing parsers?
17:50shrughesit depends how you want to write them
17:50hiredmanif I was any good writing parsers why would I use lisp?
17:50triyohehehe
17:50hiredmanI kid, I kid, I love the parens
17:51kylesmithI need a parser for CIF files, but some of the files do not follow the format exactly.
17:52triyo* patching=matching
17:53hiredmanfnparse is the only clojure parser library I have used at all, it is ok
17:53kylesmithFYI, the files are in this zip file http://www.crystallography.net/cod.zip (BEWARE, 314 MB)
17:54hiredmanconstantly under developement and changing though
17:54hiredmanwhich can be a drag
17:55kylesmithI don't mind using a library, but due to the irregular nature of these files, I need to be able to first try the correct way to parse the file, then try another way, etc.
17:55hiredmansure
17:56hiredmanfnparse just creates functions that have a certain input and output
17:57triyonight all
19:11powr-tocDoes anyone else find it annoying that the API docs at http://richhickey.github.com/clojure/ don't link back to clojure.org? It's hard to browse to the docs for special forms etc...
19:14technomancypowr-toc: I think the real problem is that so many special forms lack docstrings
19:14technomancyor they just say "see clojure.org for details"
19:14powr-toctechnomancy: yeah, that's really annoying too
19:15powr-toctechnomancy: what's the procedure for submitting documentation patches/suggestions?
19:15powr-toccan I just github fork?
19:15powr-tocpresumably I'll need to sign a contributor agreement
19:15technomancypowr-toc: yeah, but don't use pull requests. http://clojure.org/contributing
19:15technomancythat too
19:17powr-tocI also find the docs for reduce a little cryptic... Especially how it doesn't document the form of the function you pass it very well.
19:23technomancyreduce is really hard to explain well without some sort of visual aid
19:24powr-toctechnomancy: true... but my problem isn't in understanding reduce, more remembering the order of arguments for the supplied function... I always get the accumulator and current item mixed up
19:24powr-tocand the docs dont even mention the order of arguments there
19:28dnolen,(:arglists ^#'reduce)
19:28clojurebot([f coll] [f val coll])
19:30powr-tocdnolen: yes, but reduce requires f to take two arguments. The order of those arguments are not mentioned.
19:32dnolenpowr-toc: yeah I see what you mean. I suppose that's what clojure.contrib.repl-utils source is good for. In Emacs I'm always jumping into the core definitions to see how things work. refreshing actually coming from other langs.
19:34powr-tocdnolen: ahhh a handy package, thanks for the pointer... yeah having clojures source code to hand is seriously handy and far more accessible than in most languages
19:39dnolenpowr-toc: only thing cooler
19:39dnolenwill be when Clojure is written in Clojure. will be almost Smalltalkish then
19:41powr-tocdnolen: yeah that'll be sweet! But I do worry that the whole bootstrapping/meta-circularity thing might make things a little less accessible
19:41hamzaguys, I have a func called start defined in leiningen.start namespace but lein is not picking it up. lein help start says it can't find the file but it is there this in a fresh lein project.
19:42dnolenpowr-toc: in what way do you mean?
19:42dnolenhamza: and is your source organized src/leiningen/start.clj ?
19:43hamzadnolen: yeap its the only file there..
19:45powr-tocdnolen: I think clojure in clojure will totally rock, and absoloutely is the way to go... I just think a big part of my learning clojure was digging through the clj and java source code and seeing things grounded in a language I knew (Java)... If it's turtles all the way down, that learning process is harder
19:46powr-tocdnolen: Plus you'll need a build of a clojure to build clojure, which makes the build process more convoluted
19:46dnolenhamza: hmm I'm assuming you're writing a plugin, I note that lein-swank itself can't work that way.
19:46powr-tocdnolen: But everything else is pure upside!
19:48hamzayeap its a plugin, are you saying i can't test it until i build a jar and add as a dev-dep?
19:48dnolenhamza: I just wrote my first lein plugin for dealing with native deps today, and I know it works if you build a jar and add as a dev-dep.
19:49dnolenhamza: and put in your lib directory
19:50hamzadnolen: kk so during testing just mock something for the arguments to the function?
19:50dnolenpowr-toc: heh, not knowing Java well, I haven't had the experience you have. It also seems Clojure attracts a lot of people with only passing familiarity with Java. Being written in Clojure widens the number of people interested in contributing core code.
19:51dnolenhamza: heh, I didn't bother writing any tests for my plugin too simple for that really. but that sounds like a good approach.
19:51hamzadnolen: kk thanks alot.
19:53slyphonargh, i hate log4j
19:53powr-tocdnolen: I don't disagree... I just think it's a sign of clojure growing up... I'm happy for it to become an adult, but I'll miss its childhood.
19:55nuggienif i have a java class Foo with a constructor like Foo(Bar b) where Bar is an interface and Baz is a class implementing Bar, and in clojure I do (let [x (Foo. (Baz.))] ...) why does it keep telling me Baz cannot be cast to Bar?
19:56chouserWhat you describe should work. Are you very very sure you're creating a Baz, that Baz implements Bar, and that Foo's ctor takes a Bar?
19:57nuggienyes, does it matter if both Foo and Baz are declared as final?
19:59chouserI don't think so.
19:59chousertry (instance? Bar (Baz.))
20:00nuggienyes that returns true
20:00powr-tocnuggien: No, I can't imagine how... final classes prevent java inheritence
20:01powr-tocnuggien: Have you cleaned and recompiled your java code? You might have stale class files
20:01nuggienpowr-toc: this is just using classes in the unit testing jars that come with google app engine
20:02powr-tocnuggien: is the constructor public?
20:02nuggienbasically the line: private final LocalServiceTestHelper helper = new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig()); from
20:02nuggienhttp://code.google.com/appengine/docs/java/tools/localunittesting.html
20:02nuggienLocalDatastoreServiceTestConfig is a final class implementing the LocalServiceTestConfig interface
20:04nuggieni can do (cast LocalServiceTestConfig (LocalDatastoreTestConfig.)) just fine in the repl
20:05chouserwhat about the ctor. can you use repl-utils 'show' to confirm the ctor you want is there?
20:05nuggienbut as soon as i pass that to LocalServiceTestHelper, it bails out saying it can't cast LocalDatastoreServiceTestConfig to LocalServiceTestConfig
20:05nuggienchouser: let me try that
20:06nuggieni guess this line is the constructor? [ 2] (class [Lcom.google.appengine.tools.development.testing.LocalServiceTestConfig;)
20:07chouserlooks like it wants an array
20:07chouservarargs in java is an array for objects in Clojure
20:07nuggienthe [L is array?
20:07powr-tocyes
20:09hiredman[ is an array
20:10nuggienwhat is the L for?
20:10hiredmanthe L and the ; at the end are just part of reference type names
20:11nuggienthank you all, it seems to work now
20:11hiredmanthe jvm has two or three different ways of giving type names, and Ljava.lang.Object; is one of them
20:11hiredmanalso java/lang/Object
20:24slyphonhiredman: did you know another lisp before clojure?
20:51hiredmanslyphon: I'd poked at scheme a little, but just sort of hello worldish stuff
20:52slyphoni read through the "programming clojure" prag-prog book, i'm wondering what else is out there that's good
20:52technomancyQi is spoken highly of by rich
20:52slyphonQi?
20:53technomancyQi!
20:54technomancyhttp://www.lambdassociates.org/
20:54scgilardihttp://en.wikipedia.org/wiki/Qi_%28programming_language%29
20:56slyphonman, you know, i just had to pull the ex-nasa-physicist-pretending-to-be-a-CS-professor
20:57slyphonwho argued with me that OO was useless because "it's just another way of referring to a pointer"
20:57slyphonand wondered why everyone didn't just write MASM
21:01slyphonnot that i'm bitter or anything
21:05lithprwow, that
21:05lithprQi book looks very interesting
21:23ag90A question about GUI programming: Assuming that I'm using Swing, is there a more functional or lisp-y way to write the GUI instead of the standard Java imperative way? If not, what about other toolkits (like SWT)?
21:25ModiusIs there a macrolet/environments in Clojure? Just need a name to look up if there is.
21:26ag90Modius: Do you mean this? http://richhickey.github.com/clojure-contrib/macro-utils-api.html#clojure.contrib.macro-utils/macrolet
21:26Modiusag90: Is the expansion environment available?
21:28ag90Modius: I don't know. I was just guessing.
21:28TheBusbycontextual macros? the idea is interesting, but sounds a little dangerous
21:33lancepantzhow do you use the class? function?
21:33lancepantzit only takes one argument, but i would expect it to take an instance and a class name
21:33lancepantzand return true if that instance is in that class
21:34arohnerag90: stuart sierra had a few blog posts on the topic...
21:35arohnerag90: http://stuartsierra.com/tag/swing
21:35arohnerlancepantz: it returns true if the object you pass it is a class
21:35arohneras opposed to say, a number
21:35arohnerlancepantz: maybe you want instance?
21:36lancepantzah
21:36lancepantzyes, thank you :)
21:37lancepantzand i can pass the expected class as a string, correct?
21:38lancepantzlooks like i cant
21:38arohnerthe actual class object
21:39arohner,(instance? String "hello world")
21:39clojurebottrue
21:39arohner,(instance? String 42)
21:39clojurebotfalse
21:39lancepantzgot it
21:39lancepantzthanks
21:39arohnernp
22:17TheBusbyHmm, how would this work? (magic even? [1 2 4 6 5 5 5 7 8 8 10 11]) => [2 6 8 10]
22:18chouserwho no 4?
22:19TheBusbylooking for the bounds of valid ranges
22:19TheBusby"why no 4" right?
22:20chouserI thought you wanted distinct even values, but that would ahve included 4 in the output.
22:21TheBusbyyeah, filter and distinct would have been a good option then
22:21TheBusbybut finding the boundary values...
22:22TheBusbywas hoping that maybe there was a split function where I could get (magic-split even? [1 2 4 6 5 5 5 7 8 8 10 11]) => [ [2 4 6] [8 8 10] ]
22:26arohnerTheBusby: so you're looking for seqs of consecutive values that pass the predicate?
22:26TheBusbyarohner: yes
22:26arohnerI think you'll have to write that
22:27TheBusbyk, just wanted to make sure there wasn't something hiding in contrib or somewhere that I wasn't aware of
22:27TheBusbyI know re-seq kind of does what I want for strings, so I thought a more general function might be hiding somewhere
22:28lancepantzanyone mind helping me get this recursive function correct? http://www.pastie.org/830208
22:28lancepantzit returns nil, but i'm expecting it to return a nested map
22:30chouser,(use '[clojure.contrib.seq :as seq])
22:30clojurebotjava.io.FileNotFoundException: Could not locate clojure/contrib/seq__init.class or clojure/contrib/seq.clj on classpath:
22:30chouser,(use '[clojure.contrib.seq-utils :as seq])
22:30clojurebotnil
22:30chouser,(->> [1 2 4 6 5 5 5 7 8 8 10 11] (seq/partition-by even?) (filter (comp even? first)))
22:30clojurebot((2 4 6) (8 8 10))
22:30TheBusbyah, partition-by!
22:31TheBusbychouser: much thanks!
22:31chouser,(->> [1 2 4 6 5 5 5 7 8 8 10 11] (seq/partition-by even?) (filter (comp even? first)) (map (juxt first last)))
22:31clojurebot([2 6] [8 10])
22:32arohnerlancepantz: doseq returns nil
22:35dannycoatescan anyone here help a noob compile clojure-clr? I've got 3 build errors
22:36lancepantzarohner: is there a different function i should use instead, or is my approach flawed?
22:37lancepantzmaybe loop/recur?
22:37arohnerlancepantz: I'm not entirely sure what you're trying to accomplish
22:37lancepantzhahah
22:38lancepantzi've got a nested yaml string, and snakeyaml returns a nested java.util.LinkedHashMap, i'm trying to recursively turn that into clojure maps
22:38lancepantz*turn that into a clojure map of clojure maps
22:44arohnerlancepantz: try using reduce and assoc
22:45lancepantzk, ty!
23:15TheBusbydata
23:16chousercode
23:16TheBusbywhoops, sorry wrong window :)
23:56lancepantzalright, got it
23:57lancepantzarohner: this is what i was trying to do:: (defn to-seq [data] (into {} (for [[k v] (into {} data)] [k (if (instance? java.util.LinkedHashMap v) (to-seq v) v)])))
23:58arohnercool