#clojure logs

2010-03-18

00:12defnhmmm...
00:13defnso i have an idea -- id like to make something like: (what? [1 2 3] [3 2 1]) => (reverse [1 2 3])
00:14mikemdefn: looks like a "function inference engine" :D
00:15defnyeah i guess that's exactly what it is
00:15defni remember seeing why the lucky stiff's "what_method?"
00:16defnyou could do basic stuff that was similar to the above what_method?([x, y, z] [z, y, x])
00:16defni wonder if it might be easier to implement something like that in clojure, that the "code is data" thing might make life a bit easier...
00:22defnooohhh a fuzzy inference engine maybe?
00:25defnah-ha! no way! http://vimeo.com/9843950
00:27rubknobdefn, i haven't had a chance to look at _why's style of programming but what are your opinions on his style?
00:38lancepantzdo you guys pronounce lein as 'line' or 'lean' ?
00:42Rayneslancepantz: 'line'
00:43RaynesLeiningen is pronounced 'LINE-ing-N', afaik.
00:45lancepantzthanks Raynes
01:52defnrubknob: my opinion on his style is that it's artsy and creative
01:56defnDoes anyone have a working circumspec setup?
02:17crowb4rwhat is circumspec?
02:22defnstuart halloway's testing framework
02:22crowb4rdefn: ahhh
02:22defnnone it looks to be working ATM
02:22defnor maybe i just dont know how to set this up
02:22defni havent read a single blog post or anything on it
02:22defnand his video shows it working, with no mention of beyond some very general information
02:22defnas to how
02:27rfghmm, I have a macro defined in one namespace that is used in another namespace. When I compile the second namespace usually all is fine, but on OS X I'm getting "No such namespace" errors on my Java class imports.
02:42rfgWhere I have (new BorderLayout) it gets expanded to (new java.awt.BorderLayout) but later on when I do (.add canvas# BorderLayout/CENTER), BorderLayout is not resolved.
03:15hiredmanclojurebot: ping?
03:15clojurebotPONG!
03:21sunkencityryleh.
03:22sunkencityrylehI don't get "lein swank" to work it just says "swank is not a task" although I have [leiningen/lein-swank "1.2.0-SNAPSHOT"] as a dev-depencency
03:23hiredmanhave you run lein deps?
03:24sunkencityrylehyes
03:25sunkencityrylehit has downloaded a jar (swank-clojure-1.2.0-break-20100308.145053-4.jar) but maybe I should go with an earlier version of lein-swank?
03:35LauJensenMorning team
03:38TheBusbymorning
03:40sunkencityrylehok, so if I'm running leiningen 1.1.0 I cannot run lein-swank 1.2.0 ?
04:12LauJensensunkencityryleh: No, not that Im aware of
04:13sunkencityrylehLauJensen: ok, it's weird because none of the leiningen plugs I install as dev-dependencies work
04:13LauJensenYou mean they aren't added to the CP when you fire M-x swank-clojure-project?
04:14sunkencityrylehI'm trying "lein swank"
04:14sunkencityrylehor "lein run"
04:15sunkencityrylehbut it just says that "swank is not a task"
04:15sunkencityrylehI guess I'll have to try to find a project with a working project.clj file and start from there
04:17LauJensenhttp://www.bestinclass.dk/index.php/2010/02/reddit-clone-in-10-minutes-and-91-lines-of-clojure/
04:17LauJensensunkencityryleh: Check out the deployment section and git clone the repo
04:18sunkencityrylehthnx, cloning it now
04:19LauJensennp
04:20sunkencityrylehshould I be able to run "lein swank" on that?
04:20sunkencityrylehor do you somehow initiate the swank session from emacs through project.clj?
04:22LauJensensecond - Ive never used lein swakn
04:25sunkencityrylehok
04:26Raynessunkencityryleh: You need to add lein-swank to your dev-dependencies.
04:26Raynesleiningen/lein-swank "1.1.0"
04:27sunkencityrylehRaynes: I had it there, but now I think I see what's missing from the project file, needed :main as soon as I added "[leiningen/lein-swank "1.2.0-SNAPSHOT"]" to dev-dependencies on LauJensens project I could run "lein swank"
04:27sunkencityrylehwhat I mean is that ":main foobar" was missing from my project.clj
04:33sunkencityrylehok the problem was something completely different: dev-dependencies need to be placed in lib/ and doesn't honour :library-path directives
04:34sunkencityrylehnow I got it running
04:34hiredmanyou might file a bug
04:35sunkencityrylehwill do. at least they need to be there to show up as lein $TASK
04:46sunkencityrylehok filed the bug. Been trying to crack that one for a while, it's a bit tedious to have to reboot the server for every change. doing the clojure appengine thing so I need to have the lib directory in WEB-INF
05:45RaynesI can't believe it just took me 10 minutes to write a pangram checker. :|
05:45RaynesI guess when there is like 20 thousand ways to do it, and you're not sure which one is best, they kind of begin to melt your brain.
05:53LauJensenRaynes: use set?
05:53RaynesLauJensen: That's what I went with.
05:54RaynesLauJensen: It filters out anything that isn't a character and then turns it into a set and compares it against a set of all characters in the alphabet.
05:57RaynesIf that isn't good enough, I'll happily admit I suck.
05:57Raynesinb4anotherredneckjoke
06:03LauJensenDidnt mean to knock you
06:11defnsorry to harp on this, but im really interested in playing with it
06:11defnhas anyone successfully set up circumspec?
06:12RaynesLauJensen: Did you get the message I sent after you send "Didn't mean to knock you"
06:13LauJensenno
06:13RaynesLauJensen: <Raynes> You didn't. I was just putting that out there. I usually write code that sucks. I don't think I've ever written a piece of Clojure code that wasn't improved exponentially when I let someone else fiddle with it.
06:15esjoh oh, the instructions say to "be brave"
06:15Raynesesj: That's probably why they have a name that reminds everybody of circumcision.
06:28Licenser_greetings my lispy friends!
06:29LauJensenGreetings and salutations!
06:29RaynesGreetings, sir Licenser.
06:29LauJensen(too slow)
06:29Raynes;)
06:29Licenser_:)
06:31sunkencityrylehwhy do I get "IncompatibleClassChangeError" when I try to (use 'ring.adapter.jetty), I can load ring.adapter.httpcore fine.
06:42sparievso far, defn is the only one who's brave here at #clojure :)
06:42esjI heard him practicing his "FREEDDOOMM" shout earlier
06:46Licenser_why is defn brave?
06:48sparievLicenser_: he's trying to setup http://github.com/stuarthalloway/circumspec with phrase "Be brave" in README :)
06:49zmilamy salutations and thanks to lpetit! i'm waiting for new release of CCW plugin
06:50Licenser_ahh sneaky
06:50RaynesTwo words: auto indentation
06:51Licenser_defn: if you manage to do it make a blog post so the less brave of us can follow
06:53zmilaauto ident is promised to be in the next CCW version
06:54lpetitHi
06:54lpetitI confirm. I'm currently polishing it on my machine
06:54lpetits/polishing/debugging/ :-)
06:54lpetitzmila: salutations too
06:55Licenser_is CCW any good? AKA better then enclojure?
06:55lpetitLicenser_: not as feature complete, yet
06:55zmilai'm using ccw for some monthes, and installed enclojure last week
06:57zmilaenclojure has some minor advantages, but its repl uses pretty-print wich has bug - it doesn't follow *print-length* and displays the whole sequence
06:57lpetitMy rationale is really not to get people migrate from other IDEs to ccw, but rather to do my best so that people used to eclipse can continue use it when migrating to clojure. If people migrate from other IDEs, great, but that's not the goal. I think every people should be able to stay on the IDE he likes.
06:58zmilaour team for ages uses eclipse with java and related
06:58Licenser_lpetit: I just still look for a IDE that I like. I am not really happy with EMACS nor with enclojure
06:59lpetitzmila: I would be happy to get from you a thorough description of what you like and dislike about ccw
06:59LauJensenHey Laurent
06:59lpetitLicenser_: what is it you dislike about enclojure ?
06:59lpetitLauJensen: Hi Lau !
06:59Licenser_Mostly that it is slow, that it is not so nice do interact with the REPL
07:00Licenser_but the NB 6.8 logo looks way cooler then the Eclipse one
07:00lpetitLicenser_: sure this is a great reason :-)
07:00zmilalpetit - i posted some feature-requsts to your project
07:00lpetitzmila: oh it was you ? :-)
07:00zmilamost wanted - code folding
07:01Licenser_lpetit: it is! My work laptop is horrible slow I have to look at the logo 1-2 minutes I
07:01Licenser_need to see something nice during that time so I don"t flip and run amok
07:02lpetitzmila: ok. I also need to rework on the outline, it's currently based on the clojure reader, not so great for parsing potentially broken source code.
07:02zmilamy laptop (some aser) is enough to run eclipse with bunch of plugins (gwt, scala, clojure)
07:03lpetitLicenser_: sorry, can't do anything for this :-)
07:04lpetitTime to go eat smth, cu
07:04zmilalpetit - now the most annoing is some vague paredit behaviour: when i type ( inside existing s-exprs, the plugin inserts ).
07:05zmilasimilar is when i try to put ), the paredit just jumps to the end of )))) to corresponding brace
07:06MaddasLicenser_: Time to pick up meditation!
07:06MaddasEvery time to look at the logo, there's your mini meditation-retreat :-)
07:06Licenser_Maddas: I startet martial arts classes :P
07:07MaddasI have a feeling that shadow boxing for a minute to kill the time will not calm you down, but whatever works :P
07:07LauJensenLicenser_: How recently ?
07:08Licenser_a year ago, did it half a year then had a accident and had to pause half a year now I was allowed to start again
07:08LauJensenok
07:08lpetitzmila: this is expected behavior, no ? paredit tries hard to keep parens correcty balanced. So if you type (without double quotes) "(defn [arg] (hello))" then at each time you will have syntaxically correct code.
07:08esji have some experience of accidents in martial arts classes...
07:08Licenser_Maddas: but training choking techniques on my co workers does wonders!
07:08Licenser_esj: no no it was a work accident
07:09Licenser_I tore my miniscus when I was at a customers site and got attacked by network cables
07:09lpetitzmila: may I close issue http://code.google.com/p/counterclockwise/issues/detail?id=60 ?
07:10esjLicenser_: have mercy. I tore my meniscus, and some other stuff in the knee learning that I could in fact not fly
07:10Licenser_o.O
07:10zmilayes, this issue was due my bad mixing of versions
07:11lpetitzmila: but indeed there is some bug in the parser. Hopefully also corrected in the next release
07:11lpetit'
07:12lpetitFolks, if you just type counterclockwise in your local google, how far in the list do you see "counterclockwise - Project Hosting on Google Code" ?
07:12Maddas7th
07:12zmilafirst
07:12Raynes4th
07:12lpetit7th in England, not so bad
07:13lpetitfirst ???? Where are you located ?
07:13lpetitRaynes: yeah, me too, 4th in France
07:13lpetitThat's great ! :-)
07:13lpetitMust really go eat smthg, cu
07:13RaynesI'm in the USA. :>
07:14lpetitRaynes: oh :-)
07:15Licenser_lpetit: #9
07:15Licenser_in germany
07:16LauJensenlpetit: 3.rd in DK
07:16zmilalpetit, what is the best way to edit "(defn [arg] (inc arg))" to get "(defn [arg] (if (odd? arg) (inc arg))" ? in any try i have to twice delete auto-inserted ) and lately put one ).
07:17Licenser_TM allows things like marking a region then pressing " to encapsulate it in " which I found very nice
07:24esjRaynes: what brand of coffee do you drink... I want some.
07:24Raynesesj: I drink Lipton Black Tea. ;)
07:24esjthis seems impossible.
07:25RaynesBut the reason I've been up all night is because I woke up at 10:00pm.
07:25LauJensenRaynes: you mean 2200 hours
07:25RaynesYeah. That.
07:25esjLauJensen: No, he means 17:00:00 UTC
07:26esj;)
07:26LauJensenoh - Another american staying up all night to crash the economy...well its not the first time I guess :)
07:26esjoh, i thought it was already crashed ?
07:26RaynesHuh? Why is java.util.Date not recognizing daylight savings time. :(
07:27RaynesMy $time command is borked because of it now.
07:27esjRaynes: a world of pain. Check out the Chrono project in Incanter
07:27Raynes<Raynes> $time
07:27Raynes<sexpbot> Raynes: The time is now Thu Mar 18 05:26:24 CST 2010
07:31Licenser_clojurebot: what time is it?
07:31clojurebotmultimethods is what separates the boys from the men.
07:31Licenser_thank you clojurebot, you're helpful as always.
07:32LauJensenRaynes: Daylight Savings Time doesnt start here for another 3 days I think
07:32RaynesLauJensen: It started several days ago here, so there.
07:32Raynes:p
07:32LauJensenIm just saying, you sure your java lib knows that?
07:33esjif it uses tz then yes.
07:33RaynesLauJensen: I don't know what Date knows. I know people filed bug reports about it back in 06.
07:33RaynesAnd I think the bugs are still standing.
07:33LauJensenYou mean THE date? I thought you knew, we're all using Joda nowadays
07:33sunkencityrylehit's not possible to load ring.adapter.jetty while at the same time having appengine-tools-sdk in classpath. bummer :( maybe I can start a swank-server inside the app somehow in dev mode instead.
07:33RaynesJoda it its.
07:34Raynesis*
07:35esjjoda is wrapper in chrono
07:35Raynesesj: clj-time is on Clojars.
07:35_mstJava also ships with its own timezone files. A lovely surprise for sysadmins everywhere :)
07:49defnahhhh, scotch at 7am...
07:52defnMardon me padam. I fool so feelish. I'm under the alfluence of inkahol. Teny meeple pink I'm drunk but they may not think they so bad off as I am.
07:52defnafluence*
07:52defn</off-topic>
07:54defnhaha -- im only sipping -- worked all night and missed the St. Patrick's day festivities...
08:13defn,$
08:13clojurebotjava.lang.Exception: Unable to resolve symbol: $ in this context
08:14defnis $ anything in clojure?
08:14Chousukeno
08:14defnheh, is that a ridiculous question? or is it intentional?
08:15Raynesdefn: It's my bot's command prepend. Does that count? ;)
08:15defnwe have everything except $, %, ; -- what am I missing?
08:16Raynes,.
08:16clojurebotjava.lang.Exception: Unable to resolve symbol: . in this context
08:16RaynesOh yeah, dot is used.
08:16RaynesHeh.
08:16spariev,:-
08:16clojurebot:-
08:16defnwhat's that thing?! :)
08:16Licenser_,
08:16clojurebotEOF while reading
08:16Licenser_,:-P
08:16clojurebot:-P
08:16Raynes,()
08:16clojurebot()
08:17defn,::--PP
08:17clojurebot:sandbox/--PP
08:17Licenser_,-3
08:17clojurebot-3
08:17defn,(doc :)
08:17RaynesLauJensen: If that presentation pops up, let me know so I can brag to all my (fictional) friends. :D
08:17clojurebotInvalid token: :
08:17LauJensenhehe - will do
08:18defn;-xyz
08:18defn,-xyz
08:18clojurebotjava.lang.Exception: Unable to resolve symbol: -xyz in this context
08:19defn(def -f 42)
08:19defn,(def -f 42)
08:19clojurebotDENIED
08:19sunkencityrylehin the olden days run-server would start a jetty instance and then return, but with this new run-jetty it just keeps on having control of the thread, do I manually need to start a thread?
08:19Licenser_no def for you
08:19RaynesThat's a no-no.
08:19Licenser_,(eval 1)
08:19clojurebotDENIED
08:19defn-x works, huh?
08:20defnweird
08:20defnerr (def -x 1)
08:20Licenser_defn: clojure bot does not allow to def stuff
08:20Licenser_, (set! a 1)
08:20clojurebotjava.lang.Exception: Unable to resolve symbol: a in this context
08:20Licenser_,(set! *warn-on-reflections* true)
08:20clojurebotjava.lang.Exception: Unable to resolve symbol: *warn-on-reflections* in this context
08:20defn(def $f 1) works
08:21Licenser_,(set! *warn-on-reflection* true)
08:21clojurebotjava.lang.IllegalStateException: Can't change/establish root binding of: *warn-on-reflection* with set
08:21Licenser_good :) clojurebot does not break!
08:21Licenser_,*clojure-version*
08:21clojurebot{:interim true, :major 1, :minor 1, :incremental 0, :qualifier "master"}
08:22sparievis it ok to use keywords like :- and :+ ?
08:22Licenser_,(set! *clojure-version* {:interim true, :major 1, :minor 1, :incremental 0, :qualifier "master"})
08:22clojurebotjava.lang.IllegalStateException: Can't change/establish root binding of: *clojure-version* with set
08:22Licenser_:D
08:22sparievi mean is it considered good style ?
08:22defnhow could that be good style?
08:22defn:)
08:22Licenser_defn: like for writing parsers
08:22defnoh i see
08:23sparievI'm writing parser right now and use :-
08:23defni can see some cases where it might be novel
08:23Licenser_see :P
08:23Licenser_then I
08:23Licenser_'d say yes
08:23defnspariev: could you give an example line where you use :-
08:23sparievie (when (= "-(" open-paren) :-)
08:23Licenser_like to represent 1 + 1
08:23Licenser_{:function
08:23sparievwriting parser for lucene queries
08:23defnvery cool
08:23Licenser_{:function :+ :args [1 1]}
08:24sparievcompatible with sphinxsearch syntax
08:24defnGene?
08:24clojurebotmarkov chain generator is http://groups.google.com/group/clojure-study-dc/browse_frm/thread/026ccdc8acb102f9?pli=1
08:24lpetitzmila: currently, none that is satisfactory. I also (since I'm eating my own dogfood when writing ccw) have to select a space around the bracket to be able to delete one. When paredit gets more feature (not the next release, the next - next), you will be able to "slurp" an sepxr into another, like this (consider the cursor is located where I place the pipe char | ) : "(defn [arg] |(inc...
08:24lpetit...arg))" -> EDIT -> "(defn [arg] (if (odd? arg))|(inc arg))" -> BACKSPACE -> "(defn [arg] (if (odd? arg)|)(inc arg))" -> SLURP -> "(defn [arg] (if (odd? arg) |(inc arg)))"
08:25sparievOnly with lisp you can have smilies in your code :-)
08:25defn,(:-)
08:25clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to keyword: :-
08:25defn,'(:-)
08:25clojurebot(:-)
08:26defni want to make a tshirt with that on it
08:26Licenser_it is cool
08:26Licenser_I bet you could make a smily brainfuck interpreter in clojure
08:27defnit's just so distinct -- i really love that about clojure -- it has a real flavor to it
08:27defnthe java flavor was always like swallowing a rock
08:27defnbut this is awesome
08:27zmilalpetit, ok. but maybe it's reasonable to make auto-insert be configurable? say i turn it off, type a lot of code, then press "reformat" (nice feature request:) or do balance by myself
08:28defnspariev: that's very cool you're working on lucene + sphinxsearch -- do you have any public code?
08:29lpetitzmila: or with another possibility of paredit, which is to encapsulate an sexpr in surrounding parens : "(defn [arg] (inc arg)|)" -> GO TO MATCHING BRACKET -> "(defn [arg] |(inc arg))" -> SURROUND WITH PARENS -> "(defn [arg] (|(inc arg)))" -> EDIT -> "(defn [arg] (if (odd? arg)| (inc arg)))"
08:29Licenser_lpetit: that
08:29Licenser_'d be awsome :)
08:30Licenser_I also really want a SLURP key on my keyboard now :(
08:30lpetitzmila: in paredit, there's a keyboard shortcut to say : insert the next character I type "as is", do not use paredit. Or you can disable paredit by going to the workbench clojure preferences
08:31lpetitWhat could be the slurp keyboard shortcut for Eclipse ? What could be the SURROUND WITH PARENS keyboard shortcut for Eclipse ?
08:31zmilalpetit, maybe. i can't find "select till matching paren"
08:31defni really wish paredit worked properly on {}, and in slime
08:31lpetitdefn: what do you intend by "worked properly on {}" ?
08:31defnslurping and spitting like () or []
08:32lpetitzmila: like in java editing : Ctrl + Alt + P
08:32sparievdefn: well, it's more like lucene instead sphinx - we are moving from sphinx to lucene-backed (zoie + bobo, to be more precise) search, and I want to make as little changes in frontend as it possible
08:32defnerr slurping and barfing
08:32lpetitdefn: I guess there are some additions to paredit.el floating around the community. Though not integrated into technomancy's "bundle"
08:33zmilalpetit - C-A-P just jumps to matching brace, not selects the text inside
08:33defni used the bundle as a template
08:33lpetitzmila: oh, "select" till matching paren, not I don't have this one right now
08:33defni think it is a much better experience to learn elisp while you learn clojure
08:34LauJensen"learn elisp", whats to learn ?
08:34defni didnt know a lisp -- or do you mean that sarcastically?
08:34lpetitzmila: I guess it will be like in java editing, but not named "select to matching bracket", but rather "Expand selection to enclosing element" ( Shift + Alt + Up)
08:35LauJensendefn: Im just saying there's not a whole lot to learn, its a homoiconic prefix notated lisp, just like clojure. the scope of its use is very simple and after a skim of the API you're good to go
08:35LauJensenoh course if you're drunk, its another story I'll give you that :)
08:36lpetitzmila: a contributor contributed this, it will be included in the next release, too. He did not make this by extending paredit, though, so the underlying implementation wil change over time, when I port it to paredit (and it will handle edge cases better as well then, I guess)
08:37lpetit"a contributor contributed", wow, I'm really a good writer :-)
08:37zmilalpetit, ok. there are also C+S+[ or C+A+( unbound (for "wrap in [" or "wrap in (")
08:38LauJensenlpetit: You're a frenchmen from france, its ok
08:38zmilanew Runnable.run() :)
08:38lpetitzmila: I would not mind if you put an entry or this in the bug tracker, as a reminder. And then you can also "follow" the bug and see when it is implemented
08:39zmilaok, lpetit. I'll create new issue for slurp or wrap
08:40lpetitAnd maybe a separate one for For C+S+[ / C+S+{ / C+S+(
08:40lpetitoh you said "or wrap", sorry. Seperate issues for slurp and for wrap, please
08:40lpetitzmila: thx
08:40lpetitLauJensen: :-p
08:42defnLauJensen: I don't like how (:a |:b :c) -> OPEN PAREN -> (:a (|):b :c) -> SLURP -> (:a (| :b) :c) works
08:42LauJensenWhat are we talking about now defn ?
08:42zmilalpetit, do you have any architectural docs for your ccw project? if i decide to try to contribute to the plugin, how do i start? besides downloading the sources
08:43defnbah, sorry
08:44lpetitzmila: alas, not yet
08:45lpetitzmila: you are already familiar with eclipse plugin dev ?
08:45defnLauJensen: Maybe I'm just not as smart as you. To me, homoiconicity, prefix notated lisp, was not something I just intuitively realized in one afternoon.
08:46defnhomoiconic*
08:46zmilalpetit, not yet. but this skill is in my wish-list :)
08:46LauJensendefn: I dont remember how long it took me, but for Raynes it came naturally
08:46RaynesHomoiconicity made sense to me rather instantly.
08:46LauJensendefn: (and I wasn't making any remakrs about your IQ, which Im sure is quite high)
08:47zmilanow i'm in a project where the whole UI is build like eclipse: workbench/editors/views/plugins
08:47RaynesI think I have an IQ of 108.
08:47RaynesBut that was a year ago.
08:48defnRaynes: I guess I just don't believe you just instantly understood the implications of a homoiconic language.
08:48defnThat seems to border on certain arrogance.
08:48RaynesCode that writes code. I'm not sure what is ambiguous about that.
08:49RaynesMaybe I only think I understand it then?
08:49LauJensendefn: Thats out of line imho- The fact that raynes either understood, or failed to understand all of the implications does not warrent that you call him arrogant
08:49RaynesIt's alright. Maybe I am being arrogant. I /think/ I understand the implications. Maybe I'm wrong.
08:50defnI think you're reading me wrong here
08:50lpetitzmila: maybe you can open a bug to remind me to write a wiki page on how to start with installing the ccw dev environment ? :-)
08:50defnWhat I'm trying to say is that yeah, code writing code, that's not very difficult to think about. A robot building a robot. I just don't think I understood out of the box how to apply that.
08:51defni need to know what a robot is before i can use it, you know?
08:52defnand there again I suppose you could probably claim that, yeah, a language is composed of little pieces, and you just use them -- but again I would feel like I would be cheating a bit to say I knew all of them
08:52zmilalpetit, in our team exists following convention: one who asks smth, after receiving answer, must write what he get into wiki :)
08:53RaynesI never said I was instantly an expert on homoiconicity.
08:53defnzmila: haha, that is an excellent idea
08:53RaynesI knew about it before I learned Clojure.
08:53RaynesMacros came easy to me, however.
08:53defnAh, not to me.
08:53RaynesUnderstanding them, that is.
08:53zmilaso, if you tell me "how to ..." - then I write this for you (and for all new-comers)
08:53RaynesWriting them? Heh.
08:54ChousukeI find designing macros much trickier than writing them
08:54lpetitzmila: give me your google account, now ! :è)
08:54lpetit:-)
08:54lpetitzmila: and I open up the wiki for you :-)
08:54defnyeah i think maybe my definition of understanding is just including the whole application rather than just 'getting the idea'
08:54ChousukeI mean, for any one problem a macro can solve, there are n different macros you can write
08:54defnChousuke: yeah, it is a different layer
08:55RaynesWell, I wasn't lying when I said that Lisp came easy to me. My only real exposure to anything else was primarily Haskell, so I didn't have much of anything else bleeding my mind dry of resources.
08:55defnah-ha -- I came from Ruby. A lot of it made a whole mess of sense to me.
08:55defnOther things not so quickly
08:56RaynesMetadata is what I had trouble with.
08:56RaynesI could not understand what it was useful for.
08:56RaynesI still never really use it.
08:56defnI think I'm close to my 6 month mark with clojure and I feel like I'm building some muscle
08:56defnRaynes: oh man! it's great!
08:56Chousukeand you need to consider several attributes. How well does it fit with existing code or language idioms? Is it flexible enough that the user is not tempted to write the pattern manually anyway? Does it make the code clearer? ... all kinds of questions
08:57defni remember being in a daniel dennett lecture and I began thinking about some very elabroate silly AI idea with metadata, you can use it for all sorts of cool purposes
08:58ChousukeI often hear people saying that lisp has little syntax, but what do you call all those little mini-languages that macros implement using the basic syntactic elements? :/
08:59Chousukelisp can have a *lot* of syntax if you don't restrain yourself :P
08:59defnhaha
09:00defni love this line i heard awhile back... i think it was in code complete, about a guy "meditating for 4 hours and then emitting a single, elegant statement"
09:00defnsomething like that, anyway
09:00ChousukeWhich is why I think macros should be designed to reuse syntactic elements so that their semantics approximate their use in other macros
09:00defnChousuke: could you show me what you mean?
09:01Chousukedefn: eg. it would be silly to write a macro in Clojure that takes arguments in a list.
09:01ChousukeYou should use a vector instead
09:02Chousukeit would be trivial to write CL-style let or defun but it wouldn't be idiomatic :/
09:02RaynesThere still isn't anything for SOAP in Clojure-world is there?
09:06defnChousuke: ahhh!
09:06RaynesYou know... clojars.org could have been a full-fledged Clojure project forge.
09:06chousergithub's really good at most of that
09:06defnit can't be still?
09:07defngithub doesnt have let you see what the 70th most popular clojure project is
09:07defni really dislike that limitation
09:07Rayneschouser: Github is great, but that's not my point.
09:07defnRaynes: i agree with you 100%
09:07defnerr 90%, i think it still has the potential to be
09:08RaynesMaybe we should tell ato.
09:08RaynesSadly, he isn't here right now. :(
09:08defnhe's a busy man I'm sure
09:08RaynesIndeed, but we should still run it by him.
09:08defnthat code is publicly available fwiw
09:08ChousukeI wish clojars.org at least had links to the official project page :P
09:08RaynesI don't do web-development.
09:08Raynes:|
09:08RaynesEver.
09:08defn"patches welcome."
09:09RaynesIf he says that, we'll go get a guy name Patches to run it by him. :p
09:10defnive met a starsizio, but never a patches
09:10defnive also never met a bertrand
09:10defnbut that's another story entirely
09:17Rayneshttp://rosettacode.org/wiki/Color_of_a_screen_pixel#Clojure
09:18RaynesOops, wrong window.
09:46LauJensendefn: ping?
09:48sparievjust received email about updates to Practical Clojure book
09:48sparievtwo new chapters on parallel programming and datatypes/protocols
09:54rfgspariev: they haven't sent me an e-mail :(
10:40patrkrisis there a smart way to ad hoc suppress printing in the REPL for the evaluation of a form?
10:43bmasonpatrkris: check out with-out-str
10:44bmasonmight not be exactly what you're looking for but it's the right area of the API I'd wager
10:45patrkrisbmason: it's fine for me, thanks!
10:47Chousukeyou can also bind *out* to a dummy Writer
10:47bmasonright... and I think with-out-str uses bind internally
10:52patrkrisis there an easy way to get several values from a map given a set of keys and have the result as a list/vector?
10:53patrkristhe latter in the order of the keys given
10:53chouser(map your-map keys)
10:53chouserheh
10:53chouserthat's not very clear. vocab collision
10:53chouser,(map {:a 1, :b 2, :c 3} [:c :a])
10:53clojurebot(3 1)
10:54patrkrischouser: of course! I should've figured that out myself! :)
10:56fliebelchauser: wait… you just used a map as a function?
10:57fliebel*chouser
10:57patrkrisfliebel: yes he does
10:57Chousukefliebel: they are functions :)
10:58patrkrisfliebel: which I should have known how to utilize
10:58fliebeluuuhm… let me see...
10:58fliebel,({:a 1, :b 2, :c 3} :c)
10:58clojurebot3
10:58fliebelwow
10:59Chousukefliebel: associative things in general are functions of keys to values
10:59Chousukefliebel: works for vectors too
10:59Chousukeand sets; the values are just the keys themselves.
10:59fliebelHow about the other way around?
10:59fliebel,(:c {:a 1, :b 2, :c 3})
10:59clojurebot3
10:59Chousukefor keywords and symbols, yes.
11:00fliebelSo any collection is a function that will return the value corresponding to the key?
11:00arnihermannCan anyone take a look at this macro: http://paste.pocoo.org/show/191133/
11:00Chousukefliebel: any Clojure associative collection
11:01arnihermannwhen I expand it, I get weird fn back
11:01arnihermann(fn* ([] (clojure.core/for [pred__2980__auto__ state__2981__auto__ :let [[p0 p1 p2 p3] pred__2980__auto__] :when (and (= cell) (= b))] {?y 2, 2 1})))
11:01Chousukefliebel: neither lists nor seqs are functions
11:01fliebelok :( so I can't do ([:a :b :c] 0)
11:01arnihermannI meant, (fn* ([state__3078__auto__] (clojure.core/for [pred__3079__auto__ state__3078__auto__ :let [[p0 p1 p2 p3] pred__3079__auto__] :when (and (= cell) (= b))] {?y 2, 2 1}))), which looks odd (fn ([...] ...)
11:01Chousukefliebel: you can. that's a vector, not a list :)
11:02Chousukefliebel: it's associative
11:02Chousukearnihermann: fn is a macro
11:02Chousukearnihermann: expands to fn*
11:02fliebeluuuhm, Whats the difference between a vector, seq and a list? All of them are a bunch of values, right?
11:02Chousukearnihermann: you can treat fn* as fn without destructuring
11:03Chousukefliebel: a vector is an indexed collection, a seq is a list-like "virtual" collection, and a list is just a list: no indexes
11:03arnihermannah
11:04arnihermannnot sure how I fix this...
11:04fliebelChousuke: which means? I can't get the nth item of a list?
11:04Chousukefliebel: you can, but not in constant time
11:04zmilanth element from list is O(n), nth of vector is O(1), i guess
11:04Chousukefor the meaning of "constant" as applied to clojure collections...
11:05esjhas anybody tried to store a set using congomongo ? I get an error it can't serialize the set, and was wondering if there is a good reason why that should be the case.
11:05fliebeluuuhm, okay, so why would I want to use a list or seq?
11:05Chousukefliebel: why not? for a lot of your data, you don't care about the index.
11:05esji mailed somnium but I think he's on holiday, probably skiing !
11:05zmiladepends on what operations your want to perform on the collection
11:05Chousukefliebel: and seqs can be lazy, unlike vectors
11:06fliebelI knew that one… But for the rest it's a matter of efficiency?
11:07RaynesI is clean, shaven, and ready to go. :D
11:07dpritchettI really enjoyed Ch 4 on sequences in Programming Clojure
11:07arnihermannChousuke: without destructuring?
11:07dpritchettI have not built much with clojure yet but it certainly helped me understand
11:08esjRaynes - surely its bedtime by now ?
11:08esjyouth of today !
11:08Raynesesj: Absolutely not! It's time to take rentals back to movie gallery and get some chow.
11:09Chousukearnihermann: yeah. the code for destructuring is generated by the fn macro and fn* doesn't need to support it.
11:10Chousuke,(macroexpand '(fn [[a b]] [b a]))
11:10clojurebot(fn* ([p__6668] (clojure.core/let [[a b] p__6668] [b a])))
11:12Raynes,(macroexpand '(macroexpand blah))
11:12clojurebot(macroexpand blah)
11:12Raynes:D
11:13arnihermannChousuke: still not following, sorry :) can you propose a solution?
11:13arnihermanncode bit?
11:14Chousukearnihermann: oh, I don't think that applies to your problem
11:14Chousukearnihermann: what is your problem, anyway?
11:14Chousukehow does the macro fail?
11:14arnihermanncode should be generated (fn []) but not (fn ([]))
11:14arnihermannnotice the extra parenthesis
11:14arnihermannaround []
11:14arnihermannright?
11:14Chousukearnihermann: ah, that's not an issue.
11:15Chousukearnihermann: that's part of fn syntax
11:15arnihermannhmm
11:15raekfliebel: it's a common clojurian practice to use vectors when you want some kind of literal sequence in you code
11:15arnihermann(expand-true '(cell ?x ?y b) '?player)
11:15arnihermannjava.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Named (NO_SOURCE_FILE:0)
11:15Chousuke(fn [foo] bar) is just shorthand for (fn ([foo] bar))
11:15arnihermannI get this error
11:15arnihermannwhen calling the code
11:15arnihermannok, right
11:15arnihermannof course
11:15raekso, you will mostly see vectors in example code
11:16arnihermannand I don't understand the error msg
11:16Chousukearnihermann: why are you quoting the parameters to expand-true?
11:17raekfliebel: (linked) lists and vectors have different performance for various operations
11:17fliebelI see
11:17arnihermannChousuke: I don't want them evaluated
11:17raekit's efficient to add to the front of a list but to the back of a vector
11:17Chousukearnihermann: they aren't.
11:17Chousukearnihermann: parameters to macros are not evaluated
11:17arnihermannChousuke: aaaa forget
11:17Chousukearnihermann: they're just the plain symbols and whatever you pass
11:17arnihermannChousuke: right
11:17arnihermannChousuke: of course, I forgot
11:17arnihermann:\
11:17raekseqs are sequencial views of a collection (vector, list, map, java.util.Collection, etc)
11:18raekand not a collection type per se
11:18Chousukeseqs can also be constructed from simple functions, so there doesn't need to be an actual collection backing it.
11:19arnihermannChousuke: (expand-true (cell ?x ?y b) player)java.lang.Exception: Unable to resolve symbol: state__3440__auto__ in this context (NO_SOURCE_FILE:141)
11:19psykoticand in the airplane i wrote this hack:
11:19arnihermannChousuke: the error now
11:20arnihermannChousuke: but now I'm generating new symbol?
11:20arnihermannstate#
11:20psykotichttp://gist.github.com/336461
11:22Chousukearnihermann: that would mean the generated code contains the state# symbol in some way that makes it refer to a global instead of the local variable
11:23Chousukeclojurebot: macro help
11:23clojurebotmacro help is http://clojure-log.n01se.net/macro.html
11:23Chousukearnihermann: could you fill in that, please?
11:27ldpHas anyone used vimclojure?
11:27ldpAnd is it any good?
11:27fliebelI do, and I like it.
11:27ldpfliebel: Thanks. :)
11:27fliebelYou need to run nailgun in the background to get auto completion though.
11:28ldpfliebel: Explain?
11:28fliebelvimclojure relies on some strange java lib for a few more advanced features.
11:29fliebelI run it without it most of the tie unless I need to do extensive debugging.
11:29ldpfliebel: Ah, I see.
11:29ldpfliebel: Mind explaining how exactly I install vimclojure? I can't get it working. :/
11:30fliebelThere is some strange video somewhere about it, but it took me a while as well.
11:33Chousukehttp://kotka.blip.tv/#1894565 this one?
11:36petrusldp: blog post about using vim with clojure: http://writequit.org/blog/?p=386
11:36arnihermannChousuke: not sure I follow, again, sorry :)
11:37Chousukearnihermann: I can help you better with the macro if you provide the information requested on the macro help page.
11:38sparievsuppose I want iterate seq for side effects, what's more idiomatic - doseq or map wrapped with doall ?
11:38ChousukeI would say doseq
11:38chouserspariev: do you need the return value as well?
11:38_invishi everyone
11:38_invisHope you could help me
11:39_invisI want to use Emacs + CLojure... :)
11:39arnihermannChousuke: thanks, will do
11:39_invisdo all the same like here http://vimeo.com/2419596
11:39Chousukehm, that's a bit old.
11:39_invisbut When I start emacs I have message Cannot open load file, clojure-auto
11:40Chousukeyeah. it's outdated :(
11:40_inviswhat I should update ?
11:41sparievchouser: ie I need to modify some java objects and doto won't fit
11:41sparievchouser: so I dont need return value
11:42sparievdoseq feels so imperative
11:42chouserspariev: then yes, I'd suggest doseq.
11:42polypus~ping
11:42clojurebotPONG!
11:42sparievchouser: thanks
11:42Chousukespariev: that's the point. you're doing imperative things so make it look so :)
11:42_invisGuys plz help me to start emacs with clojure :(
11:43sparievyep, but it makes me sad :)
11:43Chousukehm, I always forget what the best blog/source for installing emacs/clojure-mode is ;/
11:44_invisI did 90% like in this video
11:44_invisand all was ok
11:44_invisbut Cannot open load file, clojure-auto WTf it mean
11:44Chousukeit means it's trying to load a script that no longer exists.
11:44_invisit was in clojure-mode.el ??
11:45_invisin 2008.. :( ?
11:45Chousukesomething like that
11:45_invishmm
11:45Chousuke_invis: I suggest you just install ELPA and use it to install the packages
11:45_invisso i just need to new emacs config
11:45Chousukeare you using the starter kit?
11:45_invisI trying ELPA
11:45_invisbut it was bad
11:45Chousukehttp://technomancy.us/126
11:47_invisty, i will try
11:57chouserhow wrong would it be for me to use lazy-seq just for its ability to synchronously produce and cache a single value?
11:58chouserthe natural solution would involve manual locking and perhaps an atom.
12:00ldpfliebel: I still can't get it to work. :/
12:01fliebelI don't know how to help you… I just did what they said and after some trying it worked. I could pastebin the content of some files if you're in doubt.
12:01chouseroh! I should use a delay. that's better.
12:02Chousukechouser: delays may be underused in Clojure :/
12:02ChousukeAt least, it's all too easy to forget that clojure has them, because there are so many neater tools available.
12:03ldpfliebel: can I have your vim rc and the location to where you copied the vimclojure files?
12:03chouserbleh, I need a delay that takes args.
12:03psykoticwell, they're heavily used through lazy-seq, but not so much manually
12:03Chousukechouser: a memoized function? :/
12:03psykotic(doesn't lazy-seq call delay?)
12:04Chousuke~def lazy-seq
12:05Chousukeapparently not :P
12:05chouserno, I need to do work with args the first time its called, have the cached item avaible directly afterwards, but if the fn is called again just complain.
12:05fliebelldp: I think so… but I'm not sure anymore where they are.
12:06Chousukehm
12:07Chousuke,(let [a (#^{:once true} fn* [] (print "foo") 1) ] [(a) (a)])
12:07clojurebot[1 1]
12:07clojurebotfoofoo
12:07Chousukewhat does that actually do? :/
12:09ldpfliebel: ls ~/.vim perhaps? :/
12:10fliebelldp: http://pastebin.com/mK72wMxW is my vimrc
12:11fliebelbut there was more to it...
12:11Chousukedon't forget the local.properties file
12:12ldpfliebel: doesn't work. :/
12:12Chousukehow does it actually fail?
12:12dakroneI believe it should be let g:clj_highlight_builtins=1 ldp & fliebel
12:12ldpdakrone: Neither work
12:13Chousukedo you have the nailgun server running?
12:13dakroneokay, I'm coming into the conversation late, what's happening?
12:13ldpChousuke: I don't want nailgun. :/
12:14Chousukeldp: then you need to remove the clj_want_gorilla thing I think
12:14Chousukeit depends on nailgun
12:14dakroneldp: what error are you getting?
12:14ldpdakrone: There's no error, it just doesn't work.
12:14dakronecan you describe what part doesn't work?
12:15ldpsyntax highlighting and rainbow paran
12:15ldplet me check if there's something wrong with ~/.vim
12:16dakroneldp: do you see the same output from this: http://pastie.org/875642
12:16fliebelldp: did you add the file handler? I remember there was something to do berfore it enabled vim mode
12:16dakroneminus the eclim file
12:16ldpYay, it works now.
12:16ldpI re-copied the files.
12:16fliebelwhat was wrong?
12:16ldpdirectory structure.
12:16dakronemust have been missing a file
12:16ldpOr that.
12:16ldpRainbow parens are awesome. :)
12:17Chousuke:P
12:17ChousukeI don't even look at parens anymore
12:17dakronethey're quite useful for reading other people's code
12:17ldpChousuke: I'm not used to parens, though.
12:17ldpChousuke: braces, yes, but not parens. :p
12:17ldpRuby has pampered me.
12:18chouserparens are critical in Clojure. huge difference in meaning between (foo) and foo
12:18Chousukeldp: most of the time I don't need to care about where the parens are because paredit puts them in the right place. :) dakrone's point is valid though
12:18dakroneI was never really clear on what paredit does, does it just auto surround your code with parens?
12:19Chousukedakrone: it maintains correct s-expression structure at all times
12:19dakroneoh okay
12:19dakronethere's no real good explanation of what it does for non-emacs users online that I could find
12:19Chousukedakrone: unless you screw up somehow, it's impossible to write just "((" or "(let [foo))" in paredit
12:20dakroneChousuke: what if you want to write ((func-that-returns-a-fn ...))?
12:20The-Kennydakrone: that's no problem
12:20Chousukeyou *type* ((func-that-returns-a-fn
12:20Chousukeand that's it.
12:21The-Kennyemacs insert a ) when you type a (
12:21dakroneokay, I thought you said it would prevent you from writing ((, or does it evaluate enough to know that it's a valid form?
12:21Chousukethe thing is that if you have ((foo)), you can't delete the )) before you've deleted foo
12:22Chousukeusing only backspace that is. of course, there are more advanced s-expr manipulation commands
12:22ldpI just wanted to say, you guys are pretty awesome. :)
12:22ldpClojure is going to be fun to learn.
12:22Chousukefor example, paredit has a command that allows you to move foo so that ((foo)) becomes (foo ())
12:23miltondsilvaChousuke: is there some tutorial that explains those commands?
12:23Chousukehttp://mumble.net/~campbell/emacs/paredit.html there's this at least
12:23chouserin standard vi, that command is dwhP
12:24miltondsilvayes but I have no idea how to interpet that :P
12:24Chousukechouser: imagine foo is an entire form. now what do you do? :)
12:24miltondsilvaoh forget it
12:25miltondsilvaI can see there are keys and the examples are more sane... I read some other version that I couldn't understand
12:25dakronechouser: uhh... delete-word move-left paste-word
12:25dakronechouser: so essentially it brings you right back to where you are
12:25chouser(((foo bar baz))) --> ((foo bar baz)()) is d%hP
12:25dakroneoh wait, P will paste previously
12:25chouserdakrone: right
12:25dakroneso paste it to the left by one space
12:26dakroneI read it as dwhp
12:26The-Kennyenebo: Yeah, that too :P
12:26chousermy point is not that stock vim has 100% the convenience of paredit
12:27chouserbut that stock vim is a 90% solution for so many situations, including editing of clojure code, that it's difficult to justify the effort required to replace it, just for that last 10% :-/
12:27eneboesj, The-Kenny: Yeah ^K is the shit...down with d$ :)
12:27chouserd$ == D
12:27eneboah yeah
12:27The-Kennyenebo: In paredit, C-K is different to "delete to end of line"
12:28dakroned$ == C
12:28The-KennyIn paredit, it kills sexps, not lines
12:28eneboheh...I joined this convo late with the accidental ping :)
12:28esj;)
12:28eneboI regularly use both vi and emacs...
12:29enebobut emacs is like some mother ship always orbiting my screen somewhere...vi is for quick and remote edits
12:29Chousukeheh, yeah
12:29miltondsilvaemacs = O.S.
12:30Chousukeemacs is more like the JVM than an OS
12:30Chousukeit's a platform
12:30replacaenebo: you know about emacsclient, right?
12:30Chousukefor editing whatever editable things you can imagine
12:30The-KennyEditing files in jar-files without manually extracting and re-packing is cool
12:31miltondsilvanever thought of it that way, but now that you mentioned it it makes more sense
12:34duncanmi propose renaming BUT-LAST in clojure.contrib.string to something like DROP-RIGHT
12:35The-KennyEmacs even has the power to create a powerful agendas, spreadsheets and full-featured gtd-setups out of text files :)
12:35chouserduncanm: there's drop-last also
12:35duncanmoh, is there?
12:36duncanmnot in clojure.contrib.string, according to the docs
12:36duncanmdrop-last is good too
12:36chouser,(drop-last 3 (range 10))
12:36clojurebot(0 1 2 3 4 5 6)
12:36duncanmyeah
12:37duncanmso s/but-last/drop-last/ and it'll be golden
12:38ldpcan anyone explain references to me?
12:39duncanmldp: did you read up on it first?
12:39ldpI did, and I don't really understand.
12:40eneboreplaca: yeah
12:41technomancyboo... c.c.string has but-last and clojure.core has butlast. =(
12:41duncanmtechnomancy: eeew, that's even worse
12:41duncanm,(doc butlast)
12:41clojurebot"([coll]); Return a seq of all but the last item in coll, in linear time"
12:41duncanm,(doc drop-last)
12:41clojurebot"([s] [n s]); Return a lazy sequence of all but the last n (default 1) items in coll"
12:41technomancyduncanm: what's worst is the similarities. butlast isn't a terrible name
12:41chouserbutlast is eager
12:41technomancyeasily discoverable with find-doc
12:42duncanmhmm
12:42absalomSo I'm a bit confused about the various clojure emacs modes... I have ELPA. Which modes should I install? swank-clojure and clojure_mode? And swank-clojure relies on slime?
12:42duncanmthe names i'm most familiar with are from SRFI-1 in Scheme, but I know that CL has its own set of names
12:42technomancyabsalom: all you need is swank-clojure; see the swank-clojure readme on github for details.
12:42absalomah, ok thanks
12:42technomancythe dependencies will get handled for you
13:01crowb4r, (doc drop-last)
13:01clojurebot"([s] [n s]); Return a lazy sequence of all but the last n (default 1) items in coll"
13:05slyphontechnomancy: hey, do you know, if i want to turn on paredit mode in the slime-repl buffer, er, where do i hook that?
13:05technomancyslyphon: should be able to use slime-repl-mode-hook
13:05slyphonah, ok
13:12chouserthere's no way to test if a promise has already been delivered or not. oh well.
13:14crowb4rSo, is there any good code completion for clojure. The api ref on the site is nice, but still.
13:14slyphoncrowb4r: depends on what editor?
13:15crowb4rthe la clojure module seems to work for intelij, but for say emacs or just anything else in general.
13:16dnolencrowb4r: if you're Emacs and Vim it's pretty easy to setup TextMate like snippets. slime autocomplete for symbols is pretty good.
13:24abrenkstuarthalloway: I just took a look at circumspec - nice!
13:25abrenkstuarthalloway: project.clj is missing ":namespaces [circumspec.AssertFailed]"
13:25stuarthallowayabrenk: thanks, hope it is useful
13:26stuarthallowayah, I haven't been using lein compile
13:27abrenkperhaps it would be better to use a JDK provided exception?
13:27abrenkusing circumspec in a clojure 1.1 project resulted in a VerifyError
13:28stuarthallowayabrenk: lein compile added to master
13:28stuarthallowaycircumspec is targeting 1.2
13:28stuarthallowayit probably would not be hard to get it to work with 1.1 but I won't be doing it
13:29abrenkyeah, I solved that
13:29abrenkbut being tied to a specific clojure version just because of AssertFailed is a pity
13:30stuarthallowayif that is the only issue just change your local project.clj to point to 1.1 and rebuild from scratch and you should be good
13:32remleduffI've got this simple function that I've written called files-in-dir, I have it at this gist: http://gist.github.com/336602. How would I go about making it a varargs so that it works for any number of directories passed?
13:34dnolenremleduff: (fn [arg1 arg2 & rest] ...)
13:35remleduffYeah, I know that much, but actually using &rest is what I'm a little hazy on
13:36woobyremleduff, maybe something like http://gist.github.com/336610
13:36woobyremleduff, that has some issues (& rest conflicting with the other 2 arg definition), and i'm new to things myself
13:36abrenkstuarthalloway: already did that and it works, thanks. I just wanted to provoke some thoughts if perhaps it would be better to build the framework without the need for AOT compilation.
13:37dnolenremleduff: rest just packages up the remaining arguments into a list.
13:37dnolenrest -> & rest
13:38stuarthallowayabrenk: the issue is in run-test. If I use any preexisting exception to represent test assertions, then it complicates the logic for separating test failures from errors
13:43chouserthat's got to be the one most reasonable driving force behind wanting to derive a named class from an abstract (non-interface) class
13:43chouserperhaps it would be worth a defexception in contrib that uses ASM directly so that no AOT is needed at all.
13:44technomancy+1
13:44stuarthallowayis there a way to add two type hints to the same name
13:44technomancysorry, inc
13:44stuarthallowayand yes I have a real use case
13:44chouserstuarthalloway: what would that mean?
13:45stuarthallowaythat the reference object implements two interfaces, of course
13:46stuarthallowayor is there a way to add the type hint to the call instead of the name.
13:46chouseryeah, add it to the call if you can
13:46stuarthallowaywhat does that look like?
13:46chouserthe way compilation is done, clojure needs to know exactly one interface in order to emit the efficient calling code
13:47chouser(.foo #^Fooable x)
13:47slyphontechnomancy: btw. i meant to tell you, i read the INTRO.md, good work :)
13:48abrenkstuarthalloway: ah, okay, I see the "catch" in run-tests. perhaps you could get away with a magic "circumspec: " string in Throwable's message?
13:49technomancyslyphon: great; thanks for the bulk of the text. I think it could use some more polishing wrt flow, but it's great to have either way.
13:49stuarthallowaychouser: right, hmm, I am doing something stupid
13:49crowb4rdnolen: Actually I use textmate on OS X, but the clojure bundle I found looked old and outdated.
13:49slyphontechnomancy: yeah, i realised after writing it that you cover some of the maven-ness in another page
13:50stuarthallowaychouser: it doesn't appear I can add to the call unless I am calling through a symbol
13:50dnolencrowb4r: yeah tho it looks like people have done a lot of fork on some forks, would be cool if something new emerged. Would probably greatly increase adoption on OS X at least.
13:51stuarthallowaye.g. (.stuff #^SomeType (some expr)) doesn't seem to hint
13:51chouserhuh ... couldn't callsite caching as is done for keywords work for reflective method calls too? instantly banishing all type hints?
13:51chouserstuarthalloway: really? that surprises me...
13:51stuarthallowayme too
13:52crowb4rstuarthalloway: I have your book, seems pretty good. I'm about 100 pages in.
13:52stuarthallowaycrowb4r: thanks
13:52chouserstuarthalloway: I've got a case that works here. you must have something else going on.
13:52stuarthallowaychouser: yeah :-(
13:53chouser(defn foo [] 5) (.intValue #^Integer (foo)) ; no reflection warning
13:54crowb4rstuarthalloway: No problem, I might use it for the basis in a intro clojure presentation for some university computer club I'm in. I'm going to have to present it from a C# and C/++ perspective.
13:56crowb4rSo, does anyone see a use of a clojure AIM (the instant messenger) lib. Or is the JAVA one good enough?
13:56crowb4rI don't know how much the language is pushing for it's own libs vs the already existing JAVA ones.
13:57chousercrowb4r: very close to "not at all" :-)
13:57noidicrowb4r, you might as well have written C/++/# ;)
13:57noidisorry, C/C++ is a pet peeve of mine :)
13:57stuarthallowaychouser: figured it out
13:57stuarthallowaywhen extending a protocol, you get the type tag for free (expected)
13:57chouserah, right.
13:57crowb4rnoidi: I thought of that after I wrote it.
13:57stuarthallowaybut you cannot override it (odd!)
13:58chousereh? You weren't trying to use a protocol name as a hint, were you?
13:58crowb4rchouser: cool, then I might write a AIM lib in clojure.
13:59Raynescrowb4r: It's idiomatic to make direct use of Java APIs, but alternative Clojure ones are awesome. Convenience wrappers around hard-to-grok Java libraries are nice as well.
13:59RaynesSuch as clj-apache-http.
14:00crowb4rI see that a lot of clojure projects and libs on git-hub. Is that the pretty much official place to put projects, libs etc?
14:00stuarthallowaychouser: no. what I got into was a corner case that will almost never hit anyone
14:00crowb4rRaynes: I have not looked at the clj-apache-http lib, what makes it nice?
14:00RaynesIf you use Git (and you should ;) ), Github is the canonical hub.
14:00stuarthallowayRandomAccess is a signal interface
14:00stuarthallowaybut the actual interface you want for hinting is List
14:00Raynescrowb4r: Because it's easy to use and looks pretty without dots. ;)
14:01RaynesJava I/O APIs are a bitch.
14:01stuarthallowayso extend-protocol's free behavior is not what you want in this (hopefully very rare) case
14:01crowb4rRaynes: I started using git actually when I wanted to start using clojure. svn and bzr were what I worked with.
14:02RaynesSo, github is the place where most Clojure people put their projects.
14:03noidithere are also some projects on google code and bitbucket
14:04stuarthallowayin the clojure community we prefer git for its affinity for the reference model: unrelated commits are commutative :-)
14:04Rayneskotarak doesn't count.
14:04noidistuarthalloway, isn't that true for hg as well?
14:05stuarthallowaynoidi: yeah :-)
14:05RaynesBitbucket is for bitrot.
14:05Raynes;)
14:05technomancyare there still active projects on google code?
14:05duncanmi like using hg
14:05RaynesBut still, Github is the most used.
14:05technomancyjclouds still hosts their wiki there, but the code is moved to github
14:05Raynestechnomancy: Doesn't CCW use it?
14:05mabesyou can use hghub.com :)
14:06Raynesduncanm: Begon! EEEEEVEEEL OOONNNEEE!!!
14:07duncanmRaynes: why so religious?
14:07Raynesduncanm: I'm not. I'm just bored. :|
14:07duncanmRaynes: i have to work on Windows, i find hg to work much better on Windows than git does
14:07duncanmi have git installed too, but i always have line-ending issues
14:08duncanmif git worked on windows, i could use git instead, i suppose
14:08slyphonargh, "windows"
14:08duncanmthe people in my lab run windows, so that's what i use
14:09slyphontechnomancy: ok, packaging n00b question, i have a .jks file i need to package up in my jar, how do i go about doing that?
14:09duncanmjava (swing) runs well on windows, i find swing on OS X to be a lot less robust
14:09technomancyslyphon: what's a .jks file?
14:09slyphonjava key store
14:09technomancyprobably put it in resources/
14:09slyphonwe have a self-signed cert for a SOAP endpoint i need to connect to
14:10slyphontechnomancy: will that get bundled with the jar?
14:10technomancyja
14:10slyphonwewt!
14:11crowb4rtechnomancy: You still doing telecommuting for work? Just wondered from the rudel post you did.
14:12duncanmi've been trying to learn more about Classloaders; I thought it's suppose to let me incrementally redefine things, but I've never seen that happen from Java
14:12duncanmwith Clojure and SLIME, i get incremental redefinition working beautifully
14:14technomancycrowb4r: yeah, but we generally use screen now in order to make sharing repls easier
14:14stuarthallowayduncanm: classloaders allow redefinition, but not very incremental
14:17duncanmstuarthalloway: ah right, you wrote that book on Java, i have it ;-)
14:18duncanmstuarthalloway: do you know if that module work in jdk7 will make classloaders obsolete?
14:18chouserstuarthalloway: so, you want to extend a protocol to RandomAccess, but then implement methods of List
14:19stuarthallowayduncanm: I doubt obsolete, but honestly I don't follow it
14:20dnolentechnomancy: any good resources on setting up collaborative coding in Emacs with screen?
14:21technomancydnolen: just search for multiuser gnu screen... it's pretty simple; just a few screen configs you need to tweak
14:21stuarthallowaychouser: no longer wanting, now doing: http://gist.github.com/336674
14:21dakronednolen: basically all you need is :multiuser on, :acladd <username>, screen -x <screenid>
14:23duncanmstuarthalloway: neat
14:24crowb4rtechnomancy: Screen would seem like a good way to go for sharing. a little screen -x and working together then just opening a new window in the session then being able to work on your own, but still in the same session.
14:25crowb4rI do like having a gui emacs though. the mouse is nice sometimes.
14:26remleduffstuarthalloway: What is the "nil" block where you define your actual functions in Indexed?
14:27remleduffOh, just making (chop nil) return nil?
14:27stuarthallowayremleduff: yes
14:28remleduffOr is that (chop nil 5) return 5?
14:30dnolentechnomancy: dakrone: thx, I guess the issue with screen is that only one person can control the cursor at a time?
14:30dakroneno, you can both type, you'll be competing with each other
14:30lancepantzis it possible to set an enviornment var for a task in lein?
14:30technomancydnolen: yeah, that's usually what you want when you're pairing over voip
14:30technomancybut rudel does not have that restriction
14:31technomancylancepantz: the JVM doesn't support setting environment variables =(
14:31lancepantzouch
14:32lancepantzi have a config who's location i've been reading in from the environment
14:32lancepantzi also run the app from a war, so that files location changes if i'm in jetty
14:32lancepantzhow does one go about that?
14:32remleduffstuarthalloway: chop returns the thing with one element removed from the end?
14:33stuarthallowayshould so do
14:33dakronetechnomancy: what about adding pre and post commands for leiningen tasks? then you could run a shell script
14:34technomancydakrone: that's on the pipeline. setting the environment variables in a shell won't have any effect on the JVM process though.
14:35dakroneoh yea, that's true
14:35chouserstuarthalloway: ah, I see. And it was hinting the arg in the method's arg vector that didn't work?
14:36stuarthallowaychouser: right
14:36crowb4rI think it's time to write a better clojure textmate bundle.
14:37_invisHi guys. I use this guide http://technomancy.us/126 but after all I want to use some functions like that (setq swank-clojure-jar-path (concat clojure-home "clojure.jar"))
14:37_invis(setq swank-clojure-extra-classpaths (list
14:37_invis (concat clojure-home "./")
14:37_invis (concat clojure-home "swank-clojure/")
14:37_invis (concat clojure-home "clojure-contrib.jar")))
14:37_invis(require 'swank-clojure)
14:37_invis But ELPA dont use slime.el How I can fix that ?
14:38lancepantztechnomancy: couldn't you just use export?
14:39technomancylancepantz: that will only affect processes spawned by that shell session. maybe that's what you want? I dunno. but to affect clojure code you'd have to export before launching the JVM.
14:40lancepantzyeah that would be fine in my case
14:40lancepantzi think hooks are a good idea
14:41lancepantzsecond thing i've been trying to do, is there a correct way to do something like an ant exec tag in lein
14:42technomancylancepantz: yeah, that is probably best done with lancet
14:42technomancyif you want a literal ant task to be run
14:42lancepantzknow of any example projects that do that?
14:43technomancyjust leiningen really
14:47lancepantztechnomancy: so i basically just make a build.clj using lancet syntax, right?
14:49technomancysort of... I don't know; I've never really used written ant builds; I've only ever called it through the Java API
14:49technomancymaybe they amount to the same thing
14:59remleduffDo arrays in general not play nice with collections?
14:59remleduffI've been trying to concat an array to a seq for a while, and it wasn't working the way I expected :)
15:00chouser,(concat '(1 2 3) (into-array [4 5 6]))
15:00clojurebot(1 2 3 4 5 6)
15:01remleduffHmmph
15:02remleduffOK, thanks, I'll have to blame my own code again somewhere
15:02chouserfeel free to paste somewhere a specific example that isn't behaving the way you expect.
15:03remleduffI think it's my expectation of the shape stuff is in not matching the reality
15:03remleduffI mean, "shape"
15:04abrenkShould I use "with-bindings" oder "binding" if I want to set prxml-indent? I can't really see the difference.
15:05chouserif you know the var you want to set when you're writing your code, use "binding"
15:07etateis there something like parenscript in clojure?
15:08abrenkchouser: thanks
15:10remleduffIs my problem that I can't concat two lazy seqs together, maybe?
15:11remleduffDon't think that's it either really
15:12remleduff,(concat (map inc [1 2 3]) (map inc [6 7 8]))
15:12clojurebot(2 3 4 7 8 9)
15:14duncanmhmm, if i have (([a b]) ([c d])), what do i do to get to ([a b] [c d]) ?
15:14duncanmi tried FLATTEN in clojure.contrib.seq, but it's too aggressive and got me to [a b c d]
15:14duncanmhmm
15:14duncanmmaybe just first
15:15dnolen,(reduce concat '(([a b]) ([c d])))
15:15clojurebot([a b] [c d])
15:15LauJensen,(map first '(([a b]) ([c d])))
15:15clojurebot([a b] [c d])
15:15dnolenduncanm: ^
15:15LauJensendnolen: ^
15:15LauJensen:)
15:22Fossihi
15:22Fossiah, now the ident works again
15:28arohneretate: http://github.com/arohner/scriptjure
15:39dcnstrctI'm just now experimenting with clojure's concurrency support and I'm trying to figure out what approach I should be taking. My program needs to do long running calculations on each item in a vector. Each thread just needs to process it's chunk and write it to a file so there is no shared state at all. What clojure concurrency primitives should I be looking at ?
15:40dakronedcnstrct: you could check out pmap
15:40dakronefor parallel map
15:40hiredmandcnstrct: pmap + doall
15:41dcnstrctah ha
15:41dcnstrctI knew there had to be something else I was missing because vars, refs, and agents are all about shared state and I don't have any
15:41dcnstrctI'll investigate pmap thnx guys
16:11KirinDaveAre there any good examples of architecture of systems using clojure?
16:11KirinDaveLike, specifically when it's right to use deftype and when it's better to just use data structures.
16:14slyphongah
16:14slyphonhas anyone else been bitten by the log4j maven stupidity?
16:14slyphonwhere it tries to grab javax.jms/jms which points to a url that returns a 301?
16:17remleduffHow do I get the equivalent of String[].class ?
16:17Chousukehmm
16:17Chousuke,(class (make-array String))
16:17clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$make-array
16:17Chousuke,(class (make-array String 1))
16:17clojurebot[Ljava.lang.String;
16:18bozhidarbingo
16:18bozhidar:-)
16:18remleduffThanks :)
16:18Chousuke,Class/forName("[Ljava.lang.String;") ought to work too then
16:18clojurebotjava.lang.Exception: Unable to find static field: forName in class java.lang.Class
16:18Chousuke....
16:18Chousukeexcept with different syntax
16:19remleduff,(RT/forName "[Ljava.lang.String;")
16:19clojurebotjava.lang.Exception: No such namespace: RT
16:19Chousuke,(Class/forName "[Ljava.lang.String;") this
16:19clojurebot[Ljava.lang.String;
16:22slyphontechnomancy|away: leiningen appears to be ignoring my :exclusions on a dependency
16:25StartsWithKhow can i alter var's root binding from java?
16:26Chousuke.alterRoot or something
16:26Chousukeon var objects
16:26StartsWithKit takse a IFn
16:26StartsWithKtakes*
16:26Chousukeyes. so make one :)
16:26StartsWithKpff :)
16:27hiredmanor use constantly from clojure.core
16:27StartsWithKok, and how can i alter a var's root binding from java using reflection api :))
16:27hiredmanmaking an IFn in java is easy
16:27hiredmanLispReader.java has examples
16:28chouserStartsWithK: theVar.doReset(value)
16:28defnIs the WTFPL too cheeky of a license?
16:29slyphonthis log4j maven insanity is making me a little cranky
16:31bozhidarslyphon: what log4j version are you trying to use? I have no problems with 1.2.12, but I remember that newer versions had some crazy deps
16:31bozhidarat least on central
16:31slyphoni was trying to use 1.2.15
16:32slyphoni guess i'll just use 1.2.12
16:32slyphoni don't need any 1.2.15 functionality or anything
16:32slyphonbozhidar: ah, works like a charm, thanks
16:32bozhidaryou're welcome
16:33StartsWithKchouser, doReset, swapRoot and bindRoot only work if i have (def foo) but if foo is already bound, it just keeps its old value
16:33bozhidarin case of such problems it's generally a good solution to check the deps on http://mvnrepository.com/
16:33StartsWithKmaybe i should unbind first
16:34hiredmanStartsWithK: the binding shadows the root binding
16:34bozhidarthat's how I found out that the log4j deps had changed between versions
16:35StartsWithKhiredman, but i need to do this from java, and i realy need to reset the value to new one
16:35StartsWithKand i need to use reflection..
16:36chouserStartsWithK: doReset seems to work for me on a var that already has a value
16:37StartsWithKchouser, tried it from a repl?
16:37StartsWithKit works from me too that way
16:37chouserStartsWithK: yes
16:37raekhrm, clojure fns implement Runnable, but Runnables cannot be used as functions?
16:38StartsWithKbut in java, using reflection, and when invoked from different classloader it dosn't
16:39hiredmanraek: you have to implement IFn to be called as a function
16:39chouserStartsWithK: why are you using reflection?
16:40hiredmanpossibly when invokedynamic becomes widespread, or if IFn becomes a protocol you might be able to extend that to Runnable
16:41hiredmanraek: have you looked at the asm clojure generates for a function call?
16:41raeknot yet... :)
16:41StartsWithKchouser, i'm calling a clojure from a class that is used as interface in two classloader namespaces and one of them dosn't have a clojure loaded
16:42raekI'm just playing around with JVM assembly
16:42hiredmanraek: it's just a call to one of the invoke methods on IFn
16:42raekah, I suspected so
16:42LauJensenTom Crayford in here ?
16:42remleduffAre the clojure-1.2.0-main-SNAPSHOT.jar's on build.clojure.org broken? I can't get them to open in Winzip
16:42StartsWithKmaybe i should split that to a interface+class, so i don't have to use a reflection..
16:42hiredmanif you wanted to allow runnables you would have to insert a branch and each call site, or do some reflection
16:43hiredmans/and/at
16:43raekI see...
16:44remleduffHeh, google translate thinks that http://build.clojure.org/snapshots/org/clojure/clojure/1.2.0-master-SNAPSHOT/ is in Irish, and helpfully offers to translate it to english for me
16:44hiredmanfor a language that depends on function application, you want application to be as fast as possible
16:46hiredmanwhich, when all is said and done, means having as little code to execute as possible
16:47abrenktechnomancy: I just finished a leiningen plugin to create .project and .classpath for Eclipse / Counterclockwise
16:48technomancyabrenk: cool. does it not work to generate a project from the pom though?
16:48abrenktechnomancy: What's the best way to get this integrated? fork on github? patch by email?
16:48technomancyabrenk: plugins don't need to get integrated
16:48technomancyjust push it to clojars and everyone will be able to use it
16:48hiredmananyway, that is why runnables cannot be called as functions :)
16:49abrenkright, and then just add it as a dev-dependency...
16:50StartsWithKis it posible that my var's are already resolved at call sites, so i can't see the change?
16:51chouserStartsWithK: does the var have the word "clojure" in its namespace anywhere?
16:51StartsWithKchouser, no
16:52dnolentechnomancy: have you looked at the unicode issues around jline? It looks like this has plagued jRuby as well.
16:52chouserStartsWithK: then no, I don't think that's possible
16:52StartsWithKchouser, ist something like (def *properties* (into {} (Stytem/getProperties)) and only function that will use it is (defn get-property [key] (get *properties* key))
16:53StartsWithKwhat i have is a config file that defines several components to be loaded, each in its own classloader with fresh clojure
16:54StartsWithKand one of the thing config has is 'system properties' for one such component
16:54StartsWithKbut if the clojure code is not loaded this way, i want it to default to system properties
16:54StartsWithKso it can work with or without this component system
16:58chousersorry, I don't yet understand how multiple classloaders interact with clojure globals like namespaces and vars.
17:00StartsWithKok.. this one is weird, my *properties* is global to jvm instance
17:00raekhrm, which JVM instruction does downcasting?
17:00raekIFns always return Objects...
17:00chouserdon't you just invoke the thing?
17:01chouserI thought you had to specify the specific method to call (including the class or interface) rather than "casting" as such.
17:01chouserI could be way off though.
17:01hiredmanraek: the ASM library has a user guide on their website that has a nice list of instructions
17:02remleduffI can't seem to download any jar from build.clojure.org except for 1.2.0 and get a valid file
17:03hiredmanraek: if you are trying to unbox a primitive you checkcast to the corresponding reference type and then call the method on that type
17:04raekhrm, figured it out...
17:04raekwas another error
17:04raekI thought I needed a Object -> String cast
17:04raekbut I was going to send it to printLn anyway... :)
17:06StartsWithKin 20080916 Release notes, there is "added *use-context-classloader*, which can be bound to true to cause the thread's context classloader to be the parent of the dynamic classloader used during load"
17:07StartsWithKwill that stop clojure from using system classloader?
17:08raekhiredman: do you have a link to that ASM library's website?
17:09raekwould be interesting reading
17:09hiredman~google java asm
17:09clojurebotFirst, out of 269000 results is:
17:09clojurebotASM - Home Page
17:09clojurebothttp://asm.ow2.org/
17:09hiredmanasm is what clojure uses to generate bytecode
17:11raekah, ok. it's name is simply "ASM"...
17:12slyphongah, clojure.contrib.logging is not finding commons-logging
17:12slyphondammit
17:15hiredmanhas anyone used Couverjure? does it work?
17:21slyphonhiredman: what's that do?
17:22hiredmanobjective-c bridge
17:22slyphonooh
17:22slyphonka-wwaaaaaa-zee
17:23slyphonwhat clojure-contrib am i supposed to be using if i'm using the 1.1.0 release of clojure?
17:23slyphon"1.0-SNAPSHOT"?
17:23slyphonthere's no "1.1.0-SNAPSHOT"
17:28patrkrisslyphon: just walked in - are you using leiningen?
17:29slyphonyeah
17:29slyphonisn't eveybody? ;)
17:30patrkrisyou could add the clojure release repository at http://build.clojure.org/releases and then specify 1.1.0 for both clojure and clojure-contrib
17:30slyphonhm
17:30patrkrisslyphon: see how clojars.org does it here: DmbSnI0V
17:30patrkrisooops
17:30slyphon:)
17:30patrkrisnetbank password!!!!
17:30patrkrisno
17:30patrkris:)
17:31slyphonhahahaha
17:31patrkrishttp://github.com/ato/clojars-web/blob/master/project.clj
17:31slyphonah, right on
17:32hiredmanyou should use a map
17:32hiredman{"repo-name" "url"}
17:35slyphongah
17:35slyphonlein compile doesn't seem to be working for me
17:37slyphonhrm
17:39slyphonshit
17:39slyphonlein compile is now lying and saying "all :namespaces already compiled"
17:40zaphar_pshello all
17:40slyphonzaphar_ps: IN OR OUT! jeez! pick one!
17:40zaphar_psslyphon: having issues with irc today
17:40slyphonheh, apparently! :)
17:40zaphar_psthink I got it fixed now though
17:40zaphar_psso I can ask my leiningen related question now
17:40zaphar_ps:-)
17:41zaphar_psdoes it have issues with non-standard compile and library paths?
17:41zaphar_pscause it seems to be having issues for me right now
17:41zaphar_pslein deps works
17:41zaphar_psbut lein compile, lein repl, and lein swank do not
17:43technomancyslyphon: that's just a case of bad output
17:44technomancyslyphon: you haven't told it which namespaces to compile
17:44slyphonhrm
17:44technomancyand compiling all by default is bad
17:44slyphonah
17:44technomancy"not recommended" rather =)
17:44slyphonhow do i handle a case where one of my .clj files is dependent on another?
17:44slyphoni.e. i have com.foo.MyException which com.foo.main depends on
17:45zaphar_pshrmmm lein clean also doesn't seem to work
17:45slyphonor, should i be using a proxy for that or something
17:45telaIs it possible to force an STM retry? It's not in the API, but I'm curious to see how you can get a hold of RetryEx.
17:46zaphar_pstechnomancy: any insights on my question :-)
17:46hiredmantela: any particular reason you want to force a retry?
17:47zaphar_pshrmmm lein clean also does not work
17:48zaphar_psthis is rather annoying
17:48telaat the moment, I'm just trying to abuse the transaction machinery a bit. I want it to retry not just on transaction violations, but also when the values I'm seeking aren't right.
17:48hiredmantela: that does sound like abuse
17:49hiredmanwhy not loop around your transaction?
17:50telait could be done that way, but I figured as long as I have a mechanism which follows the same structure as a transaction, I might as well use the transaction machinery I'm already invoking.
17:50Chousukedon't refs support validators?
17:51telaHm. That could be a point to sneak a force in.
17:51telaI'm trying to write a bayesian graphical model sampler. It's not that values aren't appropriate, it's that sometimes a Metropolis sampling step rejects and I want that rejection to backpropagate
17:51Chousuke(doc set-validator!)
17:51clojurebot"([iref validator-fn]); Sets the validator-fn for a var/ref/agent/atom. validator-fn must be nil or a side-effect-free fn of one argument, which will be passed the intended new state on any state change. If the new state is unacceptable, the validator-fn should return false or throw an exception. If the current state (root value if var) is not acceptable to the new validator, an exception will be thrown and the validator w
17:52hiredmantela: I do not recommend hijacking the mechanisms of the stm
17:52ChousukeI wonder what happens to a transaction if the validator fails
17:53telahiredman: it's a stable thing in Haskell, that's the only reason I'm suggesting it
17:53hiredmanfor example, transactions will not be retried indefinitely
17:54Chousuke,(let [a (ref 1)] (set-validator! a pos?) (dosync (alter a dec)) @a)
17:54clojurebotjava.lang.IllegalStateException: Invalid reference state
17:54Chousukeaha
17:54telaI know. That's fine. The loop I'd optionally write would want to bail eventually, too.
17:54hiredmanclojure's stm is still sort of a closed box, but at some point you should be able to tie stm transactions into otehr things
17:55ska2342tela: I can't help thinking "Exception" if I read "backpropagate" ..
17:56hiredman:(
17:57telaska2342: yeah, it'd be similar. I'd have to reimplement machinery to reset my refs manually though, I believe. Unless you can pass the ResetEx exception to run it through the STM machinery.
17:59ska2342tela: I may be totally mistaken, but backpropagation has a lot of stack-unwind semantics, I think. So, recursion (the real one) and exceptions come up in my mind. However, I just skimmed the messages here and did no deeper thinking...
18:00ska2342tela: unless I confuse backprop with backtracking right now, that is. ?
18:02telaska2342: by backpropagation in this sense, I'm doing a calculation at a certain node in a tree. To perform it, you recurse to its children and do similar calculations, then use their new values to make that calculation. In some circumstances, it might reject and that rejection needs to happen in the children as well, reseting them all back to their initial values.
18:02ska2342hiredman: did I step into a lesson of yours uninvited? if so: sorry.
18:03DrakesonHow can I define metadata (e.g., for sake of documentation) for each argument in the definition of a function?
18:04hiredmanska2342: oh, no, please, I'm sure you know more about the specifics than I, I just don't like exceptions as flow control
18:04hiredmanDrakeson: you put that stuff in the functions docstring
18:04hiredmanlocals don't get metadata
18:04Drakesonthat's not good enough, I want to process that
18:06Drakesone.g. (:arglists (meta (resolve 'some-function))) gives me the argument list
18:06Drakesonnow I want to get more than just their names.
18:06kotarak,(:arglists (meta (resolve 'defn)))
18:06clojurebot([name doc-string? attr-map? [params*] body] [name doc-string? attr-map? ([params*] body) + attr-map?])
18:07kotarakhmmm
18:07ska2342hiredman: I can't say I know any specifics, so I think I'd better be quiet now. My use of Exceptions as flow control is probably influenced by CLs signals and restarts and not very Java'ish.
18:08zaphar_psexactly what does one have to do to get the j2ee libs on a mac?
18:09zaphar_psjavax.* namespaces seem to be missing
18:09hiredmanjavax.* is not the samething as j2ee
18:09Drakesonzaphar_ps: give us an example
18:09Drakesonthat is, what is missing?
18:10powr-toctechnically speaking, what is an s-expression? Is it just a list datastructure? Or is a literal vector or hashmap classed as an s-expression too?
18:10Drakesonthe whole javax.* ?
18:10zaphar_pshiredman: using compojure basic hello world won't compile says NoClassDefFoundError: javax/servlet/ServletOutputStream
18:10zaphar_psso where do I get j2ee from?
18:10hiredmanzaphar_ps: you don't need j2ee
18:10zaphar_pswhat do I need then?
18:10hiredmanyou just need to have the servlet stuff on your classpath
18:11hiredmanit should come with compojure
18:11zaphar_psthe compojure jar is on the class path I thought
18:11hiredmanzaphar_ps: yes, but there are a bunch of other jars compojure depends on
18:12hiredmanif you built compojure from source they should be in the libs/ directory of the source tree
18:12Drakesonzaphar_ps: you probably need jetty, servlet-api, some commons-* stuff ..., you can get them from clojars
18:12zaphar_psI did not I used lein with the clojars dependency that hiredman uploaded
18:13hiredman:|
18:13hiredmanthat was a mistake
18:13zaphar_psahhh
18:13zaphar_psok
18:13zaphar_psis there a clojars upload that I can use or do I need to build from source
18:14Drakesonthere is one.
18:14hiredmanzaphar_ps: if you search clojars for compojure I would pick anyone that I didn't upload and try again
18:14zaphar_ps:-)
18:14zaphar_psahh ok then
18:14Drakesonzaphar_ps: [compojure "0.3.2"]
18:14hiredmanato is most likely a good bet
18:15Drakesonassuming you are using lein
18:15zaphar_psDrakeson: I am
18:16zaphar_psahhh that looks better :-)
18:16zaphar_psdownloading much more stuff
18:17zaphar_psand we have compiled it :-)
18:25dcnstrctdo you guys bend to Java's will and use camelCase for all the variables in your programs ? Someone who had never seen clojure before looked at my code and asked me why half of my variables were-like-this but most of the method calls wereLikeThis
18:25powr-tocDoes anyone here know what an sexpression is, specfically?
18:25powr-tocin Clojure as opposed to Lisp
18:26dcnstrcthe said "why not just use camel case for all your variables if that's what java is using... after all this language is supposed to mix nicely with java..
18:26powr-tocdcnstrct: No, absolutely not. Use foo-bar style for clojure code, and camelCaseForJavaMethods... It helps visually highlight when you're hitting java, and probably dealing with state
18:27dcnstrctI scoffed at him, but now I'm starting to wonder.
18:28dcnstrctouuhhh good point.. state is supposed to stick out... it's a feature!
18:29dcnstrctclojure doesn't force you to wrap it in an ugly monad to make it stick out instead you just seeTheCamel
18:29powr-tocdcnstrct: Also, it helps for knowing where to look for docs...
18:30powr-tocLike wise for ClassNames etc...
18:30powr-tocleave java syntax for java
18:31powr-tocI mean java-style (not syntax)
18:31dcnstrctyeah I suppose one day we'll have so many nice clojure libs that a clojure programmer won't even need to see that many camels.
18:57hiredmanremleduff: it's based on arity
18:58hiredmanthe compiler looks at the (foo 1 2) and compiles to, in java, foo.invoke(1,2);
18:58remleduffHow can that work in the case of apply though?
18:59hiredmanapply doesn't use invoke
18:59alexyktechnomancy|away: are you away?
18:59hiredman~def apply
19:00alexykmay be others would know: when doing lein deps in a directory with user.clj, where that has (use 'x) and x is to be downloaded by lein deps, lein chokes!
19:00alexykis there a simple way to make lein ignore user.clj?
19:01hiredmanno, because clojure loads user.clj, not lein
19:02alexykhiredman: yeah, but I was still wondering for some hack.
19:03hiredmanthere is no way, unless you want to try and avoid loading user.clj all together
19:03KirinDaveSo, if I use deftype to replace a defstruct, will it still play nice in refs and such?
19:03KirinDaveIs there an increased cost to using those things in refs and whatnot?
19:04alexykman, an |away person leaves! ghosts!
19:07alexykhow do you abbreviate: (use 'long-x) (alias 'x 'long-x)
19:08Chousuke(use '[foo :as bar])
19:08KirinDaveWhat's the point of :as in (use ...)?
19:08alexykkk
19:08Chousukethough you should use require :P
19:08KirinDaveyeah seems pointless.
19:09KirinDave(use '[foo :as bar]) ; In which we lie in a way we are sure to regret later, for no other purpose than to prove we can.
19:09alexykso what's the current clojure version? :)
19:09alexykwhich folks are using?
19:10ChousukeI suppose you should target 1.1 if you don't need features from master
19:10alexykChousuke: and the master is 1.2.0-master-SNAPSHOT?
19:12Chousukeyeah
19:14alexykso the world moves slowly
19:14alexykgood
19:18polypusi've got a defmulti, and i'd like one of my methods to convert any list or sequence into a vector. vectors should go through unchanged, and maps should not be handled. how should i proceed?
19:33hiredmanhttp://gist.github.com/337053
19:33hiredmanit's really the little things that make me love clojure
19:36TalkingHeadHi all, noob question
19:37TalkingHeadI'm running through a sequence like so: (doseq [cell row]
19:37TalkingHeadand then getting the contents of each cell: (let [c (.getContents cell)]
19:37TalkingHeadhow do I put all these values back into a Vector or list?
19:38hamzause map instead? (map #(.getContents %) row)
19:39hamzawill return a sequence
19:43arohnerTalkingHead: or you can use 'for' as well
19:50dcnstrctis there a way to get an append version of clojure.contrib.duck-streams/write-lines ?
19:50dcnstrctif not then what is the most idiomatic way to append a line to a file ?
19:50dcnstrctif I use append-spit how do I add the newline ?
19:51TalkingHeadarohner: How would you use the 'for' macro? I was looking at the documentation, but not comprehending yet.
19:52arohnerTalkingHead: it looks exactly like your doseq call, except the body must have only one expression. It returns a seq of the return value of each call in the body
19:52arohner(for [cell row] (.getContents c))
19:55zaphar_psargh
19:55zaphar_pshttp://pastie.org/876452
19:55zaphar_pswhy oh why would this error keep happening
19:56zaphar_psit obviously compiles the class
19:56zaphar_psbut then says it's not there
19:57hiredmanwhy are you referencing the class?
19:57hiredmancan you pastebin start_this.clj?
19:57zaphar_pshttp://pastie.org/876455
19:57zaphar_psthere ya go
19:58dcnstrctso there is no nice way to append a line to a file is there ? Does this mean if I write an append-write-lines function I can possibly get my code into contrib ?
19:58hiredman- are not valid in java class names to being with
19:59zaphar_pshrmmm
19:59zaphar_psok
19:59hiredmanI don't know what your file names are
19:59TalkingHeadarohner: thx, think I got it
19:59zaphar_psthey use underscores
19:59hiredmanbut clojure translates from - to _ when going from namespaces to files
19:59zaphar_psthat I new
20:00zaphar_psbut can I still use the dashes in the clojure code?
20:00zaphar_psI can rename the stuff just fine
20:01hiredmanzaphar_ps: yes
20:01hiredmanwhat is this "servlet" on line 10?
20:02zaphar_psI thought it was part of compojure?
20:02zaphar_psI'm following some tutorials or trying to anyway
20:02hiredmanhave you looked at any compojure examples?
20:03zaphar_pshrmmm renaming the classes without dashes worked
20:03hiredmanI have not written a lot of compojure but I don't think that is right
20:03zaphar_pshiredman: I'm following a compojure example right now
20:03zaphar_pswith slight modifications
20:04hiredmanok
20:07zaphar_pswell I get the servlet to launch now.
20:07zaphar_psbut I've got a whole host of other stuff to work through now :-)
20:10DrakesonI don't know if this has been reported ... lein deps copies stuff and then sits there apparently forever.
20:11Drakesonreverting the last two commits gets back to a usable state
21:16BiraHello! I'm trying to install swank-clojure on my emacs 23, using ELPA as described in the documentation. But after it downloads the jars, I get an exception saying it couldn't find clojure/main.
21:16Bira(when I try to run M-x slime)
21:16BiraIs there something I'm doing wrong?
21:22danlarkinHi there Bira :)
21:24danlarkinBira: nothing comes to mind, I recommend waiting for technomancy
21:25scgilardiHi Bira, I don't know why it's not working, but that symptom means it can't find the clojure jar in the classpath.
21:25BiraHey there :).
21:27BiraWell, I had installed clojure through ClojureX a while ago, but I'm not sure it's influencing the process here.
21:27Biraswank-clojure downloaded clojure.jar, clojure-contrib, and its own jar into ~/.swank-clojure
21:27scgilardidoes the contents of the *inferior-lisp* buffer show the classpath or any more detail?
21:28BiraOne moment.
21:29Birahttp://pastie.org/876544
21:29BiraThat's the content of *inferior-lisp*, and the names of the jars downloaded by swank-clojure
21:29BiraThey look a little strange, I think/
21:35scgilardiI just did M-X slime for the first time on my laptop, it downloaded those exact files, and then worked. Are you running emacs 23? You might also try moving your .emacs and .emacs.d out of the way (if you have them) and pointing .emacs.d (using a symlink) to a git clone of phil's emacs-starter-kit.
21:39Birascgilardi: My .emacs.d is a clone of phil's emacs-starter-kit :).
21:40clowbaris it possible to get clojure 1.2 to work with slime?
21:40BiraI did make a few customizations, though, so I'll try to move those aside.
21:40zaphar_psclowbar: is there some reason you think it wouldn't?
21:40scgilardiBira: ok. are you on linux? ubuntu?
21:42bmasonisn't there a macro that takes a sequence and unwraps it into an existing sequence?
21:42bmasone.g. [:div (unwrap [[:foo] [:bar]])] -> [:div :foo :bar]
21:42Biragentoo. Emacs 23.
21:43clowbarzaphar_ps: I'm new to slime
21:44slyphonwhat? for has a :let modifier
21:45BiraHm... same thing on a clean emacs-starter-kit. I guess I'm going to have to dig a little further.
21:56brandonwi can't seem to find the docs for it (if it exists), but is there a way to use a namespace foo.bar.baz so that you can do 'baz/a' and 'baz/b' but not 'a' or 'b'?
22:01bmasonbrandonw: like :rename? http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/refer
22:03bmasonbrandonw: this page is great for general namespace/use documentation: http://clojure.org/namespaces
22:03scgilardi(require '[foo.bar.baz :as baz]) or, from within an ns form, (:require [foo.bar.baz :as baz])
22:03brandonwokay, thanks
22:04brandonwthat works perfectly
22:04scgilardiyou're welcome
22:17brandonwokay that was good
22:17brandonwthat finally forced me to read the documentation for refer/require/use carefully, instead of just using use :)
22:47dakroneanyone done any work on redefing REPL stuff to print in color before?
22:56remleduffWhat causes clojure.main to get loaded? I see clojure.core getting loaded in RT#doInit, but haven't found clojure.main anywhere
22:56arohnerremleduff: my guess would be the command line
22:57sattvikdakrone: I don't know of any such thing, but that would be really neat.
22:57arohnerjava -cp clojure.jar clojure.main
22:57arohnerdakrone: I imagine it's fairly straight-forward. Just make the repl output the right characters
22:57dakronesattvik: would be really awesome if you could colorize output based on return class and such
22:57dakronelike people do with IRB
22:58hiredmanremleduff: I would make sure you are looking at a recent checkout of the source
22:58hiredmanI seem to recall doIt just having a comment saying "you don't need to call this" in it
22:59remleduffThat's true hiredman, but I'm trying to reflectively call RT in a separate classLoader
22:59hiredmanyou don't call RT
22:59hiredmanyou just load the class
22:59slyphonin soviet russia, RT calls *YOU*
22:59hiredmanit has a static initializer block
22:59slyphonsorry
23:00remleduffI need to call RT.var("clojure.main", "repl")
23:00remleduffAnd then invoke that
23:00hiredmanjust do it
23:00remleduffIt'll get loaded in the wrong classloader
23:01hiredman((IFn)RT.var(...)).invoke(...)
23:01remleduffI have say, a clojure 1.1 classloader that is started by lein, and I've created a new one with trunk clojure in the classpath
23:01remleduffSo I have to (Class.forName "clojure.lang.RT" true newClassLoader) to get the right RT
23:02hiredmanare you sure you are loading a new RT?
23:02remleduffYeah, I have it working if I call the method clojure.main.main
23:03remleduffBut I want to call a clojure function instead
23:08slyphonhrmf
23:09slyphonif i have [{:a 1 :b 2} {:a 2 :b 3}] and i want to transform that to be {1 {:a 1 :b 2} 2 {:a 2 :b 3}}, er, how do i do that in a non-stupid way?
23:11hiredman,(apply hash-map (interleave (iterate inc 1) [{:a 1 :b 2} {:a 2 :b 3}]))
23:11clojurebot{1 {:a 1, :b 2}, 2 {:a 2, :b 3}}
23:12slyphonwell
23:12remleduffWoohoo!
23:12slyphonit's more that i want to create an index of the values of :a
23:18hiredman,(reduce (fn [b {:keys [a] :as m}] (assoc b a m)) {} [{:a 1 :b 2} {:a 2 :b 3}])
23:18clojurebot{2 {:a 2, :b 3}, 1 {:a 1, :b 2}}
23:19hiredman,(reduce #(assoc % (:a %2) %2) {} [{:a 1 :b 2} {:a 2 :b 3}])
23:19clojurebot{2 {:a 2, :b 3}, 1 {:a 1, :b 2}}
23:20slyphonbrilliant
23:21slyphonhiredman: winnar!
23:21slyphonthanks