#clojure logs

2010-02-09

00:00JonSmithso it would be something like (get array value) or something?
00:01arohnerI'm trying to look up the javascript syntax for it
00:01arohnerI know it's possible in scriptjure, I don't remember how
00:02ninjuddi noticed that it isn't efficient to get the size of a PersistentQueue, because counting the number of elements in the front list requires O(n) time
00:02JonSmithokay
00:02JonSmithi will do some research
00:02JonSmithjust wanted to know it was possible :-)
00:03JonSmithis a really nice library btw
00:03arohnerthanks
00:03arohner:-)
00:03ninjuddi can submit a patch to fix it
00:11JonSmithah
00:12JonSmithi think the solution is to just use dot notation
00:12arohnerJonSmith: how?
00:14JonSmitharrays are just like objects bc objects are associative arrays
00:14JonSmithso i think if i do
00:14JonSmitharray.index
00:14JonSmithshould be similar to array[index]
00:15arohnermaybe this doesn't work after all
00:15arohnerif you don't figure it out, file a bug
00:19JonSmithokay
00:22hiredman,(counted? clojure.lang.PersistentQueue)
00:22clojurebotfalse
01:02wdouglasincanter's chrono is so nice <3
01:11DeusExPikachuI'm getting some weird behavior trying to modify swank.clj in lein-swank. I modifed it, built it with lein jar, installed it to local repo with lein install, then made a new project to test it, added it as a dev-dependency, lein deps, and lein repl'd the new project, when I enter the namespace and (doc swank), I get the old definition, even though the modified lein-swank jar exists (with modifications) in lib and it is
01:11DeusExPikachu in the class path, what's going on?
01:21wdouglasis the old one in the classpath too? Might you have another swank around in ~/.swank-clojure?
01:24DeusExPikachuwell at least in lib, theres only the modified lein-swank, I'm checking the whole class path, its a pretty big list
01:25DeusExPikachucrap, it is in there... hmm seems like order is important in this case
01:26DeusExPikachuis there a way to specify which definition you would like to be used?
01:42TheBusbyso is it still possible to write scripts with clojure by having #!/usr/bin/clj at the top of the script? Clojure 1.1.0 doesn't seem to like the old clojure.lang.Script syntax...
01:42TheBusbyer, I mean #!/usr/bin/env clj
01:43TheBusbynmind, answered my own question must supply "-" as a CL arg...
01:44hiredmandon't use Script
01:44hiredmanclojure.main replaces Script and Repl
01:44TheBusbymain with what options though?
01:45hiredmanas far as I know there is no canonical script for starting clojure, so just saying 'clj' doesn't tell anyone anything about how you are starting clojure
01:45TheBusbyI mean using a bash script called clj which sets up the classpath and executes the java command
01:46TheBusbyevidently the switch to clojure.main has changed the execution syntax
01:47TheBusbyit appears to be $JAVA_EXEC clojure.main $1 $@
01:47hiredmanTheBusby: sure, but as I said, since I have no idea what is in your clj script or where you got it, just saying 'clj' doesn't tell me a lot
01:48hiredmanpassing $1 and $@ together like that is weird
01:48hiredman$@ contains $!
01:48hiredmaner
01:48hiredman$1
01:49TheBusbyhiredman: you're correct. I assumed most people were using something similiar http://pastie.org/815870
01:49TheBusby$1 so that java reads the script file
01:49TheBusby$@ so that clojure can see the script name it came from
01:49TheBusbyargv[0] = program name
01:49TheBusbynot necessary?
01:51hiredmanhmmm
01:52hiredman,(doc *file*)
01:52clojurebot"; The path of the file being evaluated, as a String. Evaluates to nil when there is no file, eg. in the REPL."
01:53TheBusbyI guess it depends if you want it as *file* for (first *command-line-args*)
01:54TheBusby/for/or/
01:54hiredmanwell you asked if it is necessary
01:56TheBusbyyep, thank you
01:58TheBusbyany thoughs on the best way to spawn off one million http-agents efficiently?
01:59TheBusbywas hoping simply using map would leverage chunked seq's to do 20-30 at a time...
02:01hiredman,(doc seque)
02:01clojurebot"([s] [n-or-q s]); Creates a queued seq on another (presumably lazy) seq s. The queued seq will produce a concrete seq in the background, and can get up to n items ahead of the consumer. n-or-q can be an integer n buffer size, or an instance of java.util.concurrent BlockingQueue. Note that reading from a seque can block if the reader gets ahead of the producer."
02:03TheBusbyexcellent, I can't wait until I get more of these tools under my belt
02:11rrc7czassuming I have a seq like ["one" "two" "three" "four" "five"], is there a fn in core or contrib for (split-at "three" coll)?
02:11hiredman,(split-at (partial = "three") ["one" "two" "three" "four" "five"])
02:11clojurebotjava.lang.ClassCastException: clojure.core$partial__5034$fn__5036 cannot be cast to java.lang.Number
02:12hiredmanoh
02:12hiredmanright
02:12hiredman,(split-with (partial = "three") ["one" "two" "three" "four" "five"])
02:12clojurebot[() ("one" "two" "three" "four" "five")]
02:12hiredman,(split-with (partial not= "three") ["one" "two" "three" "four" "five"])
02:12clojurebot[("one" "two") ("three" "four" "five")]
02:15rrc7czthanks hiredman
04:15triyoI'm in the process of learning defmacro handeling in Clojure. I wrote this trivial snippet: http://gist.github.com/299036 ... All it does is check if object is in the list of give choices.
04:16triyomacroexpand expands the macro to: (let* [insym__2791__auto__ 1] (clojure.core/or (clojure.core/= insym__2790__auto__ 1) (clojure.core/= insym__2790__auto__ 2) (clojure.core/= insym__2790__auto__ 3)))
04:16triyoits obvious in the expantion whats wrong
04:17triyoThe insym is not being picked up from the let binding.
04:18triyois it because binding of insym is quoted and hence delayed for runtime. Should it be bound outside the back-quoting?
04:19hiredmanbecause of the unsyntax-quote and re-syntax-quote
04:19hiredmanauto gensyms are only the same inside the same instance of syntax-quote
04:20triyoAh, that explains the different auto id
04:23triyohiredman: thanks for your reply. How would you structure my macro to overcome the multiple syntax quote issue and still have the gensymed binding?
04:24triyoif you dont mind assisting. Just trying to get my head around it. thx in advance.
04:24hiredmanI wouldn't write a macro
04:25hiredman,(some #{1} [1 2 3])
04:25clojurebot1
04:25hiredman,(some #{4} [1 2 3])
04:25clojurebotnil
04:25LauJensenhehe
04:25LauJensenhiredman: the guy is trying to learn HOW to write Macros, not WHEN
04:26triyohaha very funny
04:26triyoThanks LauJensen
04:27hiredmanthe least amount of change would be an manual gensym
04:28triyooh and I called my macro now in? as its more of a predicate. (And I know you could probably do this few ways event without use of macros, but I'm trying to learn Clojure macros a bit)
04:28hiredman,(cons 'or (for [x (range 10)] (list '= x 5)))
04:28clojurebot(or (= 0 5) (= 1 5) (= 2 5) (= 3 5) (= 4 5) (= 5 5) (= 6 5) (= 7 5) (= 8 5) (= 9 5))
04:28hiredmantriyo: writing that as a macro is a bad idea
04:29hiredman(ins? 1 (range 10)) ; will be false
04:30triyohiredman: sure because it would not expand the range in the map.. I see
04:31esjLau: do you have jline running in your emacs slime ?
04:31AWizzArdMoin
04:32esjAWizz: wotcha
04:32LauJensenhejs, no
04:32LauJensen-h
04:32LauJensenAWizzArd: Hola
04:33esjLau: so what do you use for command history ?
04:34esji'm having to scroll up an down in the repl provided by (swank-clojure-project) and its become tiresome
04:34esjbeen randomly poking at swank and slime .el files, but to no great sucess
04:34LauJensenC-up C-down
04:35esjwhere are those bindings defined ?
04:35esji'm on OSX, so C-arrow is globally bound to switch desktops
04:36LauJensenI don't have access to Emacs right now, so I'm weak and withered, I cant help you... sorry....
04:36LauJensen:)
04:36ordnungswidrigesj: you mean C=Command or C=Control?
04:37triyohiredman: manual gensym worked. http://gist.github.com/299036 . I know what you mean by why its a bad idea. thx again
04:37LauJensenI think my brain has transferred all knowledge of Emacs to my fingers - I really struggle to tell you what the keys, let alone the bindings are, but ask me again tonight, or check out my .emacs on my blog
04:37esjLau: no problem
04:37esjthanks for your help
04:37esjby fiddling i've found the meta-p and meta-n do the trick too.... emacs!
04:37esjordnugnswidrig: yeah.
04:37esjC=Control
04:39LauJensenC-h k and C-h b are great helpers
04:41esjannoyingly those throw: wrong type argument: symbolp, (quote normal)
04:41esjthanks, what you told me will get me going though
04:44LauJensenHaven't seen those
04:47esjOK, I found the functions in slime-repl.el
04:47esjslime-repl-next-input and friends
04:48AWizzArdHi fatrow
04:48LauJensenMaybe we should hurry up and port Emacs to Clojure
04:48Chousuke:P
04:55esjLau: Genius !
04:59LauJensenI'll create 'cmacs' on Github straight away :)
04:59LauJensenor 'clabango-macs', thats _even_ more catchy
04:59AWizzArdI have a macro which expands into defn. I support doc-string? and attr-map? as defn does. I merge them (if they are provided) into a map 'meta-data'. How do I attach this to my defn? `(defn #^~meta-data ~name ...) won't work because the reader macro changes my form before the macro can touch it.
05:00Chousuke`(defn ~(with-meta name blah) ...)
05:01Chousukeie. you just need a symbol with the appropriate metadata as the name.
05:01esjemacj
05:01AWizzArdChousuke: oki
05:02dsopis there a web framework for clojure?
05:03AWizzArddsop: Compojure
05:04LauJensendsop: Check out my blog for some examples using compojure, http://www.bestinclass.dk/index.php/blog
05:04AWizzArd*g*
05:04LauJensenJust trying to help out
05:05dsopLauJensen: just a joke. thanks, I'll already browsing it :)
05:22gstrattonI'd be really grateful if someone could explain what's happening here to me: http://paste.lisp.org/display/94620
05:24triyois there a case form in Clojure like in CL?
05:24hiredman' is quote, not syntax quote
05:25gstrattonhiredman: But why does my function behave differently from + when passed as an argument?
05:26hiredmanwhat version of clojure?
05:27gstratton1.1
05:27LauJensen~source +
05:27LauJensentriyo: You're looking for cond, condp, cond*
05:27simplechatheyyas
05:27AWizzArdtriyo: did you try case?
05:27simplechatis there any sane install method?
05:27simplechatthat doesn't involve pulling from git/etc?
05:28triyoAWizzArd: no case form....however found clojure.contrib.fcase
05:28triyohas case function
05:28triyocase macro I mean in clojure.contrib.fcase
05:28AWizzArdtriyo: then you have an older version of Clojure.
05:28LauJensensimplechat: http://www.bestinclass.dk/index.php/2009/12/clojure-101-getting-clojure-slime-installed/
05:28triyo1.1
05:28AWizzArdIf you wish you can download a freshly compiled dev version here: http://build.clojure.org/
05:29AWizzArd*clojure-version* ==> {:interim true, :major 1, :minor 2, :incremental 0, :qualifier "master"}
05:29AWizzArd,*clojure-version*
05:29clojurebot{:interim true, :major 1, :minor 1, :incremental 0, :qualifier "master"}
05:29hiredmangstratton: if you look at the definition of + you see it defines an inlinable version of the function, which is what I think causes the difference
05:29triyohehe thats ver I'm running like clojurebot
05:30triyoI can switch latest
05:30gstrattonhiredman: Right, thanks very much. I've spent hours trying to figure that out!
05:30AWizzArdtriyo: I am always working with the newest development version. This may be 'dangerous', as it might break something. Anyway, you always get the newest features that way :)
05:30AWizzArdtriyo: and also you can support development this way, by filing bug reports.
05:31JayMthere are 666 people watching clojure on github
05:31simplechatlol
05:31triyoI'm experiment a lot at the mo in the Clojure space, so wouldn't hurt me to switch to master from sourcse
05:31simplechatis it considered better to use the git versions of clojure?
05:31krumholt_gstratton, i don't have the problem you described with clojure "1.2.0-master-SNAPSHOT"
05:31simplechator are those unstable?
05:32AWizzArdsimplechat: you will find a freshly compiled git checkout here: http://build.clojure.org/
05:32simplechatis that what i want tho?
05:32AWizzArdyou can compile it yourself, you will need Maven tho and thus download 88% of the internet for compilation ^^
05:32AWizzArdsimplechat: i think you want that
05:32simplechatAWizzArd, atm i have the ubuntu package clojure
05:32simplechatbut i'm unsure if i want to stick with that or grab a newer version
05:33simplechator if the newer versions are unstable/etc?
05:33AWizzArdI suggest you to just get the newest thing
05:33Chousukesimplechat: isn't the ubuntu package 1.0? That's relatively ancient already :P
05:33AWizzArdThey are more unstable, in theory. In practice however they are not really breaking code regularily.
05:33simplechatso i grab clojure.jar
05:33AWizzArdja
05:33simplechatthis might be very stupid, but where do i put it?
05:33AWizzArdOh, Ubuntu placed your current clojure.jar somewhere...
05:34simplechatyeah
05:34simplechatjust overwrite it?
05:34AWizzArdsimplechat: do you use emacs? Enclojure? VimClojure?
05:34Chousukesimplechat: in the classpath. which is specified when you start the JVM
05:34Chousukesimplechat: so the location does not really matter
05:34simplechatAWizzArd, i'm aiming to just use vim/etc
05:34simplechatChousuke, but i already have one version
05:34Chousukesimplechat: ~/.java/ or something might be okay
05:34simplechatin /usr/share/java/clojure.jar
05:35Chousukesimplechat: you can have many. don't overwrite anything the package manager has installed.
05:35AWizzArdIf you know Vim well then try VimClojure, and place the downloaded clojure.jar where Chousuke suggested. And edit your VimClojure config file so that it points there.
05:35simplechatok
05:35AWizzArd(Maybe you even want to use Synaptics and uninstall Clojure from Ubuntu)
05:35simplechatso i then need to vimclojure?
05:35AWizzArdNot need. But as a Vim user this is suggested.
05:35AWizzArdIt will help you.
05:35simplechatmmmm
05:36simplechatyeah, i wouldn't want ubuntu changing the packages out from under me
05:36gstrattonkrumholt_: Hmm, me neither. Is using the 1.2 branch recommended at the moment? I assumed 1.1 was least likely to have unexpected problems
05:36simplechathow would i test clojure-contrib is working?
05:36krumholt_gstratton, i don't know i use 1.2 and it seems very stable
05:39simplechatshould base64 be a defined symbol?
05:40simplechatyeah
05:40simplechatok
05:40simplechati really don't get this, lol
05:43scottjWhat do you guys prefer, a config file or environment variables for telling a webapp whether it's in production or development mode?
05:44yuukiIs emacs the most popular editor for clojure?
05:44scottjyuuki: yeah, but quite a few ppl use java ide's or vim
05:44simplechatbut yeah, how would i test that clojure-contrib is working?
05:44simplechatscottj, eclipse?
05:45yuukijava ide, meaning jedit?
05:45tomojI think someone said earlier that there was a poll and about half used emacs, the other half anything else
05:45scottjjava ide meaning netbeans, intellij, eclipse, probably in that order of popularity
05:45tomojsome vim as well
05:45tomojoh you said that
05:47yuukiI'm starting to like vim for programming. I think it will help to learn to manipulate windows and buffers better
05:47scottjsimplechat: start a repl w/ contrib on the classpath and then (use 'clojure.contrib.somenamespace) and run a function in it?
05:47underdevi'm using emacs, and am very impressed, but the netbeans plugin is very impressive
05:48underdevas well
05:48underdevit will code complete on the java as well as the clojure
05:50underdevive used vim for about 10 years, so emacs is a big adjustment
05:50scottjunderdev: using vipermode?
05:50yuukiis there a big cost to mutating references?
05:50underdevbut too many times its been vital that i could connect to my editor remotely
05:50underdevlike TOO MANY TIMES
05:50neotykI switched for clojure from Vim to emacs as well
05:50yuukivim doesn't support that?
05:51underdevno, it totally does
05:51underdevso does emacs
05:51underdevbut emacs is so lisp-centric
05:51neotykIt's just better supported by emacs
05:52yuukikey chords make me sad
05:52yuukias a dvorak typist
05:52underdevscottj: no, i'm really taking the plunge
05:52neotykand it's so nice to get away from java ide for a while
05:52triyoAWizzArd: do you run 1.2.0-master-snapshot with swank? Swank-clojure-project doesnt fire up a repl if running 1.2.0. If I switch back to Clojure 1.1.0, all works fine. Is there a later Swank version that works?
05:52underdevyeah, viper mode is always an option
05:53underdevand if i had to guess, i'll probably end up using it
05:53underdevbut i figured i'ld give emacs qua emacs a shot
05:53underdevbut, you know, yesterday i was editing my .emacs with vim
05:53yuukimy vi keys are scattered all about, because I'm doing them in dvorak, but I've gotten used to them
05:54underdevyuuki, you are a total fucking geek :)
05:54yuukihaha
05:55yuukiif I was a total geek I would've configured my vi keys to be more sane
05:55ordnungswidrigyuuki: you totally missing the point with emacs :-)
05:55ordnungswidrigarg
05:55ordnungswidrigs/emacs/vi/
05:55yuukihaha
05:55AWizzArdtriyo: I run indeed 1.2.0 in swank. But: I use an old version of SLIME.
05:55yuukiyes, my navigation keys are c, v, j and p, so it takes two hands to move around
05:56yuukiSeveral weeks of nethack cemented my navigation skills :p
05:56ordnungswidrigI added (test-ns *ns*) to my source file and now the tests are run when I compile/load with SLIME. I like that.
05:56ordnungswidrigHowever it reports NO_SOURCE_FILE:1 for every error :-(
05:56AWizzArdtriyo: you can see however if this helps you: http://github.com/technomancy/swank-clojure
05:56underdevyuuki: thats awesome
05:56yuukihaha
05:56underdevyuuki: you fucking geek
05:57underdevyuuki: i want to follow you on twitter
05:57yuukihaha
05:57yuukiI don't really have a twitter account
05:57underdevrats, oh well
05:57yuukihaha
05:58yuukiSome day!
05:58underdevlemme know
05:58yuukiI am thinking about using clojure to port a language to the JVM
05:58underdevtcl? tell me its tcl,
05:58ordnungswidrigI imagine using vi with dvorak is like typing on a rot13 keyboard.
05:59underdevLOL
05:59yuukiThe language has mutable data structures, and I'm wondering if that makes clojure a bad choice for implementation
05:59ordnungswidrigapl
05:59ordnungswidrig?
05:59yuukifactor :p
05:59ordnungswidrig*duck*
05:59ordnungswidrigyuuki: not so bad
05:59yuukiI would basically have to use references, for each mutable object, right?
05:59triyoAWizzArd: strange, I'm not seing anything obvious in log. Settings look fine. I have a leiningen generated project layout that suite swank-clojure-project. And I'm running ordnungswidrig slime/slime-repl 20091016
06:01ordnungswidrigtriyo: um, you're running me?
06:01triyolol, sorry ordnungswidrig
06:01triyothat might be the cause of my problem
06:02ordnungswidrighehe. I just checked but I did not for slime on github :-)
06:03AWizzArdI always used jochus swank-clojure. But one day he stopped updating his repo.
06:03AWizzArdA bit later slime changed something. I think they used symbol names that are not valid in Clojure or something like that.
06:04triyotechnomancy seems to have taken over...thats the one I've been using
06:04AWizzArdAnd now some elpa stuff is needed, and technomancy made updates, etc.
06:04yuukiI'm thinking the best way to go is to immutable-ize the language
06:05LauJensenhiredman: Are you writing the scripts for CSI ? I just heard their discussion about finding some criminal where one of them says "I'll create a GUI using Visual Basic to track the IP address", lol :)
06:05underdevlolololol
06:05underdevyeah, do that
06:06hiredmanLauJensen: huh?
06:06LauJensenhttp://www.youtube.com/watch?v=hkDD03yeLnU
06:06LauJensenJust sounded like something you would say :)
06:07hiredman2009:Apr:09:12:30:42 hiredman : I still hate writing guis, and avoid it
06:08LauJensenoooh thats right, you said that back in April - I just forgot
06:09hiredmanI just don't see how anything I've said here would lead you to belive I would say anything like that
06:09triyoAWizzArd: I got it to work. it was actually slightly incompatible swank-clojure version. (Was a snapshot 1.1 ver, so I switch to 1.1.0 final) + contrib 1.2.0)
06:10LauJensenhiredman: Just yanking your chain - Have you dissoc'ed your sense of humor?
06:12AWizzArdtriyo: what swank-clojure do you use? technomancy's stuff? Do you also use ELPA? What version of SLIME?
06:13triyoslime 20091016 - swank-clojure -> lein project: :dev-dependencies [[swank-clojure "1.1.0"]]
06:14triyoworks fine now
06:14ordnungswidrigclojure-test-mode is acutally nice
06:14triyoI had the older snapshot of swank-clojure when it didnt work with clojure 1.2.0
06:15neotykanyone here planing to join tomorrows AMS.clj meetup?
06:16underdevwhat's ams?
06:16neotykamsterdam
06:16neotykhttp://bit.ly/agptrb
06:16tomojwish I could
06:18LauJensenThis is fun - I was just looking at todays referrers on my blog, and this IP pops up, running from port 8080, so I follow the link and its someone running the Reddit Clone :D
06:20neotykvery nice Lau, best source of clojure lessons on the market lately
06:20LauJensenWhat is your machine I connected to ? :)
06:21underdevYeah Lau, i guess i have you to blame for getting interested in clojure
06:22LauJensenReally? Man thats great to hear!
06:22neotykyou do very good publicity for Clojure, I like it a lot :)
06:23triyoLauJensen: you started a reddit clone war few days ago. Congrats.
06:23LauJensenGreat - Thanks guys :) I must say it's been a lot of fun starting a blog - also a good way to remember things
06:23LauJensentriyo: Yea I noticed - I loved the QBasic version - I'm thinking of further extending the example, with user registration, search and whatever I can think of
06:24neotyknatural would be to give it some clojureql love :P
06:25AWizzArdtriyo: yeah, I use slime from 26. October
06:25LauJensenI know - But you have to be a little patient as we're rolling Frontend 2.0 - Its going to be great, but there's a lot of working involved - hopefully after a couple of weeks it'll be ready
06:26neotykno wories
06:26triyoLauJensen: I think it'd be a good idea to show off how clojure can handle some of the tougher parts of the system. For istance, reddit has some fancy ways of handeling the newly generated link identifiers, etc.
06:26neotyktill that time i might be ready with really async http client
06:26neotykone that doesn't user thread per request approach
06:28triyoLauJensen: reddit guys would be jealous as they loved CL but decided to switch to python when they had some deployment prod issues
06:29LauJensentriyo: You accidentally said that they used CL twice, but I forgive you :)
06:29LauJensenWhat exactly to you mean by new link identifiers ?
06:31ordnungswidrig,{0}
06:31clojurebotjava.lang.ArrayIndexOutOfBoundsException: 1
06:31triyoThey don't reference URL submissions by autogen ID of any sort, they create some other form of unique identifiers. I remember looking at the source about 2 years ago. You see them in the urls http://www.reddit.com/r/blog/comments/azkrk/you_requested_him_and_we_got_him_ask_noam_chomsky/ the "azkrk" part
06:32ordnungswidrigIs there a ticket for this? Or for this kind of misleading error message?
06:32triyoThe code behind that looked pretty cool
06:32LauJensentriyo: that ID is looks very trivial - You'll notice from the scraper that did for the Hadoop job, that those random characters are repeated for every 20 posts
06:34LauJensensimilar to (for [page pages id (range (count posts-on-page))]) - but instead of ints they use something random
06:34ordnungswidrigisn't it a autogen id in base35 encoding?
06:37triyoHmm, ok you might be right, I remember looking at the source and some parts were very impressive... The good thing is that reddit is open sourced so you can see some interesting parts and how they wen about implementing them and perhaps find better ways to approach those parts. Your first tutorial is cool but that is the really trivial part in many languages today. You need Part two, where the real gems lie :)
06:38LauJensenOr a small series perhaps - You can make this stuff as big as you like :)
06:39LauJensenGenerally the feedback I get, is that the Compojure docs are leaving people wanting, so I might as well try to fill the gap
06:40triyoI agree on the last point
06:42triyoLauJensen: Have you ever had a look at Django project docs? In my opinion, best I have seen in years. (Constantly updated and in informative in great depth. Their commits require full working support docs)
06:42triyoWould be amazing to see something like that in Clojure space.
06:43LauJensenNo I haven't, but it sounds interesting
06:43tomojseems like there isn't much to document about new compojure
06:43tomojonly one source file (!)
06:43tomoj+ clout I guess
06:43tomojthen you need ring docs too, maybe?
06:43LauJensenhttp://compojure.org/docs
06:44LauJensentomoj, you don't need to know ring to know compojure
06:44triyoLauJensen:here is the example: http://docs.djangoproject.com/en/1.1/ (note the 1.1 in the url. All previous and beta versions can also be referenced)
06:45LauJensenWow
06:45LauJensenI wonder where they find the time
06:45triyoLauJensen: the forst part is amazing, well tested, tutorials
06:45triyothen rest is very detailed docs for all parts of the framework
06:46tomojLauJensen: well, what's there to know about compojure, then?
06:46tomojnot much?
06:47tomojI just mean that django docs may be great, but I don't think we have enough to write about :)
06:48LauJensenhehe, I get your point
06:48tomojI hope that someday there will be lots of separate projects which can easily be plugged in
06:48tomojfor authentication, file uploads, etc
06:49powr-tocIs there an existing predicate equivalent to (complement nil?)
06:49tomojmost of that kind of stuff can just be plugged in by decorating with middleware, I'd bet
06:49LauJensenThere was an attempt at porting Django at one point by danlarking, don't know what happend to it
06:50triyotomoj: thats the thing. Getting people to build "plugins". Compojure has no pluggable well defined concept of what these plugins are. I know middleware is the answer, but I think there needs to be some more abstract way to register these plugins "components"
06:50tomojI guess a lot of the rails plugins are model-layer stuff
06:51tomojwhich is not compojure's concern
06:51raph_amiardtest
06:53tomojpersonally I kind of like the idea of just requiring the with-* function and decorating
06:54tomojI think one of the goals of compojure's design was not to be opinionated like rails
06:54tomojwe can't make any assumptions and so can only provide functions which people can use
06:55triyotomoj: sure but I think there is a need to encourage people in developing on top of compojure. And I think thats the key.
06:55tomojah, yeah
06:56tomojwhat are some of the important things we're missing
06:56tomojso far I've missed authlogic and paperclip from the rails world
06:57powr-tocIs that a predicate that tests for truthiness?
06:57tomojno, it tests for nil-ness
06:57LauJensenhehe
06:57LauJensentruthiness? :)
06:58tomojer, non-nil-ness
06:58tomojthere is no need for a predicate that tests for truthiness
06:58LauJensen(contains? truthiness? "clojure is cool" )
06:58LauJensentrue
06:58tomojby definition
06:59underdevtruthy and falsy are now official words- too useful to not be considered proper english
06:59LauJensentruthy
06:59powr-tocI want to filter nils... At the moment I have (filter (complement nil?) [nil 1 2 3 nil]) is that idiomatic?
06:59tomoj(remove nil? ..)
06:59powr-tocahh cool
07:00tomojfalse will remain
07:00LauJensen,(filter identity [1 2 nil 3])
07:00clojurebot(1 2 3)
07:00tomojfilter identity gets rid of false as well
07:00powr-tocsweet
07:01powr-tocwhich of those options is more idiomatic?
07:01underdevlanguage is descriptive, not prescriptive, and anyone who say different ain't right!
07:01LauJensendepends on what you want
07:02LauJensenif its just nils you want removed, (remove nil?) makes the most sense
07:02tomojI like (remove nil? ..) when you don't care about false, because it is so readable
07:02powr-tocyeah makes sense
07:03tomojare there functions for conjunction/disjunction of predicates?
07:03powr-tocin this case (remove nil? ..) conveys intent better... but I quite like (filter identity ...)
07:03tomojI always forget
07:04tomojlike (remove (disjunct nil? odd?) ..) to get rid of nils and odds
07:05LauJensen(remove #(or (nil? %) (odd? %)) )
07:05LauJensen:)
07:05tomojeek points
07:05tomojI think I saw that there will be a section in the new book about point-free clojure
07:05tomoj:)
07:07LauJensenMeikel already blogged about it :)
07:07LauJensenIf you want point-free, use Haskell or better yet, J
07:07LauJensenhttp://kotka.de/blog/2009/12/Pointfree_vs_Pointless.html
07:08tomojbut those aren't lisps :(
07:09tomojI agree though, clojure isn't quite right for it
07:09LauJensentomoj - I'm really hammered on time these days, but I would so so so looove to plug the J.dll into Clojure - Would be incredible
07:10LauJensen(defn average [coll] (j "# % +/"))
07:10tomojthat looks... odd
07:11LauJensenoops, I meant "+/ % #" ofc
07:11AWizzArdrhickey: is there an easy way to overwrite the public :arglists metadata for a defmacro or defn? I have a function and want its arglist to look like that of your defn, but internally (like your defn) have a different arglist.
07:11LauJensen+/ = sum, % = divide, # = count
07:12AWizzArdI could do it as you did in core.clj, but that means to repeat most of the defn code, and it feels very lowlevel.
07:13rhickeyAWizzArd: you could alter-meta! on the var
07:14AWizzArdok, good idea, thanks
07:16tomojfull disclojure might be the clojurecasts I was looking for
07:18underdevtomoj: yeah, they're great
07:32AWizzArdrhickey: btw, the alter-meta! doc string could mention symbols and fns too.
07:32rhickeyAWizzArd: no, it can't, since they don't have alterable metadata
07:33rhickeyreference types have alterable metadata, value types have value semantics for metadata (i.e. with-meta)
07:37triyoI am translating an example form OnLisp book into clojure (or at least trying to). CL has a case for like this http://gist.github.com/299163 I see the clojure 1.2.0 has a case form too, how does it work? Doesnt seem to be the same as CL ver.
07:38cemericktriyo: my CL is really rusty, but you're probably looking for condp
07:39tomojcase would work here, wouldn't it?
07:40tomojsince we're looking for literal symbols
07:40Chousuke(doc case)
07:40clojurebot"clojure.contrib.fcase/case;[[test-value & clauses]]; Like cond, but test-value is compared against the value of each test expression with =. If they are equal, executes the \"body\" expression. Optional last expression is executed if none of the test expressions match."
07:41Chousukehm. not the right one :P
07:41triyoclojurebod runnign 1.1.0
07:41triyocase only checked in 1.2.0
07:41triyoI checked ealrier
07:41cemerickI've not used case yet, but I didn't think it matched on symbols.
07:42cemerickI feel like I'm overusing bound vars lately -- e.g. offering 6 vars to be bound for a 10-fn API, instead of having each fn take a map arg or something.
07:42triyocemerick: I tried now and it doesnt match on symbols, unless i'm doing it wrong
07:42tomojmatches on any literals, no?
07:42tomojhttp://github.com/richhickey/clojure/blob/master/src/clj/clojure/core.clj#L4609
07:42tomojwarning, big file
07:43cemericktomoj: sure seems like it *shrug*
07:43Chousukelooks like it does.
07:45tomoj(case 'and (and 3)) gives 3
07:45Chousukein CL?
07:45tomojno, clojure
07:45tomojthough, strange
07:45tomoj(case 'or (and 3) (or 4)) gives an error
07:46tomojwhile (case 'and (and 3) (or 4)) returns 3
07:46Chousukeyou have too many parentheses
07:46tomojoh, I see
07:46tomoj(case 'or and 3 or 4)
07:46tomojso, triyo, I think you just need to get rid of some parens
07:47yuukishould clojure-contrib be in the clojure directory?
07:47ordnungswidrigre
07:47tomojand then instead of "t default-value" at the end, just "default-value"
07:47Chousukeyuuki: doesn't matter.
07:47tomoje.g. (case 'foo and 3 or 4 5) gives 5
07:47triyohehe, thank worked. I kept trying with the parans
07:48rhickey,(case 'b 'a 1 'b 2 'c 3)
07:48clojurebotjava.lang.Exception: Unable to resolve symbol: case in this context
07:48tomojI guess in general clojure tries to get rid of them when they're unnecessary
07:48tomojclojurebot doesn't have it yet :(
07:48rhickeycase should work with ant values with stable hashcodes
07:48rhickeyany
07:49cemericktomoj: same with cond, etc. Each case is likely to be on its own line anyway, so no need for the noise.
07:49tomojyeah
07:49triyorhickey: how do I specify the "default" case if none is met?
07:49tomoje.g. (case 'foo and 3 or 4 5) gives 5
07:50rhickeytriyo: "A single default expression can follow the clauses"
07:51AWizzArdrhickey: I could update the :arglists metadata for foo, my (defmacro foo ...). Is that a reference type?
07:51triyoI see, thanks.
07:51AWizzArdrhickey: nevermind.. "var".. ok
07:52ChousukeAWizzArd: I don't know what you even asked :P
07:52triyoA lot less parens than CL ver of case
07:52Chousuketriyo: you can do away with many parens through implicit grouping
07:53triyoChousuke: what is implicit grouping?
07:53Chousukeeg. (let [a b, c d, e f] ...)
07:54Chousukerather than (let ((a b) (c d) (e f)) ...)
07:54triyoOh sure, I see what you mean
07:54AWizzArdChousuke: it was some minutes earlier, about alter-meta!. I thought its docstring could need an update, but it doesn't. It already mentions vars, and a var's meta-data I updated. So, all fine :)
07:55ChousukeIt does mean that you need to use do if you want multiple expressions evaluated on a condition, but that's pretty rare.
07:59yuukimaven is complaining about the maven-resources-plugin
08:02tomojI wonder if applying constraints to functions like middleware would be a good idea
08:05AWizzArdtomoj: in Compojure?
08:12tomojAWizzArd: I meant, copy compojure's middleware decoration idea
08:12tomojbut use it for applying constraints
08:13tomojso (defn some-fun []) (add-constraint some-fun some-constraint)
08:13tomojsomething like that
08:13tomojexcept need a better way to do it so that you can apply specific preds to specific args, maybe
08:14LauJensentomoj: You mean a more flexible post/pre args thing ?
08:14tomojyeah, basically
08:14tomojI just watched the full disclojure about constraints and he mentioned the idea of separating the constraints from the functions that use them so that the constraints can be reused
08:15tomojbut I think I like the idea of applying them using something compojure.control.decorate style
08:15LauJensenCan't recall ever having the need
08:15tomojyeah, heh, I've never used constraints at all
08:15yuukidoes clojure-contrib contain its own version of clojure.jar?
08:15tomojmaybe I should try to use the feature before I start dreaming up abstractions around it
08:16AWizzArdtomoj: you can always add constraints after you defined a function. Functional programming allows you to decorate fns with other fns (such as constraints).
08:16tomojthat sounds great if :pre/:post is just a shortcut for that
08:16tomojand whatever it uses behind the scenes is reusable
08:18cemerickyuuki: no, they need to be obtained separately
08:18yuukiHmm
08:18yuukiI did mvn package and it builded successfully without reference to clojure.jar
08:19cemerickthat's because maven retrieves contrib's dependendies automatically
08:19cemerickI thought you were referring to the downloadable jars.
08:19yuukiAh I see...
08:20yuukiSo when I did maven package, clojure itself was downloaded and built into clojure-contrib.jar?
08:20cemerickNo, clojure is not built into clojure contrib.
08:21cemerickThey are both going to be needed by any apps you use them with downstream.
08:21yuukiI guess I don't understand how contrib compiled and was tested without clojure itself
08:22yuukihmm...
08:22cemerickmaven downloads the version of clojure that is required by the version of contrib you have the source for
08:22rhickeyyuuki: maven grabbed a release of clojure for you
08:22yuukiAh, I see... thanks!
08:23tomojI hope a full disclojure about datatypes/protocols is on the way
08:23triyoHow do I check what the first character of a given symbol is?
08:24tomojsymbols are named
08:24tomoj,(name 'foo)
08:24clojurebot"foo"
08:24cemerickan uberjar profile should probably be added to contrib's pom
08:24tomoj,(first (name 'foo))
08:24clojurebot\f
08:25chousercemerick: that would be cool. a single jar with clojure and contrib, all ready to go...
08:25triyotomoj: nice and easy, thx
08:26cemerickchouser: super-trivial to do. I'd do it right now, but I'm nowhere near contrib's head.
08:28cemerickchouser: you can badger SS about it when he gets in :-) Point at http://maven.apache.org/plugins/maven-shade-plugin/
08:28chouser"shade"?
08:29cemerickhey, I didn't name it :-/
08:29cemerickThere's no collisions, so it should be as simple as adding a profile with the shade plugin bound to the package phase.
08:45ordnungswidrighmm, clojure-test-mode higlighting collides with my rainbow parens. any ideas?
08:46ordnungswidrigtoggling rainbow-parens after running the test fixes this. Can I hook this in somehow?
08:46rhickeyhas autodoc fallen behind on contrib?
08:46rhickeyI tried grabbing the latest docs from github, but are from Jan 14
08:47chouserI'm not sure the docs were ever being auto-updated.
08:47rhickeyah
08:47AWizzArdrhickey: is there something like swap! for with-local-vars? I found only var-set so far.
08:49rhickeychouser: I got the impression they were from http://groups.google.com/group/clojure-dev/msg/836e9381f87a6515
08:49AWizzArd(var-set myvar (inc @myvar)) vs. (var-update inc)
08:49cemerickAWizzArd: swap! has semantics specific to atoms.
08:49AWizzArdyes
08:50rhickeyAWizzArd: there can't be any contention for a settable var
08:50rhickeythread-local
08:50AWizzArdyes, I know
08:50AWizzArdjust like c++;
08:50rhickeyso, var-set is it
08:50AWizzArdvs c = c+1
08:50rhickeynot like c++
08:50AWizzArdsyntactic sugar
08:51rhickeybleh - why are you using local-vars?
08:51rhickeyshould be ugly and painful
08:51AWizzArdThey are used as in-transaction value to update a DB.
08:51rhickeyyikes
08:51AWizzArdThe DB itself is in an atom. So I can not use swap! or reset! during the transaction, because readers outside the transaction could see that.
08:52LauJensenclojurebot: code-review is <rhickey> yikes
08:52clojurebotOk.
08:52LauJensen:)
08:52AWizzArdrhickey: this is what chouser and I came up with as currently best solution.
08:52rhickeyAWizzArd: ok - leave me out of it :)
08:52cemerickThis sounds like those scary CLOS-based orthogonal persistence thingamabobs.
08:52AWizzArdrhickey: well, you could offer a "plugin" to dosync.
08:53rhickeyAWizzArd: not trivially
08:53AWizzArdA mechanism that would allow me to do io when the transaction has in principle completed, but is not visible right now.
08:53rhickeyalso, bleh, very fragile
08:53AWizzArdSo multiple dosyncs won't repeat the io (writing the transaction log to disk) and block each other out.
08:53rhickeythis is why they invented transaction cooridinators
08:53LauJensenAWizzArd: You seem to have totally forsaken functional programming
08:53AWizzArdAnd the io part could still prevent the transaction from going live if the write to disk fails.
08:54AWizzArdLauJensen: nope, but there currently is no obvious mechanism for that purpose in Clojure.
08:55LauJensenIs the code public somewhere?
08:55AWizzArdnot yet, but in some weeks
08:55AWizzArdLauJensen: when you have a dosync and want to write data to the disk just before the dosync ends.
08:56AWizzArdIf 5 threads are running this dosync, then they can block each other, because writing to disk is so slow.
08:56LauJensenAWizzArd: Isn't it the case, that futures spawned within transactions only launch if the transaction is successful ?
08:56cemerickAWizzArd: IO within a transaction is a sure path to disaster. This is why io! exists.
08:56AWizzArdAnd if I need a lock around dosync anyway to prevent that I can use the faster atoms, as chouser suggested.
08:56tomojordnungswidrig: after advice on whatever function from clojure-test-mode you're using?
08:57LauJensenAWizzArd: I remember doing some trick with threads once, when I wanted to log something from the transaction
08:57AWizzArdcemerick: but io within the transaction is a requirement
08:57cemerickAWizzArd: transactions can, by definition, be repeated. You've got it backwards.
08:58AWizzArdnope :)
08:58rhickeyhttp://java.sun.com/javaee/technologies/jta/index.jsp
08:58cemerickThere may be *some* STM system that can support semantics like that, but clojure's cannot as-is.
08:58AWizzArdcemerick: I am talking about my db transactions here.
08:58tomojis it just a lot of work to add on? or is it fundamentally wrong for clojure's stm?
08:58AWizzArdInside such a db transaction, before it completes, a log entry must be written to disk. Otherwise the consistency is in danger.
08:59cemericktomoj: There's nothing wrong with it, it's just not a database-in-a-box.
08:59AWizzArdrhickey: I will have a look at this.
09:00rhickeycemerick: it is a database in a box. It's not 2 databases in a box :)
09:00cemerickrhickey: ah, sure. I guess I should have said it's not a durable database-in-a-box. :-)
09:00rhickeyright
09:00AWizzArdAnd I want to make it durable.
09:00AWizzArdSo, that is why I need the io.
09:01rhickeyAWizzArd: no, you want 2 databases in sync
09:01LauJensenrhickey: isn't it true that either agents or futures are only dispatched once from transactions?
09:01rhickeyLauJensen: agent sends are held until commit, yes
09:01AWizzArdrhickey: well, you can say that what I have in RAM is one, and the other is what I have on disk.
09:01LauJensenGreat - Then AWizzArd should be able to leverage that
09:01AWizzArdIn that case I have two dbs.
09:02rhickeyLauJensen: no, because the agent action can fail, in which case he wants to roll back the STM work
09:02AWizzArdLauJensen: I first wanted to use agents. But they can.. yeah, what rhickey said.
09:02LauJensenah
09:02AWizzArdI discussed this with chouser some days ago.
09:03rhickeyAWizzArd: these are old problems, that's why there is two-phase commit etc
09:03rhickeyany homemade solution is going to have problems
09:03AWizzArdWhile this JTA stuff looks interesting, it seems to be very heavy compared to my homemade solution.
09:03rhickeyuntil you reinvent two-phase commit
09:04LauJensenrhickey: two-phase commit ?
09:04AWizzArdhttp://en.wikipedia.org/wiki/Two-phase_commit_protocol
09:04rhickeyAWizzArd: but once Clojure's STM is JTA enabled, it will sync with just about anything Java
09:04rhickeydbs, message queues etc
09:04AWizzArdwell, as soon this is true I will happily use Clojures STM for that purpose.
09:04cemerickhah, I didn't realize that was on the drawing board.
09:04tomojoh, great, so this is on the way?
09:04rhickeynot on the drawing board
09:05tomojwell, at least it's feasible? :)
09:05AWizzArdrhickey: I just need a solution that works now. And what I have is very lightweight and I am under the impression that it will work perfectly fine.
09:05rhickeybecause I'm not sure you can truly participate in distributed transactions without a pre-commit log of some sort
09:05AWizzArdSo, it's no problem to use var-set, I can add syntactic sugar myself.
09:06rhickeyI'm happy to have others look into this. If possible to satisfy the semantics from an ephemeral participant like an STM, it would be great
09:06AWizzArddo you mean by distributed transactions those that occur over different JVM processes?
09:07rhickeyAWizzArd: that doesn't matter - distributed just means >1 participant
09:07AWizzArdAs in RAM and HD?
09:07rhickeyneed to succeed or fail together
09:07AWizzArdright
09:08rhickeya transaction involving more than one transactional participant needs to be coordinated
09:08AWizzArdWell, my plan currently is to first do the in-memory stuff. If no constraints or exception occur then I write to disk.
09:08rhickeyAWizzArd: good luck
09:08AWizzArdThanks, but it seems I pretty much solved this.
09:09AWizzArdAnd it was pretty simple, given that Clojure has these amazing fully persistent data structures.
09:09AWizzArdThey do the hardest part.
09:10tomojbut.. don't you lose isolation?
09:10AWizzArdno
09:10AWizzArdthe in-transaction modifications are done to a snapshot of the atom, hosted in a with-local-vars
09:10tomojoh
09:10AWizzArdthe snapshot can be modified in any way, and nobody will see that
09:11AWizzArdBecause everything in Clojure is fully persistent *thumbs up*
09:11tomojso, what's the downside?
09:11tomojno downside? :O
09:11AWizzArdThe downside is that I as the implementor of the DB need to use locks and w-l-v.
09:11AWizzArdNot as beautiful as using Clojures STM.
09:11tomojah
09:13AWizzArdEach insert/update/delte only modifies the w-l-v. And if that does not fail for any reason, then the w-l-v already contains the perfectly updated DB in RAM. Now only the changes get written to disk. And if that also not fails the atom will get its new value and everybody can then see it.
09:13tomojI would love to see something like cassandra or hbase in clojure someday
09:14cemericktomoj: you mean implemented in clojure?
09:14tomojso you must ensure by locking that only one person can do this w-l-v stuff at a time, I guess
09:14tomojcemerick: yeah
09:14tomojstarting work on thrift for clojure so that I can play with them from clojure now
09:15cemerickplenty of people are using both of those from clojure
09:15AWizzArdtomoj: yes. Without detailed knowledge it is always only possible that one thread can update a collection.
09:15tomojmaybe clojure wouldn't be a good fit, I dunno. I just know if it could exist, it'd be much more pleasant than java crap
09:15tomojcemerick: sure, wrapping over java stuff I guess for now?
09:16cemericktomoj: perhaps...though I don't see how that's bad.
09:16tomojI'd rather not have to deal with java thrift in clojure :/
09:16tomojmaybe there is an easier way bypassing thrift
09:17AWizzArdClojures stm is doing it in a similar way. If only one threads runs a dosync it will always win and do its isolated changes. If many threads are running a dosync then also only one can win, and the others must repeat. The result will be equivalent with my locks, only that no retries can occur.
09:18AWizzArdSometimes it would be okay to concurently modify a collection, without locks and retries. But you can do this only when you understand what you are doing there.
09:18tomojto me it's object-functional impedance
09:18tomoj(mismatched)
09:19cemericktomoj: if that's the case, that's what a good wrapper will fix. But there's zero value in reimplementing heavily-tested and widely-used impls of nontrivial functionality.
09:19tomojsure, I don't want to rewrite cassandra
09:19rhickeyAWizzArd: "then also only one can win" above is not true
09:19tomojif someone else did, I'd just be happy :)
09:20rhickeyAWizzArd: non-overlapping transactions can both succeed without retry
09:20rhickeyotherwise STM would devolve into a single global lock
09:21AWizzArdYes, if they don't overlap it is fine.
09:21rhickeyAWizzArd: but not true of yours, is it?
09:21AWizzArdindirectly it is also true for mine
09:21AWizzArdBecause each thread would work on its own clone of the db
09:22AWizzArdAnd thus will be the only user updating it.
09:22rhickeywhich get merged how?
09:22chouserAWizzArd: I thought you were using one lock per db
09:22AWizzArdOnly later, when he merges databases it will be a global lock.
09:22AWizzArdchouser: yes
09:23AWizzArdThe merge is done with snapshots too, and after those are merged we see if the original db is still the same version. If yes it can get swaped.
09:24chouserand if not?
09:24rhickeyit is serialized
09:24rhickeythe STM is a parallel world view
09:24AWizzArdyes
09:24AWizzArdchouser: if the original db was changed then you can retry the merge.
09:25AWizzArdIt may succeed, it may now run in a constraint
09:25rhickeyAWizzArd: then just use a global lock, that's what you end up with
09:25chouserAWizzArd: so retries happen, but only before the write?
09:25AWizzArdlike in a Clojure dosync, where two threads try to get mony from an account which may have a balance less than 0. One thread wins and gets the money first, the other one will fail.
09:26AWizzArdrhickey: I don't need a global lock, only during merges.
09:26AWizzArdAnd also then not a global lock, but just around the slave and master
09:26rhickeyAWizzArd: but you are testing for success with a global db version, so all work is serialized - might as well do that up front
09:26AWizzArdAll other DBs can be updated at the same time
09:27rhickeyall right, lock per db. You aren't really leveraging STM
09:27rhickeydoind speculative work only to fail on not-serial is a waste, just serialize the work with a lock
09:27AWizzArdrhickey: during a (merge db1 db2) I want to merge changes in db1 into db2. I will make a snapshot of db2 and merge that. If db2 did not change I can replace it with the merged snapshot.
09:28chouserAWizzArd: I thought you were taking the one lock per db up front
09:28AWizzArdchouser: yes, that is true for non-merge operations
09:28chouserthe one feature over a simple lock is the thread-local version of the db to allow unlocked reads of old versions.
09:29AWizzArdrhickey: is dosync not doing speculative work? When I try to take money from an account in two different threads, then only one can win, because the balance my not be less than 0. 1000 is in the account, 800 both threads want to take.
09:29rhickeyAWizzArd: but dosync overlap granularity is the ref, not the world/db
09:29AWizzArdBoth concurrently take the 800 but then see that another thread already tried that and one needs to repeat and is now confronted with a different balance.
09:29rhickeyaargh
09:30AWizzArdchouser: yes
09:30AWizzArdrhickey: the db could be in the ref. Not every table and index is its own ref.
09:32rhickeythe STM world is a set of identities. transactions can encompass any arbitrary subset. transactions on non-overlapping subsets can simultaneously succeed
09:32AWizzArdnon-overlaying subsets means: different refs yes?
09:32rhickeyyour dbs are fixed subsets
09:32AWizzArdNot two different key/value pairs inside one hashmap
09:33AWizzArd(def db (ref {}))
09:33AWizzArdNow two dosyncs want to assoc something onto db.
09:33rhickeyI don't have any more time for this, sorry
09:33AWizzArdCan they both do it concurrently?
09:33AWizzArdThread 1 adds :a 1, Thread 2 adds :b 2
09:33AWizzArdNo retries, no speculative work, no global lock?
09:34AWizzArdrhickey: thanks for your time so far :)
09:38chouserAWizzArd: Based on the scheme we discussed with one lock per db, I don't see any value in allowing speculative work and retries.
09:38AWizzArdchouser: those would be only for merges.
09:39chouserI don't see any value in separating merges from other write work on the db.
09:40AWizzArdmaybe that will not be needed, it is just an idea with which I am currently playing. Maybe merges will indeed have the same locking mechanism.
09:40chouserthe reason speculative work can make sense for STM transactions is because the overlapping set of refs involved in each transaction is discovered within the transaction, and could even change on each retry.
09:41chouserbut none of that applies to these db's, where you'll declare up front the one or more dbs you're going to touch.
09:41AWizzArdYes, maybe that is not needed.
09:41jcromartiehmm, I seem to have lost the ability to hit C-up in my Clojure slime repl
09:41jcromartieoh, nevermind... stupid OS X Spaces shortcut keys!
09:41AWizzArdchouser: I will decide more about merges in the coming days. Currently the lock system seems to be very okay.
09:43AWizzArdAlso it can later be updated to do more granular locking and indeed allow concurrent updates to different parts of the db.
09:43AWizzArdCompletely separated modifications can then be divided and happen concurrently.
09:44cemerick_fogus_: can you move around down there yet?
09:44_fogus_In theory yes... in practice no
09:44cgrandAWizzArd: http://www.assembla.com/spaces/clojure/tickets/213-Invariants-and-the-STM
09:45cemerick_fogus_: and more to come, yes?
09:46_fogus_cemerick: Yes, another 10-20 on top of the 30 on the ground. :-(
09:46AWizzArdcgrand: yes, like this. And if Clojures STM supports that and io, then I can switch to that system within 1-2 days, and without breaking user code.
09:46AWizzArdcgrand: i only need something now, so what I do will be mostly equivalent in practice.
09:47cemerickWhat I don't understand is why I keep hearing people talk about "the northeast" getting pounded, when no notable amounts are falling north of Jersey.
09:48cgrandAWizzArd: use a ref of map of refs and a special-assoc fn
09:59ordnungswidrigAnybody uses genetic algorithms on sexps for machine learning?
09:59tomojI remember someone talking about that a long time ago in here
09:59tomojit may have been you? :(
10:00AWizzArdordnungswidrig: yes
10:01AWizzArdWell, I am doing Genetic Programming, not GA.
10:01ordnungswidrigtomoj: no, just thought of it. there was a java chess application which did evolve an algorithm on a dsl.
10:01tomojdoes that actually work at all?
10:01ordnungswidrigtomoj: somewhat, yes :-)
10:01AWizzArdtomoj: Genetic Programming?
10:01tomojI always sort of imagined that random code would suck
10:01tomojbut never tried it
10:01AWizzArdit works very well for some problems
10:01ordnungswidrigif think of evolving some code for the google ai challange
10:02tomojmaybe particularly if you can restrict the language?
10:02tomojwhoever was talking about it before in here was trying it with just arithmetical functions, I think
10:04AWizzArdyes, in GA and GP you restrict the language.
10:07ordnungswidrigtomoj: airthmetic is way to unspecific. although I heard of attempts to generate formulas for certain numbers as the fine structure constant
10:15jkdufairanyone happen to have binaries of the CLR version of clojure? i don't have visual studio on this machine
10:21triyoWhats the best way to check if something is a non-sequence type? (not (coll? x))
10:22Draggor(not (seq? x))?
10:23cemericktriyo: you probably want (not (or (sequential? x) (seq? x)))
10:24cemerickunless you really, honestly only want non-seqs, in which case (not (seq? x)) will do as Draggor said.
10:27triyocemerick: thanks, what is cool?
10:27triyooops
10:27triyotype
10:27triyotypo
10:27cemerick,(doc coll?)
10:27clojurebot"([x]); Returns true if x implements IPersistentCollection"
10:27triyocemerick: thanks, what is coll? then
10:27cemerick,(doc sequential?)
10:27clojurebot"([coll]); Returns true if coll implements Sequential"
10:27cemerick,(doc seq?)
10:27clojurebot"([x]); Return true if x implements ISeq"
10:28cemericktriyo: see http://github.com/Chouser/clojure-classes/blob/master/graph-w-legend.png for the complete view
10:29triyocemerick: oh nice link, thanks
10:30cemerickchouser: what do the colors mean on that diagram again?
10:32chousercemerick: the colors have no meaning, they're just to help to follow traces as the cross, converge, etc.
10:32cemerickah
10:33chouserand I imagine that thing's probably out of date again.
10:35jkdufairif one were to add durability (via the filesystem, say) to clojure's STM, would that require a two-phase commit?
10:35jkdufairor just a lot of blocking, or what?
10:51jcromartieyou know what would be good for the web? a distributed URL shortening service
10:52jcromartie(just thinking out loud... I know it's OT)
10:52tomojordnungswidrig: unspecific?
10:52tomojI would've guessed the opposite
11:04rhickeycgrand: one problem with http://www.assembla.com/spaces/clojure/tickets/213-Invariants-and-the-STM is how to avoid races? the STM no longer knows where the contention is and can't park conflicting attempts like it can at the ref level
11:08cgrandrhickey: you're right as usual and I would already be happy with single-ref invariants. (I over generalized the problem or the solution or both :-/)
11:09cgrandor do you mean "in-ref" races?
11:09rhickeyyes, in-ref
11:10rhickeyit's an important part of the Clojure STM design that it doesn't spin
11:11rhickeyperhaps spinning in-ref not so bad, but I don't know
11:11dsoprhickey: I tried to initialize clojure classes from a jar using urlclassloader and failed
11:12dsoprhickey: it seems that the clojure rpl tries to use the system class loader to get the .clj file
11:12dsoprhickey: as the jar file is not in the classpath it doesn't find the .clj file and aborts.
11:15cgrandrhickey: ok, the real problem that made me think of invariants is being managing concurrent changes to a ref holding an associative datastructure.
11:15dsoprhickey: is that 'expected' to happen?
11:15cgrandrhickey: Another solution could be a commute-in fn (a mix of commute and update-in): (commute-in a-map-in-a-ref [:a :b] inc), there the STM knows both the ref and the path.
11:16dsopah yes, and I gen-classed the necessary .class files for the jar
11:20rhickeycgrand: how is that not ordinary commute?
11:26cgrandcommute-in would commute as long as (get-in @a-map-in-a-ref [:a :b]) doesn't change between in-txn value and commit-time. (so commute-in is a bad name)
11:28rhickeycgrand: that's still spin prone, as we'll allow two destined-to-conflict transactions to proceed
11:29rhickeyI guess it could have the blocking characteristics of a write, but right now once blocked a txn is presumed failed
11:34yuukiare library routines with side effects marked? (like pop!)
11:34chouserfrequently.
11:40rhickeydsop: can you make a simple test case?
11:41dsoprhickey: yes for sure.
11:42rhickeydsop: ok, then please attach that to a ticket on assembla - thanks
11:43dsoprhickey: I cannot open tickets, have to make sure first if I'm allowed to sign the cla
11:44rhickeydsop: anyone can create tickets via: https://www.assembla.com/spaces/clojure/support/tickets
11:44rhickeyno CA required
11:44dsopoha, must have overseen this, thank you. will do
12:00yuuki(apply (peek '(+)) 2 3 ())
12:00yuukiWhy should this not give 5 as the answer?
12:01yuuki(apply (peek (list +)) 2 3 ()) works
12:02rhickey,(class (peek '(+)))
12:02clojurebotclojure.lang.Symbol
12:02rhickey,(class (peek (list +)))
12:02clojurebotclojure.core$_PLUS___4518
12:03yuuki,(+ 5 5)
12:03clojurebot10
12:03yuukineato
12:03yuukiI thought quote was a macro for (list ...)
12:04chouserno, they are rather different.
12:04chouserlist is a function, so all its args are evaluated first, then passed to 'list' which returns a list object.
12:05chouser'foo is the same as (quote foo)
12:06yuukiHmm
12:06chouserwhich causes foo, however complex and nested it may be, to remain unevaluated, returning whatever literal datastructures you have there.
12:06yuukiI see
12:07yuukiso '(+) returns a list containing the symbol + and (list +) returns a list of the definition of +
12:08chouseryes
12:08chouser,[1 (+ 2 3)]
12:08clojurebot[1 5]
12:08morphlingyuuki: `(~+) would be the same as (list +)
12:08chouser,'[1 (+ 2 3)]
12:08clojurebot[1 (+ 2 3)]
12:08yuuki,`(~+)
12:08clojurebot(#<core$_PLUS___4518 clojure.core$_PLUS___4518@1b38815>)
12:08yuukineato
12:08chouser,`[1 (+ 2 3)]
12:08clojurebot[1 (clojure.core/+ 2 3)]
12:09yuukiwhat is the deal with `?
12:09chouserthat's an example from the section on evaluation and quoting in _fogus_'s book.
12:10yuukiinteresting
12:10chouser` is provided to make the writing of macros more convenient
12:11dnolen,(let [x '+] `(~x 2 3))
12:11clojurebot(+ 2 3)
12:11morphling,(apply (peek `(+)) 2 3 ())
12:11clojurebot3
12:11morphling(apply (peek `(~+)) 2 3 ())
12:12morphling,(apply (peek `(~+)) 2 3 ())
12:12clojurebot5
12:24underdevanyone recommend a good sytax highlighting theme for clojure?
12:24underdevemacs
12:27pjacksonThere's not /really/ much to highlight. I use "arjen"
12:28pjacksonwhich is part of color-theme.el...
12:28underdevgreat, ty
12:29underdevhard to get a straight answer about color-theme
12:29underdevnow i know
12:33noidiunderdev, I like zenburn
12:33noidilooks like this http://slinky.imukuppi.org/zenburn/ , emacs port available here http://brockman.se/2003/zenburn/
12:39underdevnoidi: ty
12:39underdevpretty nice
13:21DeusExPikachuI'm getting more strange behavior modifying server.clj in swank-clojure, I'm passing to function setup-server the option :dont-close true, to opts. I'm printing out the value of opts before the call to start-swank-socket-server! and its set to true, but if I print out the last map {:annount ... (opts :dont-close) [by wrapping it in a let, printing, then returning], :dont-close turns to nil. The only way this is possibl
13:21DeusExPikachue is if something is mutating opts, however, I don't see any code mutating opts... What's going on?
13:45ninjuddgetting an error compiling clojure-contrib master using maven
13:45ninjuddReason: POM 'com.theoryinpractise:clojure-maven-plugin' not found in repository: System is offline.
13:48cemerickninjudd: are you running maven in offline mode (e.g. -o)?
13:48ninjuddyes
13:49ninjuddfrom the README: mvn package -o -Dclojure.jar=/Users/ninjudd/lib/java/clojure.jar
13:49cemerickdoing that will prevent maven from obtaining the necessary dependencies
13:49cemerickthat's only necessary if you're using your own clojure.jar, but even so, you need to let it run normally once so it can pull down the necessary plugins, etc.
13:50ninjuddi am using my own clojure.jar
13:50cemerickok, so run mvn package so that the necessary plugins can be obtained, and then do an offline build with your own clojure jar.
13:50ninjuddis that the kind of thing i would know if i'd ever used Maven before? or should it be added to the README?
13:51cemerickyeah, that's sorta basic :-)
13:52cemerickin general, building offline is entirely unnecessary.
13:52ninjuddok
13:52cemerickI actually don't think it'd be necessary when using a particular clojure jar either *shrug*
13:53technomancyit's pretty important if you're using mvn for tests and you have a lot of snapshot dependencies
13:53technomancyotherwise you can double or triple the time a test run takes
13:54stuartsierraShould I remove the "-o" in the command line on the README
13:54cemerickstuartsierra: I think so. It doesn't do anything w.r.t. ensuring that the provided clojure jar is used.
13:55ninjuddhmm, looks like master clojure-contrib won't compile with master clojure
13:55ninjuddCompiling clojure.contrib.fnmap.PersistentFnMap to /Users/justin/projects/clojure-contrib/target/classes
13:55ninjuddException in thread "main" java.lang.VerifyError: class clojure.contrib.fnmap.PersistentFnMap$loading__4759__auto____1 overrides final method meta.()Lclojure/lang/IPersistentMap;
13:55stuartsierraok
13:55Ankouhi, I have a nested map structure and want to change something in an inner map(say I have {:a {:b 0 :c 0}} and want to change c) what's the best way to achieve this?
13:55cemericktechnomancy: I dunno -- then you're going to be (potentially) testing against stale artifacts
13:55stuartsierraninjudd: that sounds like a bug in fnmap, which is obsoleted by deftype/defprotocol anyway
13:55technomancycemerick: that's almost always what I want
13:56cemerickAnkou: try assoc-in or update-in
13:56technomancyI mean vs waiting 60s to make sure they're not stale
13:56ninjuddankou: assoc-in or update-in
13:57technomancyslight exaggeration, but we have a _lot_ of snapshots, and have five repositories to check against; it adds up fast
13:57technomancyeach snapshot must be checked in each repository
13:57ninjuddstuartsierra: so what should i do get it to compile?
13:57stuartsierraleave out the -o
13:58Ankouokay, thanks
13:58stuartsierraoh, wait
13:58stuartsierraninjudd: to compile, see instructions for skipping tests in the README
13:58stuartsierraWait, that won't help either.
13:58stuartsierraRemove the line for PersistentFnMap in pom.xml
13:59cemericktechnomancy: I'd almost say that what you've described is a symptom of not cutting releases often enough ;-)
14:00stuartsierraHudson reports no failures on latest builds.
14:01technomancycemerick: probably. but in most cases we don't have control over that.
14:03stuartsierraPushed 9aecba5c5133d1a5017bc52b7def9a85b2ec3cef - remove -o from command line in README
14:09DeusExPikachuhas there existed a bug in clojure where deferencing an item in a map using keywords with hyphens in their name?
14:10stuartsierraDeusExPikachu: not that I can think of
14:10stuartsierrare your problems with swank, maybe there's an issue with how the default options get merged
14:11hiredmanDeusExPikachu: deferencing?
14:11cemerickDeusExPikachu: this is a slot in a deftype instance?
14:11DeusExPikachuI'm not familiar with default options, at least in the definition of setup-server, I don't see any code involving defaults
14:12DeusExPikachuperhaps I'm not using correct terminology, but I'm referring to something like this (let [opts {:a 1 :b 2}] (opts :a))
14:13DeusExPikachuwhat do you guys use to paste code?
14:14chouserDeusExPikachu: http://paste.lisp.org/new/clojure
14:16DeusExPikachuhttp://paste.lisp.org/+2118
14:17DeusExPikachuI pasted my modified version of setup-server, which includes some print statements, and the output (forgot to paste the word "setup-server but that's not relevant)
14:17DeusExPikachuif you look at the output, :dont-close becomes nil when I (opts :dont-close) it, but opts never changed
14:19cemerickDeusExPikachu: and you're getting an error when accessing opts?
14:19DeusExPikachuno error, just that it returns nil
14:19ChousukeDeusExPikachu: are you sure the code is exactly like that?
14:19DeusExPikachuin the code (opts :dont-close)
14:19ChousukeDeusExPikachu: maybe you have a typo?
14:19DeusExPikachuChousuke, I just copied pasted it
14:20cemerickA couple months ago, I ran into a bug where deftype slots with dashes caused errors (because the java name munging wasn't in place yet).
14:20DeusExPikachuthat's what I figure
14:21DeusExPikachusomething of that nature must be the problem, cause the code looks fine
14:22stuartsierrabut opts is an ordinary map, right?
14:22DeusExPikachustuartsierra, correct
14:22cemerickoh, nevermind then
14:23cemerickanyway, deftype doesn't support non-java field names (at least in my current build)
14:24stuartsierramust be a typo
14:24DeusExPikachuthe function start-server, creates a new map generated by this (let [opts (apply hash-map opts)] ..., start-server passes this to setup-server
14:25DeusExPikachuthere is no typo
14:25stuartsierrahttp://paste.lisp.org/+2118/1
14:25stuartsierraWait
14:25stuartsierra(apply hash-map opts)
14:25stuartsierraIf opts is already a map, that won't work.
14:26DeusExPikachuit wasn't, opts was a vector
14:26stuartsierra,(apply hash-map {:a 1, :b 2})
14:26clojurebot{[:a 1] [:b 2]}
14:26DeusExPikachu(apply hash-map (apply concat {:a 1 :b 2}))
14:26DeusExPikachuthats basically what happens earlier
14:26stuartsierra,(apply hash-map (apply concat {:a 1 :b 2}))
14:26clojurebot{:a 1, :b 2}
14:26stuartsierrahmmmm
14:27DeusExPikachubtw, to be clear, I'm not running this function in a repl, its the output after running my modified version of lein-swank
14:30stuartsierradunno, good luck!
14:30DeusExPikachu:(
14:31cemerickDeusExPikachu: try (println (keys opts)), just as a sanity check?
14:31DeusExPikachucemerick, ok
14:31cemerickeh, that won't help
14:32cemerickperhaps one of the :dont-close keys has an unprintable char in it
14:33DeusExPikachu... I probably quadrillion checked that already
14:33DeusExPikachuI can't make an unprintable typo 20 times ina row
14:34cemerickDeusExPikachu: you've got a repl in to this code?
14:35DeusExPikachucemerick, haven't called it in a repl yet, no, only grabbing output after running it as part of a larger system
14:36cemerickDeusExPikachu: that's your next step. Just def the opts somewhere, and then poke at the thing until you know what's up.
14:37DeusExPikachuthing is, I've been printing verbose information of all the function calls leading up to this call
14:40DeusExPikachuok, so in the repl it works correctly, but in the system it doesn't
14:47DeusExPikachuso that means the problem lies not in my code
14:48cemerickIt doesn't sound like you can infer anything from that.
14:48cemerickThere's certainly *some* code that's faulty, and it's nearly certainly not clojure's map impl.
14:50DeusExPikachuwhen I say it works correctly in the repl, I mean that it prints correctly, it ultimately fails cause the other args are missing instances of classes that are made unless I simply run everything from the beginning
14:50DeusExPikachujust to be clear
14:51DeusExPikachubtw, http://paste.lisp.org/display/94652#2 I printed other ways to refer to the :dont-close item, which all return nil
14:51LauJensenExtended the Reddit Clone a little bit: http://www.bestinclass.dk/index.php/2010/02/reddit-clone-with-user-registration/
14:56DeusExPikachucemerick, in the class path, there are multiple versions of clojure being used, is it possible a conflict can arise with multiple versions? That would be a problem not caused by any "faulty code" per say , but faulty configuration
14:57cemerickheh, that's a bad idea in general. All bets are off if you've got multiple versions of *any* library in your classpath.
14:57DeusExPikachuunfortunately, leiningen seems to setup running environments like that a lot
14:59DeusExPikachuor I should say, its easy to do so
14:59DeusExPikachuand difficult to do otherwise
15:00cemerickI'd try manually fixing up the classpath and seeing what happens.
15:01cemerickcgrand: is there any reason why I shouldn't use enlive's emit for general use? clojure.xml's emit is broken.
15:07DeusExPikachuhmm, tried it with no multiple versions, still have the problem
15:07DeusExPikachuwouldn've been great had that been it
15:21cemerickI wonder if anyone has any interest in a json -> XML conversion fn?
15:22dakronehave any for the other way around?
15:23cgrandcemerick: none that I can think of (apart from namespaces as usual)
15:23cemerickdakrone: that's a lot tougher
15:23cemerickso, no :-)
15:24cemerickcgrand: sure. Maybe rhickey can be convinced to pull yours in as a replacement. ;-)
15:25xp_prganyone want to help a newbie learn some clojure?
15:25BrandonWthat depends how newbie you are :)
15:26BrandonWif you are less newbie than me, then no :D
15:26chouserthe-kenny: thanks! :-)
15:27the-kennychouser: I wanted to buy it for some weeks now, but I only just figured out how to buy it with paypal w/o a credit card
15:28chouserthe-kenny: ah, good. I didn't even realize Manning was using paypal until you mentioned it a while ago. For some reason I haven't felt compelled to buy the book. :-P
15:28the-kennychouser: mh... but I think it's an interesting book, you should buy it :p
15:29chouser:-)
15:35the-kennyhuh
15:35the-kenny"aus seinem Herzen keine Mrdergrube machen"
15:35rhickeyrhickey: would gladly take patches to improve emit
15:36the-kenny"Mrdergrube" is missing an "ö" after the "M"
15:38rhickeywhat's with the run-test3369805950334031482.clj in contrib tests?
15:43chouserrhickey: I don't see that.
15:44rhickeyERROR in (can-print-json-null) (run-test3369805950334031482.clj:45)
15:44rhickeyexpected: (= "null" (json-str nil))
15:44rhickey actual: java.lang.NullPointerException: null
15:45chouserI just pulled a new contrib, and in master branch did "mvn test" ... Ran 256 tests containing 1203 assertions. 0 failures, 0 errors.
15:46rhickeyyes, but I made a change to core that broke contrib with that message
15:46chouseroh, I see.
15:46chouserbut I don't have a file named anything like that in contrib either.
15:47rhickeyreverted it, rebuilt both, re-inserted it, now tests pass - aargh
15:47chouserhm, perhaps it's temporary while maven does its thing?
15:47chouseroh
15:47chouser:-(
15:47chouser"Multiple deliver calls to a promise"
15:48cemerickrhickey: that file is a temp file that clojure-maven-plugin generates to require all namespaces found in the project, and run tests over them.
15:48cemericklook in your /tmp (or whereever java puts temp files on your system)
15:49cemerickThe file is uninteresting, just the root from where tests are run.
15:50cemerickrhickey: are you only interested in incremental patches to emit, or would you be open to a replacement?
15:51rhickeyalmost any patch would be a replacement - there's next to nothing there
15:51cemerickare you tied to the idea of printing, as opposed to, say, a seq of strings?
15:52cemerickreturning a seq of strings, that is
15:53rhickeycemerick: strings that start and stop where?
15:56cemerickrhickey: e.g. enlive emits ("<" "root" "></" "root" ">") for {:tag :root, :attrs nil, :content ""}
15:58rhickeycemerick: to what end?
16:00cemerickrhickey: not following you.
16:00chouserso you can lazily pull from that seq instead of dancing with binding *out*, I assume.
16:00rhickeybut there isn't a rule about what is in the strings or where they break, is there?
16:01cemerickchouser: that's nice, but not a huge deal IMO -- the real improvements would be proper content output (e.g. no inappropriate newlines, etc), basic attribute value escaping, etc.
16:01rhickeyi.e. what else are you going to do with them but dump on a stream?
16:02cemerickthe printing vs. seq issue is only important vis á vis API compatibility
16:02rhickeyone can be built on the other
16:03cemericktrue enough
16:03rhickeybut it is more efficient to put the characters right on a stream than to allocate all those strings
16:04cemerickI really dislike rebinding *out* -- I can never remember what specific type of stream/writer/printer/whatever it's supposed to be.
16:05cemerickBut anyway, that's neither here nor there.
16:05chouserpretty often those individual strings will already exist in the tree being emitted
16:05chouserthough of course the lazy-seq objects would have to be created.
16:05rhickeycemerick: fair enough, but the solution there is to make it easier to do the right thing, not abandon streams
16:06cemericksure
16:07cemerickcgrand: would you have any objection to my attempting to package up the enlive emit stuff as the basis for a new clojure.xml emit?
16:09chousercemerick: fwiw, there's an emit in lazy-xml that also escapes attr values and has an option to not insert extra newlines.
16:10chouserlooks like it does a lot of string allocating though. :-/
16:11cemerickhrm, quite the profusion
16:12cemerickit seems like one of these should get into clojure.xml for 1.2
16:12cemerickchouser: was the :pad option just to stay compatible with clojure.xml/emit?
16:12chousercemerick: yes
16:13jimtIs there a standard/best way to do serial port communication with clojure? Just use Java/rxtx? Or is there a more lispy wrapper?
16:14ordnungswidrigre
16:15cemerickperhaps a better idea would be to build a clojure-xml->DOM fn that produces java DOM elts, and feed that into the xerces/xalan stuff in the JDK to emit XML. There's a perf hit, but otherwise someone's going to be reimplementing all the escapes, pretty printing, blah blah blah.
16:16chouserperf hit + 3rd party lib to avoid escapes that have already been translated to clojure (a few times) doesn't seem worth it.
16:16chousercemerick: I would draw the line at pretty-printing, though. If you want more complex kinds of transformations then by all means use a java lib that does it for you.
16:17cemerickchouser: what 3rd-party lib? All that stuff is baked into the JDK.
16:17chouserxerces/xalan is? oh, is that JDK not JRE?
16:17cemerickThere's also the issue of emitting namespaced xml eventually, as well as non-UTF-8 encodings.
16:18cemericksorry, I shouldn't have said xerces/xalan -- the JRE/JDK starting with 1.4 or 1.5 includes an XSL transformer, which ropes in all this serialization stuff.
16:19cemerickI don't actually know what the specific impl is.
16:19chouseroh. if it's included, that sounds like a good route.
16:19chouserto me. though if rhickey was concerned about allocating string, allocating DOM objects may be right out.
16:20cemerickchouser: yeah, javax.xml.transform and friends are all there.
16:22cemerickXML serialization doesn't seem like a perf-sensitive thing to start with, but reimplementing all that can go into it seems a little crazy regardless.
16:24rhickeyI'm definitely for the path of least wheel-reinventing
16:26cemerickThe only issue is that this would be the first step out of the java.lang/io/util packages...which doesn't matter to me, but makes things just a little harder for someone porting to another host.
16:49rhickeycemerick: but some all-clojure things already exist (enlive)?
16:51rhickeydid anyone aver submit a patch for inline bit shifts?
16:51rhickeyever
16:52cemerickrhickey: enlive is very good in my experience so far, but it has no pretty-printing option, I don't know what one would do if emitting non-UTF-8 was required, and even once clojure.xml/parse and friends support namespaces, serializing them properly is wickedly difficult.
16:53rhickeycemerick: still seems like a proper subset of the final solution, what/whenever that may be
16:53cemerickrhickey: you mean something like enlive?
16:53rhickeyyes
16:54cemerickhrm
16:54rhickeyunless it is doing something that will become wrong in the future
16:54cemerickI'm quickly becoming convinced that having an easy clojure.xml <-> DOM bridge is critical in general, and if that exists, why bother having a clojure-based emit?
16:55rhickeymakes sense - have you got a clojure.xml -> dom thingy?
16:55cemerickum...no :-)
16:56rhickeybecause there's a sense in which that can become more generic, even though the DOMs might differ per host, we just cover to/from host DOM
16:56cemerickyeah
16:57replacarhickey: I have to apologize. Autodoc is broken on post-1.1 clojure & contrib (the prob of using code to document itself)
16:57rhickeyexcept everyone knows DOMs are unusable pigs sometimes
16:57rhickeyreplaca: no problem
16:57replacarhickey: I've not had too much time to work on it because we just had a baby and that's kind of all consuming, but I should be thee soon :-)
16:58cemerickrhickey: yeah, this is purely a library leverage strategy
16:58rhickeyreplaca: congrats!
16:58replacarhickey: thanks :)
16:58lancepantzhow can i get the exception message from a catch? i'm trying (catch Exception e (foo (.getMessage e)))
16:59replacanow that the baby is actually born, I'm taking some time off and while she's napping (a lot) I should have some time to get things put back together
16:59rhickeycemerick: no one would look askance at a to/from DOM option
16:59lancepantzwhich returns null
17:00cemerickrhickey: FYI, all the DOM stuff is interfaces, but they're pretty hairy and super-mutable, and I wouldn't rule out a nightmare scenario where transformers have implementation-specific dependencies, etc.
17:00StartsWithKlancepantz, can you paste a bigger code snippet?
17:00cemerickbut, I'll take a stab at it soon-ish. :-)
17:00cemerickrhickey: do you have any idea as to how namespace support might work out in clojure.xml/parse, etc?
17:01lancepantzhttp://www.pastie.org/817149
17:01lancepantzthis is my first clojure project, so don't laugh :)
17:02StartsWithKrhickey, in clojure.xml you use Keyword/intern to convert string to keywords in parse, and not keyword, can you explain why?
17:03StartsWithKi just finished json parser on jackson, and keyword vs Keyword/intern is something like 4x speed up
17:03StartsWithKif i use intern
17:04rhickeyStartsWithK: probably because keyword didn't exist yet
17:04replacagoing back over today chatting: the reason enlive returns a seq of strings is because it builds things up from small chunks with function applications and Christophe wanted to avoid building up successively larger strings at each layer
17:05replacainstead you just assemble the parts at the end
17:05StartsWithKrhickey, any reason why keyword has a instance check for keyword?
17:05lancepantzanyone mind taking a look at my exception handling code, i'm trying to get the message from the exception: http://www.pastie.org/817149
17:05rhickeyreplaca: understood, but not really important to the consumer
17:05StartsWithKi don't think that is a main reason for such a drastic difference in speed
17:06StartsWithKbut it looks out of place
17:06rhickeyStartsWithK: do you see this difference in master?
17:07StartsWithKrhickey, yes, i am on 1.2, and when converting jsonk string keys to keywords i get 4x bether performance with Keyword/intern, i also checked with c.c.json, and it can get up to 2x only by changing keyword to Keyword/intern
17:07StartsWithKbut if i wrap Keyword/intern in a function, problem returns
17:08StartsWithKi wanted to do something like (read json-stream :key keyowd) so user can pass a covertor function
17:08DeusExPikachutechnomancy, I've got a two part patch that depends on each other for both leiningen and swank-clojure to extend lein-swank to accept more arguments and pass them to start-repl, how should i send them to you, email? mailing-list for clojure/leiningen/swank-clojure?
17:08StartsWithKbut now i'm stuck at :key true/false, sending anything but identity will trash performance
17:12StartsWithKrhickey, http://paste.pocoo.org/show/175941/
17:12technomancyDeusExPikachu: thanks. I prefer being given a git url to pull from to patches. the mailing list for leiningen would be fine.
17:15StartsWithKand if i do (def make-keyword (fn [#^String s] (clojure.lang.Keyword/intern s))) (time (dotimes [i 100000] (make-keyword (str i)))) i get almost the same results as Keyword/intern
17:15chouserit seems plausable that the org.xml stuff in java may provide a away to emit xml from a stream of SAX events instead of a DOM. Ought to be more efficient and probably no less simple to implement than converting clojure.xml to a dom.
17:19StartsWithKrhickey, (defn make-keyword2 [name] (if (keyword? name) name (clojure.lang.Keyword/intern #^String name)))
17:20StartsWithKwith added typehint it works just like a direct call
17:21StartsWithKmaybe the hint should go inside the symbol too
17:21cgrandcemerick: feel free to borrow any of my code
17:22chouserperhaps using javax.xml.transform.Transformer and providing something that implements SAXSource on a clojure.xml structure
17:25StartsWithKis this http://clojars.org/repo/nstools/nstools/0.2.0/nstools-0.2.0.pom a good template for creating a pom?
17:25rhickeyStartsWithK: http://paste.pocoo.org/show/175950/
17:26StartsWithKrhickey, yeah, that works, can you do the symbol too
17:27rhickey?
17:27StartsWithKsymbol function is missing type hints at the same places as keyword
17:28rhickeyStartsWithK: doesn't need them
17:28rhickeykeyword had a reflection warning, symbol doesn't
17:28StartsWithKoh, your right
17:31rhickeyStartsWithK: ok, fixed on my machine, will go up with next push - thanks for the report!
17:31chouserthat looks like it should do it. should give you options like encoding, indent, xml-declaration, media-type, entities...
17:32StartsWithKthat will speed up c.c.json/read-json by 2x :)
17:33StartsWithKother problems i found in c.c.json are, it consumes stack while reading (and in write, but that is not such a big deal)
17:34replacarhickey: (sorry, jumping around) you're right, of course, but the issue was that there's no difference between the inside and the outside and Christophe didn't want to create an extra layer that was just (apply str ...) and duplicated the whole mechanism of deftemplate.
17:34StartsWithKand it will parse invalid json like "1" "[1,,,,2]" "{\"a\":::::2}" ...
17:36romanroeemacs/slime always asks to save the files when I eval the buffer etc. Is it possible to set something like autosave=true?
17:43fro0gI'm looking for a sparql interface for clojure
17:43fro0gagraph-java-client seems to contain one, but is it only for allegro graph ?
17:52DeusExPikachutechnomancy, I'm sending you the pull request via github's pull request, I don't know how to link a pull request manually. Is that ok?
17:58technomancythat's fine
17:58technomancyDeusExPikachu: if you can keep work in a topic branch you get bonus points
17:59technomancybut if it's on master that's OK too
17:59DeusExPikachuhmm, next time I suppose, I sent them
18:00technomancyI should write up a post about best practices for submitting patches to the projects I maintain. =)
18:00DeusExPikachuthe changes are simple, but it took me forever to test it to make sure it worked... the print not printing quotation marks really got me, it would've saved me sooooo much time
18:01technomancyyeah, that's put me off hacking swank more myself; it's so annoying to test manually =\
18:01DeusExPikachuwhat sucks is I wanted to use lein swank, and slime and all that goodness I"m used to, but couldn't cause thats the thing I'm actually working on
18:03DeusExPikachutechnomancy, I agree a brain dead simple guide would expand the people who would submit patches to you :) Maybe a new video from in the works sean devlin?
18:03technomancyoh, that's a great idea
18:42ninjuddif i want to submit a patch do i still need to fill out the contributor agreement and mail it in?
18:45neotyk,(doc proxy)
18:45clojurebot"([class-and-interfaces args & fs]); class-and-interfaces - a vector of class names args - a (possibly empty) vector of arguments to the superclass constructor. f => (name [params*] body) or (name ([params*] body) ([params+] body) ...) Expands to code which creates a instance of a proxy class that implements the named class/interface(s) by calling the supplied fns. A single class, if provided, must be first. If not provide
18:45neotykdoes proxy work with generics?
18:46neotyklike "interface I<T> ..."
18:50neotykright, generics are compile time, so I don't really care, thanks :)
18:58raekhmm, if I add a class into the classpath after the start point of a clojure program, can I use it without having to restart the program?
19:02technomancyraek: if you add a .class file to a directory that's already on the classpath it should work
19:09raekaww, I realized what where wrong...
19:09raekI'm using swank on my server and slime on my laptop
19:09raekI only have the class-file on my laptop...
19:32raekcan I re-import a class if I have changed it?
19:35rhickeyraek: not without restarting the jvm, no
20:12raekWhy does LazySeqs catch exceptions and wrap them in RuntimeExceptions?
20:32qedhttp://www.infoq.com/interviews/hickey-clojure
20:32qedi missed that one
20:41xp_prganyone want to teach a newbie some clojure?
20:42qedxp_prg: anything in particular
20:42qedxp_prg: im sort of a noob myself, but maybe i can help
20:42xp_prghow to make a custom programming language with it
20:43qedxp_prg: like a DSL?
20:43xp_prgwhat is that?
20:43xp_prgDomain specific language?
20:43qedlike CSS
20:43xp_prglike a cascading style sheet?
20:43qedyes
20:44xp_prgthat is what DSL means?
20:45xp_prgqed be my friend right now
20:47xp_prgam I talking to myself?
20:48xp_prgqed just be my friend right now, no biggie
20:51xp_prgqed?!!!!!!!!
20:51qedhttp://en.wikipedia.org/wiki/Domain-specific_language
20:52xp_prgok so how do I do that in clojure then?
20:52qedxp_prg: very carefully
20:52qedxp_prg: it's best to learn clojure before trying to do things with it
20:52qed;)
20:53xp_prgright, so help me to learn it then do a DSL
20:53qedi dont think i will be doing that
20:53xp_prgand remember to be nice as I am new
20:53xp_prgqed? :(
20:53qedif you have specific questions id be happy to offer some help, but the request you are making right now is rather unreasonable
20:53xp_prghow come?
20:54xp_prgare you a playa hata?
20:54qeddont hate the player, hate the game
20:54xp_prgright
20:54xp_prgI want to learn the game don't hate on a playa
20:55xp_prgso you gonna hate on me?
20:56qedxp_prg: if you have a specific question about implementing something in clojure that is not as vague as creating some vague DSL, then I can help you more, but like I said, you're asking something which has many answers, could require every core clojure feature available, etc.
20:56xp_prgeven for a simple little example?
20:57qedxp_prg: if you have a specific question about specific code i can help, otherwise i suggest you google around
20:57xp_prgbut how about a simple little DSL?
20:57xp_prgI learn quick I have CS, MSCS, and MBA
20:57qedso surely you could pick up a book...
20:58xp_prgya, that is the hard way to do it
20:58qedit is the correct way to do it
20:59xp_prgya I guess I am just too overwhelmed, oh well
20:59qedxp_prg: i felt the same way, but there is no substitute for diving in
20:59qedyou will be glad you did
20:59xp_prgI have stuided some stuff
21:00qedi suggest projecteuler.net
21:00qedstart doing some problems with clojure -- it will get you a bit more comfortable
21:00underdevxp_prg: google sicp, breaze through that, you'll be able to make a dsl
21:01qedshouldnt take you more than 2-3 hours ;)
21:01danlarkinstop with this dsl nonsense
21:01danlarkinwhat you mean is "library"
21:06underdevlisps are great for dsls
21:06underdevxp_prg: read some paul graham essays, grep for "bottom up"
21:06xp_prgdude I have cs degree I am not a fool
21:06xp_prgI just want someone to hold my hand for a while
21:07underdevgraham
21:07underdevseriously
21:07qedxp_prg: i dont think anyone is calling you a fool
21:07xp_prgactually I am a fool :>
21:07xp_prgbut I am a fool with two cs degrees
21:07qedxp_prg: one cannot ask meaningful questions without knowing the problem they need to solve first
21:08underdevi have a degree in philosophy, and i've read some paul graham essays
21:08xp_prgwell the truth is I just want to understand why clojure is so cool
21:08qedxp_prg: read http://clojure.org/rationale
21:08qedthat should sum it up
21:09underdevyeah, for "whats cool", get some of the videos, grab them locally, and play them at 2.5x in vlc
21:09underdevblow your mind, not take a lot of time
21:09qedxp_prg: here's a good video to watch
21:09xp_prgsweet passive learning
21:09xp_prgthat is how I am now, I am too old to be like all active learning and stuff
21:09qedxp_prg: http://channel9.msdn.com/shows/Going+Deep/Expert-to-Expert-Rich-Hickey-and-Brian-Beckman-Inside-Clojure/
21:09xp_prgespecially when this is just for fun
21:10ninjuddxp_prg: check out http://www.amazon.com/Programming-Clojure-Pragmatic-Programmers-Halloway/dp/1934356336/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1265767791&amp;sr=8-1
21:10ninjuddxp_prg: there is a section in there about writing your own DSLs
21:10underdevi put the flvs (or that case mov) throuugh winFF and listen to them on my mp3 player while doing chores
21:11underdevthat first one is streamed, so it takes a long time to capture it
21:11xp_prgsweet man
21:11qedvery sweet.
21:11xp_prgI am humbled by your ways
21:11underdevi think his keynotes are really great for whats cool
21:11qedrich is a great presenter
21:12underdevstm mvcc data structures
21:12underdevyeah he is
21:12qedi liked "Are we there yet?"
21:12qedit's all the clojure you need, without the clojure
21:12tomojthe philosophy stuff really made me happy :)
21:12qedtomoj: im a philosophy guy as well
21:12underdevrt
21:12underdevhad a few issues with it, but you know...
21:12underdevit applys to the concrete
21:13underdevimplementation stuff
21:13qednod
21:14tomojI guess most of my previous exposure to language evangelism was about accidental stuff
21:14qedi loved the commenter at the end of are we there yet who talks about rich capitulating the history of philosophy
21:14qedsort of synthesizing the two halves of philosophy
21:14tomojlike "oh the syntax is so nice and we have features XYZ"
21:14tomojrather than "nearly everyone else is fundamentally wrong" :)
21:14qedhaha yes
21:14underdevANW FTW!
21:16underdevi think there was a bit of conflating epistemolgy with metaphysics in there
21:16qedyeah
21:16underdevbut im a jerk about such things
21:16underdevan orinthologist having some issues with birds
21:17underdevas it were
21:17underdevbut hey, he implemented clojure, i'm on day two of configuring emacs
21:17underdevso who should you listen to? :)
21:18chousercemerick: looked at emitting xml any more since this afternoon?
21:20cemerickA little. Producing DOM node impls looks possible, but the interfaces are pretty hairy, and I'm scared that stuff like the transformer has hidden dependencies on some default implementation in the accompanying DOM parser(s).
21:20chousercemerick: I think it can be done without a DOM
21:20cemerickEither way, I'm very convinced that a clojure.xml <--> DOM conversion process is the way to go for a lot of stuff.
21:20cemerickchouser: Oh?
21:21chousercemerick: I'm not quite sure yet, but it looks like transformers might be able to take as input a thing that's delivering sax events
21:21cemerickI was hoping for that too, but I don't think so.
21:22chouseroh
21:23cemerickeverything related to sax grounds out in an InputSource, which must be backed by an inputstream or a reader.
21:24cemerickI'm certain we could implement a sax event source for a specific parser impl (like xerces), but that's a no-no.
21:24chousercemerick: I'm looking at this. it seems so close... http://stackoverflow.com/questions/1977504/what-is-the-most-memory-efficient-way-to-emit-xml-from-a-jaxp-sax-contenthandler
21:27cemerickchouser: hrm, that does look promising. I'll have to go trolling some more tomorrow. :-)
21:27chouserit's just like snapping together Lego bricks.
21:27chouserLego bricks that are giant misshapen lumps with wildly incompatible surfaces.
21:28cemerickheh
21:28cemerickg'night :-)
21:38qedk
21:42hiredmanlisppaste8: url?
21:45hiredmanoh, whoops
21:47qed'http://lib.store.yahoo.net/lib/paulgraham/jmc.lisp -- what is the purpose of the dots after function names?
21:47qedevcon. assoc. eval. etc.
21:53tomojis it just me or are compojure requests stateful
21:53tomojI mean, not values
21:54tomoje.g. get-multipart-params from compojure.http.multipart seems to only work once
21:54tomojis this for efficiency, or was it just convenient to use java crap, I wonder
21:59TheBusbySo what's the clojure/java way of handling getopt?
22:00chouserTheBusby: there's a weak simple little thing in contrib: command-line
22:01TheBusbychouser: thanks! will look there first!
22:01qedtomoj: my guess re: efficiency vs java is that it's a little of both
22:05tomojoi
22:05tomojthe problem is with the java code anyway
22:05tomojso I guess compojure's statefulness in this case is not actually so bad
22:05tomojwas annoying to debug thoug
22:06tomojnow, though, the problem is inside apache commons
22:06tomojwhich I really don't want to hack up with debugging crap
22:16tomojhah
22:17tomoja few hours wasted because the objective-c code my partner copied from the internet had two extra hyphens in a string literal
23:05JonSmitharohner: I have a patch for scriptjure that makes array access possible
23:17yuukiis there a function to show the definiton of a function?
23:19chouseryuuki: clojure.contrib.repl-utils/source
23:19yuukithanks!
23:19chouserthough it's a bit of a hack -- requires the function be named by a var and the definition be in a source file that's on the classpath.
23:20devlinsfAnd it must be Tuesday
23:20chouserit actually reads the source from the clj when you ask, so it could theoretically be out of date.
23:20yuukihmm
23:20chouserdevlinsf: right! use it quick, before midnight...
23:20yuukiI thought that functions might carry around their source
23:21chouserthey do no
23:21chousernot
23:21tomojyuuki: using emacs yet?
23:21yuukinope, vimclojure
23:21tomojoh, maybe they have something?
23:21yuukiI was hoping to inspect the definition of m-bind
23:22tomojemacs has yelled at me for trying to compile files that are in jars, and I guess I'm thankful
23:22tomojnot sure what I was thinking really
23:22chouseryuuki: should work. (source m-bind)
23:22yuuki(defsymbolmacro m-bind m-bind)
23:23chouserheh. that's what it said?
23:23tomoj@def m-bind
23:23tomojhow do you do it
23:24tomojah
23:24tomojm-bind doesn't really have a definition, does it?
23:24yuukiI don't know?
23:24yuukiI was hoping clojure would tell me :)
23:25tomojI think it did
23:25tomojin a strange way
23:25somniumyuuki: try (source monad)
23:27tomojI guess I should try to learn how to use clojure's monads sometime
23:27yuukiI am trying to understand the idea of monads
23:27tomojfor me, clojure tutorials I read were confusing
23:27tomojmade more sense in haskell
23:27tomojbut I guess it's just a confusing subject
23:28somniumthe fact that clojure fns are typeless makes it still harder to reason about (for me)
23:29devlinsfI get the impression that they aren't required as much in Clojure
23:29yuukithe idea of using monads to do I/O without side effects reminds me of plausible deniability for mob bosses
23:29yuuki"What if Johnny were to ... disappear?"
23:30devlinsf:)
23:31JonSmithyou could write a macro to put the source in metadata
23:31JonSmithbut it might be inefficient
23:32devlinsfJonSmith: And you lose it when you partial
23:32JonSmithright that would be bad
23:32tomojsomnium: yeah, when I played with some monad clojure tutorial code, I just got back fns
23:32tomojwith their ugly names
23:32tomojand no way to tell their types
23:33tomojthen gave up :(
23:33somniumIve been experimenting with a deftype that implements ifn and has :source and :type fields, could extend it to partias args too
23:33somniumI think metadata on fns will really come in handy
23:33devlinsfIt can be dangerous, though
23:33JonSmithwould be neat if you wanted to do reflection
23:34devlinsfThat's exactly what you don't want to do
23:34chouserfns support metadata now
23:34JonSmithwell yeah, most of the time :-)
23:34tomojdevlinsf: are you the full disclojure person?
23:34devlinsfchouser: Oh, that's new
23:34chouserdevlinsf: yes
23:34yuukiis being purely functional important in clojure?
23:34devlinsfThe same
23:34somniumId just like to be able to do (:type (*comp f g h)) and get back (seqable -> seqable -> seqable) or something similar
23:35JonSmithbut if you had a specific purpose like code that bugfixes itself, it could be neat
23:35chouser,(meta (with-meta take {:my :meta}))
23:35clojurebotjava.lang.UnsupportedOperationException
23:35devlinsfsomnium: What about (comp f identity g)
23:35chouserah, well, that works in master
23:36somniumdevlinsf: ah well, the types would have to live in the type-system defined by *comp I guess
23:36tomojsomnium: isn't that anti-clojurian?
23:36somniumoh, its in master already? time to upgrade
23:37devlinsfsomnium: Granted, in some respects I'd like that too. It would be nice to define a protocol that guarenteed a certain type
23:37somniumtomoj: its just an experiment
23:37somniumI was playing with a multimethod that could compose fns of various types safely
23:37devlinsfsomnium: Really? That'd be cool to see.
23:37devlinsfLink?
23:38somniumhmm, I can put some in a gist I guess
23:38devlinsfsomnium: If you get a chance
23:39somniumah, found it
23:40somniumhttp://gist.github.com/300031
23:40somniumwas just playing with at the repl (a week or two ago), no idea if I left it broken or not
23:41tomojdevlinsf: I'd pay for an episode on datatypes/protocols
23:41tomoj:)
23:41devlinsfsomnium: Just checking out new ideas
23:41devlinsf$100 :-p
23:42devlinsftomoj: They are so on the list. I'm just waiting to get closer to a release of 1.2 I don't want to cover something while Rich is still working out his own ideas.
23:43tomojgood thinking
23:43devlinsfI'm thinking to seriously start work when 1.2 is in late beta/RC1
23:47somniumcompojure handlers are like (m -> m), and middleware is like ((m -> m) -> (m -> m))
23:49somniumbut sometimes middleware operates on m1 or m2 or both, wondering if there's some way to make that composition more explicit/transparent
23:54somniumdevlinsf: btw, I really liked your & and p aliases, started using them myself
23:55devlinsfsomnium: I noticed :)
23:55devlinsfsomnium: People love 'em or hate em
23:57devlinsfsomnium: Interesting code. I'll have to sleep on it to fully get it. That, and I need to get a basic unstanding of Haskell
23:59somniumIve only solved euler #1 and read monad tutorials in haskell so far :)
23:59devlinsfOh, okay. Then where do your A,B,C... types come from?