#clojure logs

2010-01-12

00:01G0SUBctdean: which version of log4j should I use? 1.3 is obsolete, 2.0 is experimental
00:02ctdeanG0SUB: I'm using log4j-1.2.14.jar, no idea if that's a good one
00:02mebaran151defn, I've built, but it wants a program called makeinfo
00:02mebaran151why can't stallman use manpages like the rest of us
00:05Licenser_hmmm functional chimney: (reduce #(burn %) '(wood wood wood wood))
00:06somniumLicenser_: isn't the smoke and heat side-effecty?
00:06Licenser_na we just reduce the wood to ashes
00:07Raynesdefn: You know you can get Emacs 23 from the Ubuntu repos as far back as Hardy, right?
00:07Raynesemacs-gtk-snapshot
00:07Licenser_but somnium you're right
00:08G0SUBctdean: the log file path, does it need to be absolute?
00:08Licenser_so lets say: (defn burn [stuff] '(heat ashes smoke))
00:08ctdeanG0SUB: I don't think so
00:08somniumLicenser_: hmm, you may be on to something
00:09Licenser_yap
00:10arohnerhmm, I want a get-in that also does derefs as appropriate...
00:10arohner(get-in* foo [:a :b @ :c])
00:10arohnerof course, writing that, I want an update-in that does the same thing
00:11arohnernm, that doesn't make as much sense
00:11hiredmanget-in is called ->
00:11arohnerhiredman: good point
00:11hiredman,(-> foo :a :b deref :c)
00:11clojurebotjava.lang.Exception: Unable to resolve symbol: foo in this context
00:12somniumare any of the -$> variants in contrib?
00:12hiredmanmaking update-in work on mutable structures and immutable structures would be tricky
00:12hiredman,(doc -?>)
00:12clojurebot"clojure.contrib.core/-?>;[[x form] [x form & forms]]; Same as clojure.core/-> but returns nil as soon as the threaded value is nil itself (thus short-circuiting any pending computation). Examples : (-?> \"foo\" .toUpperCase (.substring 1)) returns \"OO\" (-?> nil .toUpperCase (.substring 1)) returns nil "
00:13somniumah!
00:13somniumhmm
00:13arohneryeah, I realized I don't need [:a :b deref :c] on update-in
00:14arohnerI wish those things had canonical names
00:14arohneri.e. thread-maybe
00:14arohnerI don't want perlisms in my clojure
00:14somniumI meant the ones that move the argument
00:14arohnerthere's ->>
00:14hiredmanoh, the icky templating stuff?
00:14hiredman*shrug*
00:14somniumIve been using an anti-> for doing (-> x (range) (>> map inc))
00:15Licenser_somnium: http://gist.github.com/274938
00:15somnium=> (->> (-> x range) (map inc))
00:15somniumbut its kind of silly
00:15mebaran151alright, I think I got emacs installed
00:15hiredmanadd a doto in there
00:15mebaran151and I can get slime
00:15mebaran151now how do I get all the goodies
00:16hiredman,(doto :a (-> prn))
00:16clojurebot:a
00:16clojurebot:a
00:17hiredman(doto X (-> ((partial juxt #(.write % stuff) #(.close %)))))
00:18hiredmanof course you could just (doto X (.write stuff) .close)
00:20mebaran151like the infamous paredit etc
00:20somniumhiredman: doto in place of >> / -$> ?
00:20hiredmanaslong as you are using -> and ->> you might as well also use doto
00:20somniumLicenser: =)
00:21somniumhiredman: (-> 10 range (>> map inc) (nth 5)) with doto?
00:27mebaran151rainbow parens etc
00:27somniummebaran151: emacs-starter-kit has some good stuff, incluing elpa
00:28mebaran151I've got elpa
00:28hiredmanthere is a rainbox-paren-mode out there
00:28mebaran151I've got highlight parens now
00:29somniummebaran151: otherwise just start collecting .el files in your .emacs :)
00:30mebaran151alright
00:30mebaran151so now I want to setup something like I had in netbeans
00:30mebaran151where I would load the contents of a current file and smack it at the repl
00:30hiredmanhttp://delicious.com/search?p=rainbow&chk=&context=userposts|clojurebot&fr=del_icio_us&lc=0
00:32mebaran151I've got parens
00:36mebaran151where's a good guide to swank. like resetting the repl, etc
00:37mebaran151loading the current file in repl etc
00:40somniummebaran151: you can install everything from elpa
00:45mebaran151will it autoload
00:46mebaran151like let's say I always want highlight-parens-mode when I'm editing a clojure file,how would I do this?
00:50RaynesThere is a rainbow paren mode? Holy shit.
00:50RaynesI want.
00:51somniummebaran151: highlight-parentheses (from elpa) is global, and ez customization can be had via <M-x customize-group> <highlight-parentheses>, which is only a couple with keystrokes with tab
00:53mebaran151so everytime I open a clojure file I have to M-x highlight-parentheses?
00:53somniummebaran151: oops, its not global. std way is (add-hook 'clojure-mode-hook 'highlight-parentheses-mode) but may be an option in customize too
00:56mebaran151where do I write this?
00:57Raynesmebaran151: .emacs
00:57Raynes~/.emacs
00:57clojurebotemacs is best configured for Clojure with instructions at http://technomancy.us/126
00:58RaynesThe hell with Phil and his canonical instructions.
00:58Raynes!
00:58Raynes:>
00:59mebaran151alright let's try this
00:59mebaran151how do I switch to the slime buffer
01:00G0SUBpeople, I have this log4j.properties file in my src/ -- http://gist.github.com/274951 even then, when I log an error with c.c.logging it doesn't go into the file.
01:00somniumM-x slime
01:00Raynesmebaran151: Also, you don't have to close and then reopen emacs everytime you want to load new code in your .emacs file. Just place the cursor in space directly after the last parentheses in the sexp you want to evaluate in and do C-x C-e
01:02Raynesmebaran151: Also, checkout http://www.emacswiki.org/emacs/InteractivelyDoThings
01:02Raynescheck out*
01:02RaynesQuite useful.
01:04G0SUBOK, I figured what the problem was. c.c.logging uses java logging even when I have log4j in the classpath
01:04hiredmansure
01:04mebaran151so I want to duplicate this work process
01:04G0SUBif I call (log4j-logging) it works fine.
01:04hiredmanlogging decides which logging system to use at compile time
01:04mebaran151in Netbeans, I'd type ctrl-shift-n to switch to the name space I'm working in
01:05mebaran151then I'd type alt-l to load the file
01:05mebaran151then I'd whack at it in the repl
01:06RaynesSwitch to the namespace you're working on the old fashioned way (ns ..) and then load the file via C-c-C-l or recompile the file via C-c-C-k
01:07somniumcompile wont work without the classpath setup
01:07Raynes^
01:08somniumhttp://github.com/technomancy/swank-clojure
01:10mebaran151I've got swank clojure up and running
01:10mebaran151can I get autocomplete
01:10mebaran151so ns woudl complete my namespace
01:11optimizeris there something like sqlite, but for clojure?
01:11mebaran151optimizer, derby?
01:11mebaran151hypersonic sql
01:12optimizermebaran151: nice; thanks
01:33mebaran151so how would I get this setup
01:33mebaran151I want three or four buffers
01:33mebaran151one to list directories and files to switch between
01:33mebaran151one as the main editor
01:34mebaran151one as my project repl
01:34mebaran151and maybe one where I could get java and clojure docs
01:35Raynesmebaran151: Also, C-x 3-C-x o-C-x 2 :D
01:36RaynesI have 3 'panes' in my set up. 2 square boxes on the right side, and a big one on the left for editing.
01:37RaynesI'll also note that there is an Emacs file manager. M-x dired
02:09timothypratley,(.comparator (sorted-map 1 2 3 4))
02:09clojurebot#< clojure.lang.RT$2@f4a444>
02:10timothypratleyAny ideas what that is?
02:12timothypratleyI expect it is RT.DEFAULT_COMPARATOR, but I cannot fathom why it is not an IFn
02:16timothypratleyah I see why - never mind I figured it out
02:16timothypratleya comparator need not be an IFn from java land.
02:21RaynesReading about protocols. Awesome
02:23timothypratleyRaynes: I thought you were a vim user - have you converted to emacs now?
02:23timothypratley(or back)
02:24Raynestimothypratley: I played with Vim long enough to find out that I can't work with VimClojure very well.
02:24timothypratleyRaynes: ah - why is that? The REPL interaction, or editing preference, or project integration?
02:25Raynestimothypratley: Mostly the fact that I could never get it to work correctly.
02:25RaynesNot that that is a VimClojure problem.
02:28timothypratleyRaynes: hehehe yeah I hear you! It takes me an hour to install VimClojure whenever I need it somewhere... the installation instructions require careful attention I find lots of ways to make it not work.
02:41G0SUBtimothypratley: hey, need some help with c.c.logging
02:42G0SUBtimothypratley: c.c.logging is picking up util logging even when I have log4j in classpath
02:42G0SUBtimothypratley: it works when I call (log4j-logging) manually.
03:00mebaran151thnaks Ranes
03:00mebaran151*Raynes
03:00mebaran151I gotta get used to buffers
03:01Raynesmebaran151: You're welcome.
03:01RaynesAnd either I've lost sense of time, or that was extremely delayed. :p
03:03mebaran151heh, my Internet went way wonky
03:03mebaran151anyway
03:03mebaran151how do I open three buffers?
03:03defnC-x 3
03:03defnC-x 2
03:04defnif you want a new frame, C-x 5 2
03:04RaynesI told you that a minute ago. >.>
03:05RaynesWell, more than a minute ago.
03:05mebaran151ah
03:05mebaran151that's what that did
03:05mebaran151it looked arcane
03:06mebaran151sorry, my internet went way wonky, packets flying and red lights flashing
03:06mebaran151I'm getting swank swnak not found
03:06mebaran151but it seems to work
03:07mebaran151how do I get dired to open the file in a different buffer
03:07mebaran151so I'd always have dired in a pane
03:09RaynesThat's beyond me. I don't use dired.
03:09mebaran151I need an emacs manual
03:09mebaran151sigh
03:10Raynesmebaran151: http://www.gnu.org/software/emacs/manual/emacs.html
03:10mebaran151a manual not written by Richard Stallman
03:10RaynesHehe.
03:10mebaran151who assumes that we all live in the 70's :)
03:11Raynesmebaran151: http://articles.techrepublic.com.com/5100-10878_11-1053058.html
03:11somniummebaran151: C-x 4 d
03:12somniumIm starting to dig this point free stuff: http://gist.github.com/274994
03:14RaynesI thought >> was in core.
03:15hiredman->>
03:15hiredmancompletely different
03:20mebaran151I'm beginning to remember why I wasn't a fan of emacs
03:23timothypratleymebaran151: why?
03:24mebaran151I'd have my Netbeans setup in less than two minutes
03:24mebaran151I'm trying to get a simple setup
03:24mebaran151dired pointing at my project
03:24mebaran151a main buffer editing a source file
03:24mebaran151and a repl with my classpath
03:24mebaran151I can't seem to get all these together
03:24timothypratleyGOSUB: I'll take a closer look
03:27Raynesmebaran151: Emacs isn't a plug-n-play kind of thing.
03:27mebaran151nope I know
03:27mebaran151but I'm not sure what I'm going to get
03:27mebaran151:)
03:27mebaran151though I do like its parentheses highlighting a little better than Netbeans
03:28somniummebaran151: do you have paredit on?
03:28mebaran151I think I do
03:28mebaran151I took the sign of my accidentally deleting my home dir as a sign I should learn emacs as penance
03:29timothypratley:)
03:30somniumIm not sure if paredit can keep your home-dir safe, but it may coax you out of netbeans :)
03:33mebaran151oh dired might
03:33mebaran151I was rm -r and there was a directly named tilde
03:33mebaran151this led to certain death
03:34mebaran151how do I get the repl now
03:34mebaran151I've got a process
03:35mebaran151how do I know if I have paredit on
03:35timothypratleyG0SUB: timothypratley: c.c.logging is picking up util logging even when I have log4j in classpath <-- do you happen to have a git project I can try (no problem if not, I can try to recreate)
03:36G0SUBtimothypratley: it's a proprietary codebase, but I can create a minimal setup just for you :)
03:36G0SUBtimothypratley: just a sec
03:37timothypratleyGOSUB: thanks!
03:39vymebaran151: In "C-h m" there should appear paredit.
03:40mebaran151I don't think so
03:40mebaran151how do I enable it
03:41esjm-x paredit-mode
03:42mebaran151okay
03:42mebaran151so what can I do now?
03:43mebaran151I'm sorry for being such a total newb
03:43mebaran151all the blogposts tell you how to setup emacs, but nobody ever tells you how to use it...
03:43RaynesCheckout the paredit cheatsheet.
03:43RaynesI have it set as my desktop background.
03:44mebaran151it won't let me type a parens...
03:44mebaran151this I feel is intentional
03:45G0SUBtimothypratley: http://github.com/ghoseb/test-logging
03:45Raynesmebaran151: If you started paredit mode with open parens that need closing, you're kind of screwed.
03:45RaynesI think I got around that somehow before though...
03:45G0SUBtimothypratley: even now it picks up util logging
03:45esjRaynes: your background ! That's fantastic.
03:45timothypratleyGOSUB: thanks for that - I'll see what I can do with it.
03:45Raynesesj: It's the place where it's most accessible. :p
03:46G0SUBtimothypratley: cool
03:48mebaran151slime also is constantly telling me its polling
03:48mebaran151can I disable this?
03:48RaynesEh, that means Slime never opened, and it means something's wrong.
03:48RaynesIs there a *slime-repl clojure* buffer, or just an *inferior-lisp* buffer?
03:49RaynesIf there is just an *inferior-lisp* buffer, you might want to paste what it says.
03:53esjmebaran151: you're probably in for a frustrating morning.
03:53Licenserhrm I have trouble to understand require and use I think ...
03:53mebaran151it's an inferior lisp buffer
03:54mebaran151it seems run clojure
03:54mebaran151and it picks up my class path
03:54esjyou also need a *slime-repl clojure* buffer
03:54esjwhich is where you clojure it up
03:54Licenserwhen I've two namespaces that both require a 3rd one, it should be loaded in both right? And they should not confligt?
03:54mebaran151Polling "/tmp/slime.6498".. (Abort with `M-x slime-abort-connection'.) [1147 times]Cancelled connection attempt.
03:55esjmebaran: Raynes is correct
03:55Licensermebaran151: your problem is likely that slime does not find the clojar jars
03:55mebaran151alright
03:55Licenserwait a second I dig something up
03:55mebaran151let's have slime find them!
03:56esjmebaran151: I'm not the guy with the answers to this one. I had endless unhappiness until I did exactly what http://learnclojure.blogspot.com/2009/11/installing-clojure-on-ubuntu-910-karmic.html said to do
03:56Licenseryou've to adjust your .emacs file
03:57Raynesmebaran151: At the beginning of your inferior-lisp buffer, do you see something with RestFn<init> in it?
03:57Licenserhttp://gist.github.com/275037 <- this one did the trick for me
03:57G0SUBtimothypratley: that's a skeleton lein project. just open a repl with that project and use c.c.logging and check the *impl-name*
03:57G0SUBtimothypratley: if you call (log4j-logging) it will work fine. just that (or ...) form is not working correctly (don't know why).
03:57mebaran151I can just start slime
03:57mebaran151there's like a graphic
03:58mebaran151M-x slime works
03:58Licensermebaran151: I had the exact same problem this fixed it for me
03:58Licenserslime was working swank-clojure project not
03:58Raynesmebaran151: Slime is NOT working unless there is a *slime-repl clojure* buffer.
03:58Raynesjava.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V to be exact.
03:58Licenserwhat I did was getting the swank-clojure and slime from the git site and put this in my config file
03:59mebaran151yep
03:59mebaran151I get slime-repl clojure
03:59mebaran151jsut not from my project
03:59RaynesOh.
03:59mebaran151I have the clojure jars in my project: is this going to cause problems
04:01mebaran151does swank works with 1.1
04:01Licenseryes but I had the same problem you have with the one from epal or how that thing is called
04:02somniummebaran151: did you read the readme at technomancy's swank-clojure on github?
04:03mebaran151oh I need the swank jar
04:08mebaran151huzzah
04:08mebaran151I've got slime
04:09mebaran151and I got it to load a file
04:09mebaran151how do I get history in the repl
04:09Licensergrrr
04:09somniumC-<up>
04:11mebaran151now how do I load just one form
04:11mebaran151like evaluate a def
04:12somniummebaran151: slime has a lot of commands, do C-h b, to be overwhelmed
04:12somnium(at the repl buffer)
04:12mebaran151alright
04:12mebaran151a more featureful repl
04:12Licenserso when I have namespace a.b.c1, a.b.c2 and a.b.c3 can I require a.b.c1 in both c2 and c3 without any problem?
04:14somniumLicenser: yes, why?
04:14Licenserbecause I keep getting problems like 'Alias modules already exists in namespace net.licenser.epic.modules.cycle, aliasing net.licenser.epic.modules'
04:16somniumLicenser: Im guessing theres more requiring going on than just a b and c?
04:17Licenseryea :(
04:19timothypratleyGOSUB: Yeah thanks for the example I can clearly see the behaviour, and calling (or ...) works fine ... but I have a theory why it is not working
04:20timothypratleyGOSUB: I believe the issue here is that because or is a macro, and so are the XXX-logging calls, it all gets decided at 'compile' time - which for a pre-packaged jar happens before the jar gets made, at which point log4j is not in the classpath
04:21somniumLicenser: if the repl's been up for awhile it might be lingering vars
04:21LicenserI really get confused
04:21timothypratleyGOSUB: Whereas when using uncompiled contrib, this behaviour would not happen
04:21Raynesmebaran151: C-x C-e with the cursor immediately after the last paren in the sexp you wish to eval.
04:22LicenserI geuss I can't require A from B and B from A?
04:22timothypratleyGOSUB: I could be way off the mark here but I'll experiment a bit more with it.
04:23somniumonly if you can explain how to the compiler
04:23Licenserteehee
04:25RaynesLicenser: That is a circle dependency. Those are bad.
04:25Licenser:(
04:27timothypratleyGOSUB: sorry that made no sense hahaha forget what I said just then.
04:28Licensercan I entirely flush the repl from everything I 'tought' it?
04:29RaynesI believe you would have to restart it for that.
04:30Licenserhmm hmm
04:31esjon that subject is there an undef ?
04:31esji couldn't find it the other day
04:32Raynes(doc ns-unmap)
04:32clojurebot"([ns sym]); Removes the mappings for the symbol from the namespace."
04:32RaynesAha.
04:34kanakI installed swank-clojure from ELPA (version 1.1.0), and I'm getting this error: "Debugger entered: (("Error in timer" slime-attempt-connection (#<process inferior-lisp> nil 2) (file-error "make client process failed" "connection refused" :name "SLIME Lisp" :buffer nil :host "127.0.0.1" :service 49525)))" when i M-x slime. I'm on a debian system. Does anyone know what the problem could be?
04:34Rayneskanak: Did you also install Slime via ELPA?
04:35fliebelGood morning!
04:35RaynesMorning.
04:35kanakRaynes: I only installed swank-clojure from ELPA. I haven't installed slime separately
04:36Licenseryap flushing the repl helped
04:36Rayneskanak: Check to see if slime and slime-repl are installed in ELPA.
04:36RaynesIf not, install them and try again.
04:36esjRaynes: hooray. That's a weird name, no ?
04:36Raynesesj: I didn't name it. ;)
04:37esjthe naive might think that would be to do with the map function perhaps ;)
04:37kanakRaynes: It says slime 20091016 and slime-repl 20091016 are installed
04:37Rayneskanak: In that case, you might need to take this one to the swank-clojure mailing list. :\
04:37kanakRaynes: will do. thank you for your help.
04:39fliebelClojure is good a concurrency, right? I thought it would be fun to write a computer vs computer card game of the kind where you have to shout or hit the stack when a certain combination of cards is on the table. How would I do such a thing? All the computer players need to access the stack in parallel, and the one with the best code or the most luck wins.
04:39Raynesfliebel: Clojure is awesome at concurrency.
04:40mebaran151but I think it's not good for the concurrency fliebel once
04:40mebaran151*wants
04:40mebaran151as in, it's meant to prevent those kinds of race ocnditions!
04:41mebaran151fliebel, you'd probably want to use Thread/sleep with a random value to simulate differences in response time
04:41fliebelThat is what I was struggling with.
04:41mebaran151yeah you want a race condition :)
04:42fliebelhmhm, and I don't want to fake it, I want to make different players and test who's the best.
04:42mebaran151you could use a ref to moderate which player slaps its cards first
04:42mebaran151(whoever reads first wins...)
04:42mebaran151and randomized sleep to simulate different reaction times
04:44fliebelhmmm… What is I made one stack of cards which can be read by all, maybe via those hooks… The players then append their name to another ref and the first item on that ref is the winner.
04:44Chousukethat's not very interesting though.
04:45Chousukeessentially, the winner will be decided by luck. :/
04:45fliebelChousuke: How would you do it then?
04:45ChousukeI don't know.
04:45fliebelThe idea is that the winner is decided based on the most efficient way to check the cards.
04:47fliebelThere are a lot of combinations that lead to a match, some occur more often than others, so which you check first and how is important I think.
04:47Chousukewell, if you arrow direct reads of the stack then that would be most efficient.
04:47greghyou could model the actual comparison operations or whatever at a higher level than just clojure code
04:47fliebelAnd, I know for myself that I think the wrong way around with this game, so I'm going to simulate bad players as well
04:48mebaran151is there anything in emacs where I can select a bunch of region of text and align the code
04:49mebaran151format it based on clojure spec
04:49RaynesThat would be nice, wouldn't it?
04:50somniumM-x indent-region?
04:51RaynesWell, there ya go.
04:51timothypratleyGOSUB: after throwing out my silly theory - I tried the same test without lein - and it says "org.apache.log4j". I'm still digging into why.
04:53mebaran151somnium, thanks
04:53mebaran151I got emacs almost as nice as netbeans now
04:53mebaran151and I can hold side by side buffers which is nice
04:53mebaran151slime is a little bit more comfortable than the Netbeans repl
04:53somniumalmost!? :/
04:55mebaran151well dired doesn't quite do what I want
04:55mebaran151and I'm still scared whenever I do a buffer command
04:55mebaran151I don't know them yet
04:55somniummebaran151: that will pass
04:55mebaran151yeah I think it will
04:55somniumtheres nav if you dont like dired, on elpa
04:56mebaran151I was wondering if you could put swank clojure in a production app
04:56mebaran151and dial into it if it started acting up
04:56mebaran151no dired itself is fine
05:03Licenserhmmm okay I noticed something about the REPL, it clogs up after some time and gets all ugly, is that something that is me specific or a general problem?
05:06greghthat's a vague explanation :)
05:07Licenseryes of cause, I like to put things in vauge words when they confuse me - it's a nice and fluffy feeling inside I'd love to share with the rest of the world
05:08Licenserwhat I mean is after a while stuffing things in the REPL and requiering and using stuff I seem to be unable to revert it to a clean state by using (remove-ns ...)
05:11Licenserso I wonder if there is a way to keep it clean or at least arranged in a way that makes it easy to remove it again when I change stuff around
05:11Licenser
05:25mebaran151how do I make parenmatch highlighting default
05:27sparievmebaran151: (show-paren-mode 1) in .emacs
05:29mebaran151it's nice
05:29sparievmebaran151: btw. have you seen awesome screencast by Lau on slime/emacs http://www.bestinclass.dk/index.php/2009/12/clojure-101-getting-clojure-slime-installed/
05:30mebaran151can't watch screencasts: no soundcard :(
05:31esj mebaran151: the link I posted earlier works too.
05:31esj(he uses Ubuntu, i'm osx with aquamacs and it still works)
05:32mebaran151I'm on Ubuntu
05:32mebaran151what link?
05:32sparievmebaran151: anyway, there is his .emacs in that post with lots of useful emacs-fu
05:32mebaran151ah yeah I saw it
05:36RaynesLaurent is an Emacs God.
05:37Licenserwhen I do a require :reload will that concatinate to all the require's in the file I require?
05:39esji think its :reload-all ? But I may be imagining.
05:40Licenseresj: way thank you!
05:40esjnp
05:43Licenserthis is going to save me lots of trouble
05:43timothypratleyAnyone here know the internals of lein repl? If I delete clojure-contrib from the libs dir... the repl still has access to contrib somehow....
05:44timothypratleyit must be loading its own version somehow but I'm not sure where to start looking.
05:54G0SUBtimothypratley: any news?
05:56timothypratleyGOSUB: I've established that the problem occurs using lein, but not without, but still trying to figure out why.
05:58timothypratleyGOSUB: I'm a bit stuck because I can't seem to substitute a debug contrib to lein, which I was hoping would provide the clues.
05:59timothypratleyGOSUB: But I'm sure the answer is not far away :)
06:02RaynesWhat would be a better way to write this: (dosync (alter stack #(cons 2 %)))
06:03Raynescons' argument list doesn't allow me to just do cons 2.
06:05G0SUBtimothypratley: cool.
06:07G0SUBtimothypratley: but why, oh why? everything is in classpath, alright.
06:08G0SUBtimothypratley: and oh, it happens inside slime repl too. not just lein repl. (using clojure-project)
06:12timothypratleyGOSUB: That's handy to know!!!
06:12timothypratleyGOSUB: The test I did with a custom REPL was using latest contrib/clojure
06:13timothypratleyGOSUB: When I do custom REPL with the jars from lein/lib dir.... problem occurs
06:14timothypratleyGOSUB: I'm starting to think this is an old bug that got fixed (hence why we couldn't see it in the source)
06:18Licenserhmm hmm, when I get a clojure stack trace that and there is not a single of my own functions in the trace does that mean clojure is eating it up or does it mean the error happens outside of the function calls of mine?
06:38G0SUBtimothypratley: any idea what the bug might be ?
06:43timothypratleyGOSUB: Nope, I'll post what I've found on the group - but in terms of solving your problem I think you'll have to stick with (log4j-logging) for now
06:44G0SUBtimothypratley: that fact that it's private makes matters worse
06:47timothypratleyGOSUB: *nod* yup
06:48Licenserhmm I think to think I have some odd bug in the printer o.O
06:50RaynesAlso, this was the better way: (defn flip [f] (fn [& args] (apply f (reverse args))))
06:51RaynesFollowed by, (dosync (alter stack (flip cons) x)))
06:51RaynesFlip is probably already defined in core, but I couldn't find it.
06:52Chousukeit's not.
06:53Licenserah I know what it comes from, lazyness :D
06:54RaynesChousuke: Cool, I did something right! :D
06:54RaynesChousuke: I'm used to using flip in Haskell, so it was the obvious solution here.
07:00mebaran151anybody here know the transaction syntax for clojureql?
07:05hamzahey guys, is it possible to write a function to file? just like using pr to write objects to a file? I would like to have function modify it a bit then write the new function to a file?
07:09mebaran151I don't think it is natively, but I have a coworker that has a macro that almost does it
07:09mebaran151as in, what do you mean by write it file: if it's a clojure, the variables might refer to things you wouldn't think of
07:10hamza(prn [2 3]) using this with with-out-str would give me string represantation of the vector that i can write to a file and read it back later, i would like to do same for a function.
07:11mebaran151but a function isn't simple like a data-structure
07:11mebaran151it's variables are bound to its environment
07:11mebaran151to really serialize a function, you'd have serialize its environment as well
07:12mebaran151if you just want the actual representation, you could write a macro that would take the function forms as a list of symbols and writes them somewhere
07:14timothypratleyGOSUB: I'm off to bed, have posted about the problem http://groups.google.com/group/clojure/browse_thread/thread/79c609df3632a5d1, hopefully someone will be able to suggest a better solution.
07:15hamzayeah i am after the actual represantation..
07:20optimizeris RAII possible in clojure?
07:22somniumhamza: you could try something like this http://gist.github.com/275149
07:28hamzaam i missing something? (defn-src atest [] (println "test")) i am getting unable to resolve symbol body?
07:30somniumhamza: ah, the tilde is wrong in the gist, updated it
07:31hamzasomnium: greate thanks a lot just what i was looking for..
07:35defnWhen I add a dependency to leiningen, where does it all pull from?
07:35defnI see some people adding things like org.markdownj/markdownj to their project.clj, but it's not in the repo anywhere
07:35defnthe clojars repo i mean
07:36LauJensenI would guess it checks Maven Central
07:36Raynesdefn: It pulls from Maven Central, Clojars, and clojure-snapshots as far as I can tell.
07:36defnthanks LauJensen -- didnt know what to google on that
07:37Raynesdefn: clojure-snapshots would be build.clojure.org/snapshots
07:37defnhmm, wtf is this markdownj coming from
07:37defn [org.markdownj/markdownj "0.3.0-1.0.2b4"]
07:37defnit's not in maven2 or in clojars
07:38RaynesI'm pretty sure it's in maven central.
07:38defnyou would think, but i go into maven2/org/...
07:38defnand no markdownj
07:40defnah-ha!
07:40defnhttp://code.google.com/p/markdownj/wiki/Maven
07:41defni need to add a repository to markdown as a dependency and then i can get it
07:41defnwhoa im tired
07:41RaynesAdd a repository to markdown as a dependency?
07:41defni need to add a repository in my project.clj and then i can get it
07:42defnyeah sorry about that, that is just incomprehensible
07:42RaynesHow do you add a repository to project.clj? ;o
07:42LauJensendefn, did you check out my latest blogpost where in I show how to add your own jars to a lein config?
07:43RaynesLauJensen: Link pwease.
07:43LauJensenwww.bestinclass.dk
07:43defnLauJensen: i didnt see that but im interested
07:43LauJensenclick blog - click top post
07:43defnleiningen is still a strange mistress to me
07:44defni can do some basics like :dev-dependencies, :dependencies, :main, but havent messed with any others
07:44RaynesLauJensen: I referred to you as an Emacs God earlier. Do I get points?
07:44Raynes:p
07:45LauJensenNo, but because of your good motives I wont slap you for blasphemy
07:45defndude LauJensen ! I stop checking my RSS feeds for 5 days and you manage to put a ton of awesome content up
07:45defnalso, you are an emacs god, your videos showed me about fuzzy completion in slime
07:45defn:)
07:45LauJensenYea the Hadoop stuff is pretty fun
07:45LauJensenI hope to do some massive image processing soon :)
07:46defnim excited about the enlive stuff
07:46defni read up on it, but im still not 100% on how to use it
07:46LauJensenanyway, gotta duck out a little while, will be back in 5 hours or so
07:47defnLauJensen: what's clojure-mode-el?
07:47defnis it el or clojure-mode-l?
07:47LauJensenclojure-mode.el
07:47LauJensenThe Emacs Lisp file which contains Clojure-mode
07:47defnoh -- gotcha
07:49defnLauJensen: i had no idea how to do a keyboard macro on a region
07:49defnthat rules
07:50defnive just been doing C-u 20 C-x e
07:50defnor whatever, to do multiple lines
07:51defnwhere i make sure to put a M-x next-line
07:51defnand M-x beginning-of-line
07:52defnLauJensen: using enlive to get those function is nice and all, but couldn't you just use ns-publics?
07:53LauJensenYes of course - But how would you show off Enlive doing that?
07:53defn:D
07:54defnLauJensen: i have an odd request for a video
07:54LauJensenThe important part is the (info ...) - that way you can fix stuff yourself
07:54LauJensenWhats the request?
07:54defni want to see 2 hours of emacs + clojure with no particular theme, just you working on "stuff"
07:55defnthat includes switching windows, looking stuff up, etc.
07:55LauJensenAh
07:55LauJensenI don't think I'll do 2 hours, but I might do a compilation of sorts to give an idea of the workflow, a little similar to the webdevelopment video
07:55defnyeah that'd be cool
07:55defnid also like to know more about *organizing* clojure projects
07:56defnlike with a webapp im messing with, im having a very hard time separating functionality out into separate files
07:56defnsince they all seem to rely on one another
07:57LauJensenOk - I really need to duck out now, but I'll think it over. I also have a tool in mind for organizing projects, but more on that later :)
07:58defnsounds good, thanks again
07:59LauJensennp
08:06esjdefn: nice requests, I could use that stuff too.
08:07gerrhello
08:07gerrwhat's wrong with this: (defprotocol Show (show [x]))
08:08gerr(deftype Person [name age] Show (show [x] (str (:name x) (:age x))))
08:08gerrjava.lang.IllegalArgumentException: Can't define method not in interfaces: show (NO_SOURCE_FILE:2)
08:09gerr,(defprotocol Show (show [x]))
08:09clojurebotDENIED
08:14defnesj: ive been thinking a lot about organization
08:14defnesj: i think it's important to pay attention to the type that a function returns
08:14Raynesgerr: http://gist.github.com/275175
08:14Raynesgerr: Sorry for the delay.
08:14esjdefn: me too actually, getting things properly structured is a good part of the battle.
08:14gerrRaynes: ok
08:15RaynesIt appears that 'this' is implicit.
08:15defnso for instance, a "controller" function in my compojure app can return anything, EXCEPT html
08:15defninstead of making some function (defn gen-page [] (html (interpose .......)))
08:15Raynesgerr: You can access the fields of the type directly in the protocol functions.
08:15defnyou just put the (html x) part into a layout file
08:16RaynesI didn't realize that initially earlier, and had hell with it.
08:16gerrRaynes: but in defprotocol, i still need one arg?
08:16Raynesgerr: Yes.
08:16RaynesIt's 'this'.
08:17gerrhmm, thx
08:17{newbie}deftype? is clojure gaining an builtin OO system?
08:18Raynes{newbie}: Not really. No more than Haskell has an OOP system because of it's algebraic datatypes.
08:18cemerick~deftype?
08:18clojurebotdeftype is see datatype
08:18cemerick~datatype?
08:18clojurebotdatatype is see datatypes
08:18cemerick~datatypes?
08:18clojurebothttp://www.assembla.com/wiki/show/clojure/Datatypes
08:18cemericksheesh
08:18cemerick{newbie}: see ^^
08:19Raynesgerr: Note you can do this `(deftype Person [name age] :as x Show (show [] [x] (str name age)))' if you want to access 'this' directly.
08:19{newbie}OH, I'm reading programming clojure right now so I'm a couple of revs behind
08:19Rayness/directly/explicitly/
08:20gerrRaynes: ..(Show [] [x]..) two arg list is abit odd
08:21Raynesgerr: Also, see the examples in (doc defprotocol)
08:21gerrok
08:23rhickeyso, who's written code that depends on defmacro creating (internally) a fn with the same signature?
08:23Raynesgerr: The resulting functions from defprotocol dispatch on their first argument, and that's why they have to have at least one argument.
08:24gerrRaynes: i see
08:34RaynesSomebody needs to write a book and host it for free online, like Real World Haskell.
08:38cemerickvy: functions in BNF?
08:38cemerickoverkill for sexprs, no?
08:39_fogus_cemerick: I don't know about BNF, but the format that the CLIPS user manual uses for its functions is pretty nice.
08:39vycemerick: In some sort of BNF, for instance, CLHS is quite in this area.
08:39vys/quite/quite good/
08:39vy_fogus_: +1
08:41_fogus_Chouser and I have adopted a similar format for our book
08:46chouserrhickey: now *that's* an interesting question. what are you up to?
08:47chouserI don't have any real code like that.
08:47chouserShould 'restart' be named 'restart-agent'?
08:47cemerickseems like a bad idea in general
08:49chouserI guess if you were trying to write your own (modified?) version of macroexpand or something.
08:49rhickeychouser: I'm thinking of supplying 2 more implicit args to defmacro expansion fns - &env and &whole
08:50chouserooh
08:50rhickeycemerick: right, I consider any such code as relying on implementation details
08:50rhickeyand thus subject to breakage
08:51rhickeythe latter, &whole, might be the path for fn metadata
08:54rhickey&env will preclude the implementation-dep inside things like local-bindings here: http://gist.github.com/254110
09:28midgetHey.
09:28midgetDo you know how to twist on the knife?
09:28midgetI can`t make it right - always cut myself
09:30esjwell, that would be a mutating operation, so we can't help you there.
09:31Drakesonhow do you add a repository to the 3 default ones in leiningen?
09:32Drakesonfor instance, I want to add http://mirrors.ibiblio.org/pub/mirrors/maven2
10:01lisppaste8someone-stuck-behind-a-mean-proxy pasted "+1 for a supported way to access the environment in macros" at http://paste.lisp.org/display/93280
10:19RaynesDrakeson: :repositories
10:21RaynesOf course, there isn't any example of how to actually use that, so I can't help you there.
10:54chouser,({(int 5) :ok} (long 5) :not-ok)
10:58chouser,({(int 5) :ok} (long 5) :not-ok)
10:58clojurebot:not-ok
10:59chousercan we use Clojure's = instead of Java's .equals() for map key comparison?
10:59chouserthis just bit me hard.
11:05cemerick1.equals(1L) is false ?!? Crazy.
11:05rhickeychouser: not without breaking the contract of j.u.Map
11:07chouserarararagag
11:10chouserI just spent longer than I'd care to admit tracking down a map lookup failure.
11:11chouserthe keys of the map are complex nested maps and vectors, and printing the map keys and the item I was looking up showed they printed identically.
11:11cemerickthat's not friendly at all.
11:12chouserso then I added debugging code to walk through the map, and discovered that the key and lookup value were =
11:12rhickeychouser: how did you end up with a long?
11:12chouserchecking that now. I think the long came from a protobuf
11:13cemerickpr should probably attach suffixes to numbers as long as stuff like this is possible.
11:13cemerickor, optionally so, perhaps
11:13chouseryeah, I think that was it. some of these maps are converted to protobufs and back. so this one went in as an int and came out a long
11:14chouserbut then I looked it up using the original int
11:15chouserI even knew about the problem with different number types as map keys, and still didn't "get" it
11:15chouser,(= (int 5) (long 5))
11:15clojurebottrue
11:16chouser,(= (hash (int 5)) (hash (long 5)))
11:16clojurebottrue
11:18rhickeythis is an area with no universally good answer
11:18chouserno kidding
11:18chouserwell
11:18rhickeyas long as you can have different types represent the same value
11:18chouser.equals() could be potentially do the "right thing" couldn't it?
11:19rhickeyyou mean if JAva changed it?
11:19chouserright
11:19chouserI guess it still couldn't support new number types like Ratio
11:19rhickeywhat about (.equals 1 1.0) ?
11:20chouserI understand that's a question that would come up, but this morning the difference between 1.0 and (int 1) seems much bigger than the difference between (int 1) and (long 1)
11:20chouserbecause they print differently, I would have spotted 1.0 much sooner.
11:21chouserOf course I'd hate for either ints or longs to print with decorations be default
11:21chouserand I wouldn't have thought of trying a non-default print option until after I'd identified the real problem.
11:22chouser*print-dup* already prints them differently
11:22chouserdidn't even occur to me to try that.
11:23cemerickstuff like this is going to cause so much pain when people start seriously targeting other hosts
11:23Spockz|lapstuff like what?
11:30stuartsierra,(.equals (long 1) (int 1))
11:30clojurebotfalse
11:30arohnerchouser: yeah, that problem bit me hard a few months ago
11:31arohnerdifferent printing would have helped me catch it much sooner
11:31stuartsierra,(with-out-str (binding [*print-dup* true] (pr (long 1) (int 1))))
11:31clojurebot"#=(java.lang.Long. \"1\") 1"
11:31arohnerwhat's the problem with making longs print as "1L" or whatever?
11:31chouserugly
11:32stuartsierraIsn't that what Java's long syntax uses?
11:32chouserbut maybe it'd be worth it.
11:32arohnerthat's not very convincing to me when we already print 1.0 and 1M
11:32stuartsierra,(pr-str 12345678901234567890)
11:32clojurebotjava.lang.ExceptionInInitializerError
11:33stuartsierra,(pr-str (BigInteger. "12345678901234567890"))
11:33clojurebot"12345678901234567890"
11:33stuartsierra,(binding [*print-dup* true] (pr-str (BigInteger. "12345678901234567890")))
11:33clojurebot"#=(java.math.BigInteger. \"12345678901234567890\")"
11:33cemerick1L is a lot prettier than #=(java.lang.Long. "1")
11:34chouserheh. true.
11:34cemerickI'd love to have literals like that in general, to avoid stuff like (int 1)
11:35stuartsierraYes, Java uses 1L for (long 1).
11:37chouser(int 1) also means primitive in some contexts. I assume 1I or whatever wouldn't?
11:38stuartsierrachouser: probably not
11:38stuartsierra1L would probably mean (java.lang.Long. "1") to the Clojure reader.
11:39arohnerwhy not?
11:39arohnerit probably doesn't now, but why couldn't it?
11:40stuartsierraI guess it could, in a 'loop' head.
11:40cemerick1L should just expand out to (long 1), which will get boxed as necessary anyway
11:40arohnerthe reader reads 1M appropriately, so I don't see why it can't do 1L just as easily
11:42stuartsierracemerick: that assumes that "L" is a reader macro
11:43cemerickstuartsierra: it should probably be considered something lower-level than that. Not dispatching on #, etc.
11:44cemerickthe reader can emit whatever symbols it wants as its tokenizing
11:56rhickeyLong-term (pardon the pun) I think longs and doubles will win out as defaults, making ints as rare as shorts
11:56stuartsierrarhickey: That wouldn't have prevented chouser's original problem caused by interop with protobuf.
11:56rhickeystuartsierra: sure it would, if Clojure never boxed to Integer, only to Long
11:57stuartsierraUntil some other library decides to down-cast long to int!
11:57rhickeystuartsierra: but only boxed things end up as map keys
11:58rhickeyso back to Long on box
11:58stuartsierraAh, I think I see
11:58stuartsierraIn other words, there wouldn't be any auto-boxed java.lang.Integer
11:58rhickeyin my do-over universe, Clojure integer literals would be longs that did exception on overflow. The only other interger would be explicitly-requested bigints
11:58stuartsierraJust java.lang.Long
11:59leafwconsidering the overhead of an Object, whether it has a long or an int inside will make little difference. I'd go for having only boxed Long as well.
11:59stuartsierrarhickey: But aren't automatic integer upgrades a cornestone of Lisp? :)
12:00rhickeystuartsierra: I now consider that a mistake for Lisps
12:00stuartsierraHuh, interesting.
12:01rhickeyI agree that 'bad math' is unacceptable, but exception on overflow is fine, as long as explicit bigints are there and contagious
12:01cemericksort of inevitable given hardware history
12:02chouserinteresting
12:02rhickeyIn DotLisp I did exception on overflow, and it is better for 95% of the use cases
12:03rhickeyIf you know you will have bigints, use 42BIG (or whatever)
12:03chouserbut a protobuf can emit a boxed Integer too -- that would be the same problem in reverse.
12:03rhickeychouser: a boxed integer how?
12:03rhickeyuser boxing?
12:03rhickeyreflection?
12:04chouseroh
12:04rhickeyif the lang only does Long boxes, and fixes reflection boxes, then only user boxing is an issue
12:05rhickeyoh, and Java-land boxing
12:05chouserright, it's coming from java-land
12:05rhickeythe Java wrapper for protobufs boxes?
12:06LauJensenSo the compiler will handle all incoming Ints being cast to longs and the same outgoing if need be ?
12:06rhickeyrather than generating classes with primitive fields?
12:06chouseroh, i see what you're saying. let me check.
12:13chouserthe generated methods return primitives, but I'm building the clojure map from a java.util.Map
12:13chouserso it's java or protobuf doing the boxking, not Clojure
12:14djpowellif someone calls (mymacro String), is there anyway to resolve the symbol: String in that macro, into the class object: java.lang.String
12:14chouser,(resolve 'String)
12:14clojurebotjava.lang.String
12:14djpowellah
12:17rhickeychouser: when Java is boxing you will always have to manually do matching of types. But at least with Longs-only on the Clojure side you would rarely have this problem in Clojure code, whereas it is a current issue
12:17rhickeyevery now and the I contemplate these changes, but dread the pushback
12:17rhickeybreakage
12:18chouseryeah. In this case, I have a loop that's converting and can easily adjust the number type.
12:18chouserbut what should I adjust to? with your proposed change, it would be easy: Long.
12:18rhickeyright
12:19chousertoday, I guess I'll want to convert to the minimal acceptible type. is there a fn for that?
12:19rhickeyalso, longs are on the table to get primitive arg/return support
12:19rhickeychouser: so 1 is Byte?
12:19chouser:-(
12:20rhickeyexactly
12:20chouserno, I want to match what Clojure would do for a similar literal
12:20chouserso that when the protobut has {5 10]
12:20chouserso that when the protobut has {5 10} and I type {5 10} in the code, they match
12:20chousereh
12:21chousermaybe. Either that, or I want to manually cast to longs in my hand-built maps to match the declared types of the protobuf fields.
12:21chouserboth sound like trouble.
12:22rhickeyif Clojure defaulted to Long, I'd be happy printing all others with suffixes
12:23rhickeybut the fact is, in Java, if you put a boxed long 42 into a map key and lookup a literal 42 you won't find it
12:23rhickeythat is the map you are building and handing to Clojure
12:24rhickeybasically, types matter when numbers are used as keys
12:25rhickeyJava could have made different decisions in the boxed number tower, but that's water under the bridge
12:26rhickeyso, Long integers by default, exceptions on overflow, suffixes for all others?
12:27chouserI'm on board.
12:27chouser:-)
12:27cemerickvery happy about Longs and suffixes
12:28rhickeycemerick: and on overflow?
12:28chouserwho are these people that cause you pain when you make beneficial breaking changes.
12:28chouser?
12:28cemerickrhickey: aren't things going to get promoted automatically anyway?
12:28chouserand can I have a little one-on-one time with them?
12:28rhickeyI hardly ever make breaking changes
12:28rhickeycemerick: no, that's the change
12:29chouserI know. because you fear these bullies. ;-)
12:30rhickeywhat's funny is that, in spite of rarely making breaking changes, still sometimes get dinged for Clojure changing so fast, even though it's largely additions
12:31rhickeycemerick: it ends up that promotion from primitive to boxed (BigInteger) is a primary perf disaster
12:31rhickeycemerick: because on the bytecode level no single type can hold both
12:31cemerickclearly, I don't do enough maths
12:31cemerick,(-> Integer/MAX_VALUE inc)
12:31clojurebot2147483648
12:32cemerickthat's interesting -- that fails in my repl with an overflow
12:32rhickeyhere too
12:33cemerickanyway, that (sometimes?!?!?) fails, but this is OK currently:
12:33cemerick,(-> Integer/MAX_VALUE Integer. inc)
12:33clojurebot2147483648
12:33chouser((identity inc) Integer/MAX_VALUE)
12:34_fogus_Are we playing, avoid the overflow exception game?
12:34rhickeybut Integer/MAX_VALUE is tricky as you are already into Java primitive rules
12:35cemerickrhickey: so, insofar as I obviously don't know what the overflow rules are currently, I can't see how I could have a defensible position (or opinion, even) on changing them :-)
12:36rhickeycemerick: with no Java interop in play, the rules are the traditional lisp ones - unbounded integers
12:36cemerick,(inc (int 2147483647))
12:36clojurebot2147483648
12:37rhickeythe change would be that unqualified integers would be longs, and would throw on overflow rather than auto-convert to bigints
12:37cemerickI'm really curious about why clojurebot isn't erroring on that.
12:37cemerickoh, I see
12:38cemerickrhickey: if it's primarily a perf issue, I wonder if it's at all possible to opt out of autoconversion, rather than opting into it.
12:40lpetitHello, is it normal to have an ArrayIndexOutOfBoundsException throw from clojure.lang code, more precisely PersistentArrayMap$Seq.first() (line 217) ?
12:40chouserlpetit: when you give a non-even number of items in a literal {}, yes.
12:41chousercemerick: but it's not just perf, I think -- it's problems like the one I just had.
12:41lpetitAh, but here first() is called from APersistentMap.hashCode() (line 101) which is called from APersistentMap.equals() (line 60) which is called from java code
12:42chouser,{1}
12:42clojurebotjava.lang.ArrayIndexOutOfBoundsException: 1
12:42lpetit,(equals {1} {2})
12:42clojurebot1
12:43lpetit,(= {1} {2})
12:43clojurebot1
12:43chouser,(first {1})
12:43clojurebot1
12:43lpetit,{1}
12:43clojurebotjava.lang.ArrayIndexOutOfBoundsException: 1
12:43chousernoo
12:43chouser,(val (first {1}))
12:43clojurebot1
12:43chouserno! those are failing for me.
12:43lpetitgargl
12:43lpetit(clojure-version)
12:44lpetit,(clojure-version)
12:44clojurebot"1.1.0-alpha-SNAPSHOT"
12:44chouseranyway, those maps are invalid. Don't do that.
12:44chouserlunch.
12:44cemerickchouser: how does overflow impact the issue of concrete types of map keys?
12:44lpetitWell, it's from something read by the reader from a user source code editor ...
12:45lpetitSo the reader seems to not complain, and the exception is throw later
12:45lpetit(doc read-string)
12:45clojurebot"([s]); Reads one object from the string s"
12:45lpetit,(read-string "{1}")
12:45clojurebot1
12:45lpetit,(read-string "{1 2}")
12:45clojurebot{1 2}
12:46lpetit,(read-string "{1}")
12:46clojurebot1
12:46lpetitok clojurebot is fooling us there
12:48unfo-any help to why my join-channel function is not being called? https://gist.github.com/5005a3004cf58b1b7df3
12:49lpetitAnyway, I now know how and where to catch the problem, thanks
12:52stuartsierrarhickey: Personally, I think rapid change is good IF it comes with a predictable cycle of stable releases
12:54cemerickstuartsierra: absolutely. Everything can get broken in the process of being improved as long as there's a tag for a stable build in clojure and contrib.
12:57stuartsierraI'm working on Contrib.
12:59stuartsierraAnd I think Clojure itself needs more releases. 1.1 added a whole pile of stuff that could have been let out incrementally.
12:59cemerickmore tests + a maven repo + build process would make weekly releases entirely plausible, if warranted.
13:00stuartsierraMaybe not weekly, but at least every 6 months. Weekly would be a lot of extra work for rhickey.
13:01cemerickShouldn't be. mvn release:prepare release:perform, and you're done. *shrug*
13:02cemerickI'm probably not seeing a lot of stuff that is happening around release time.
13:03stuartsierracemerick: Not until we have a Maven build for Clojure. That's another mountain to climb.
13:04cemerickstuartsierra: we'll have to bag rhickey first. ;-)
13:07stuartsierraright
13:25unfo-if I have some data in a struct and I get it via (:somekey @mysharedstuff) how could i (in repl) get info about its type?
13:26Chousukewell, you can call class on it
13:27technomancyunfo-: C-c S-i gives you a nice inspector if you're using slime
13:28unfo-technomancy, nope, not using it since emacs is bizarre to me :) coding with IDEA and standard REPL
13:28technomancythen I guess you need to use the class function
13:29unfo-ty
13:40patrkrisLauJensen: is it possible to say to clojureql that utf8 must be used when connecting to mysql?
13:41LauJensenpatrkris: I'm pretty sure its an attribute of the driver, but we haven't wrapped it. You might be able to specify it directly on the connection-string
13:42LauJensenUuh check it out, Clojure almost in top10 again on Hacker News :)
13:43patrkrispatrkris: are you suggesting I modify the jdbc-url on the map returned by make-connection, or is there another way to specify the connection string directly?
13:43LauJensenpatrkris: Gimme a sec I'll check
13:43patrkrisLauJensen: thanks
13:44LauJensenpatrkris: In the URL set "//localhost/db&characterEncoding=UTF-8"
13:44LauJensen2.nd argument to make-connection-info
13:44patrkrisLauJensen: coolio, thanks
13:45unfo-fffffuuuuu! I had a samename struct as I had a local variable in a few places... great confusion
13:46hiredmanuse ’
13:46hiredmanor <x>
13:52unfo-https://gist.github.com/5005a3004cf58b1b7df3 -- why does my map fail?
13:52hiredmanmap is lazy
13:53unfo-aaaaah! didn't know that
13:53unfo-so I need to use a do* function there? the doall or wotnot
13:53unfo-or was it dorun
13:53hiredmansure, you might just replace the call to map with a call to doseq
13:53unfo-ok. thanks!
13:54hiredmandoseq is like for, but not lazy, and it evaluates to nil
13:54LauJensenhehe
13:54LauJensen"doseq is not like for because..." :)
13:56LauJensenDoes anybody know where _ato Alex Osborne is hiding these days?
14:02unfo-(dorun (map myfun mylist)) worked wonders :-)
14:03unfo-hiredman, even tho' I read the lazy/infinite sequences chapter quite well in my view (from programming clojure) i still managed to forget that map is lazy... doh :D
14:03unfo-hiredman, very much appreciated! :)
14:05technomancyclojurebot: map?
14:05clojurebotmap is *LAZY*
14:07unfo-:-)
14:08unfo-REPL is deceptive in this because it gives me the result I am expecting immediately
14:09LauJensenYea I've been tripped up by that as well
14:09unfo-but now for something completely different after I submit this patch to my github
14:11mebaran151I think I'm finally comfortable in emacs
14:11mebaran151my penance for accidentally deleting my homedir is completed
14:12LauJensenhqhq
14:12LauJenseni mean... haha :)
14:12mebaran151eah
14:12mebaran151I'm gonna stick around
14:12mebaran151I got the the layout I like, and tab completed bufffers are kind of groovy
14:12mebaran151I'm just looking for a good window manager now
14:13mebaran151as in a quick way to switch between emacs panes
14:13LauJensenC-x b, aint working?
14:13mebaran151I mean
14:13mebaran151I have three different windows open
14:13mebaran151I'd like to switch between the repl and a pane
14:13mebaran151of doc editing really fast
14:14LauJensen C-x o ?
14:14mebaran151well it's a little basic
14:14technomancymebaran151: C-c C-z switches to the repl from any clojure buffer
14:14mebaran151but what about switching back :)
14:14technomancyI don't know if there's a reverse
14:14mebaran151yeah
14:14mebaran151I'd like something a little more general
14:14mebaran151forwards and backwards
14:14mebaran151I'd also like an undo that doesn't make me cry
14:14ska2342mebaran151: checkout iswitchb, mtorus, windmove and windresize
14:15LauJensenmebaran151: the undo makes you cry? I really like it
14:15technomancyemacs' undo mechanism is carefully architected in order to avoid creating time-travel paradoxes
14:15technomancytrust me, you really don't want to have to think about what happens when alternate timelines interact.
14:16mebaran151I haven't successfully undone yet
14:16mebaran151hg rollback!
14:16mebaran151hg revert
14:16ska2342mebaran151: you can setup a slime-selector-method for switching between clojure code files and the repl, back and forth
14:16mebaran151ah that was another questiong
14:17mebaran151how do I control where the slime error pane renders itself
14:17chouservim undo lets you go to any version of the file since you opened it -- even branches that have been undone.
14:17LauJensenIts fun I was trying to remember what I do for undo/redo, but I cant remember it directly, I have to read it from my fingers first
14:17chouserjust fyi
14:18mebaran151chouser, I'm a big vim fan
14:19mebaran151it's the only thing I use for sysadmin
14:20technomancythere's no way to calculate an md5 sum of a file without slurping it all into memory, is there?
14:20technomancyunless you shell out or something
14:20ska2342mebaran151: I seem to remember to get the slime selector method from Bill Clementson, here: http://bc.tech.coop/blog/docs/clojure-emacs.el
14:21chousertechnomancy: it doesn't all have to be in memory at once
14:22Chousuketechnomancy: IIRC you can feed the MD5 calculator thingy data in chunks
14:22mebaran151yeah so I remembered
14:22mebaran151I think it takes an input stream
14:25technomancyaha, you can call "update" on it with just a few bytes. sweet.
14:26humphrejI've got a clojure syntax question..
14:26mebaran151heh, playing in Erc
14:26mebaran151this is actually a far more convenient way to ask coding questions
14:26Hunmebaran151: try rcirc. it feels more clean :)
14:26humphrejI don't think In understand binding
14:27mebaran151can I get it from packages?
14:27humphrejhttp://pastebin.com/d727cc1bd
14:27Hunit's included by default since emacs22
14:27HunM-x irc
14:27humphrejMy question is why do I get the error if the set! is within the map func
14:28chouserhumphrej: you probably understand 'binding' ok -- the problem there is that map is lazy
14:28chouserso the code in your fn isn't executed until the resulting seq is printed by the repl, *after* you've left the 'binding' scope.
14:29humphrejI see - it does work if I enclose everything in a huge binding
14:29humphrejinc the usage of the lazy seq
14:30chouserright. or realize the seq before leaving the binding you've got.
14:30cemerickis there any way to configure a var so that one can set! a value to it without having a binding in place? Seems like doing (binding [*foo* *foo*] ...) shouldn't be necessary if one wants to use a var to provide returns/status/etc outside the stack.
14:31chouserhumphrej: via 'doall' for example.
14:32humphrejreason I ask is that I found this page http://www.findinglisp.com/blog/2004/11/investing-with-lisp.html
14:32humphrejand was wondering the best way to implement the make-history-function in clojure
14:34humphrejI was thinking keeping it lazy would be nice as then the source seq could be a seque or somesuch
14:34rhickeycemerick: what happens in other threads?
14:35fliebelCan someone answer me this very simple question: How do I empty a vector in an agent?
14:35cemerickrhickey: in my ideal world, nothing -- it seems that set! should be a no-op (not an error) on a var that has no binding.
14:36rhickeycemerick: I'm confused - what's the use case?
14:37cemerickrhickey: I have a fn that has a status code, which is generally uninteresting. When a caller *is* interested in that status code, I'd like them to be able to bind on that var, and check it when they want.
14:38cemerickI just think it's irritating to have to wrap my fn impl in (binding [*foo* *foo*] ...) in order to set! that occasionally-interesting status code
14:38chouserfliebel: (send empty agt) ?
14:38ska2342cemerick: wrap it in a try catch in your fn?
14:39cemerickska2342: surely you're joking :-P
14:39ska2342cemerick: Hm, I'm not so sure.. Going back to the REPL for a moment to try this
14:39fliebelchouser: I did not think of the possibility that such a stupid function would be in core.
14:40cemerickska2342: oh, I'm sure it'll work, but that's hardcore ugly.
14:41rhickeyfliebel: what's stupid about empty ?
14:41chouserfliebel: it's actually quite important to allow fns to support a variety of collections.
14:41ska2342cemerick: uglier than changing the behaviour of a special form for a rare use-case?
14:41chouser(into (empty x) (map f x)) is such a nice pattern that lots of people want it to be a fn of its own. :-)
14:42qbgcemerick: That would be solved beautifully with multiple return values
14:42cemerickska2342: not so rare, IMO, but regardless, uglier than what's necessary now
14:42fliebelrhickey: Nothing really, but I could not imagine a use case where you would want to return an empty sequence. Since stuff is immutable anyway I'd just use [].
14:42ska2342yay, multiple-value-bind, here we come :-)
14:42rhickeycemerick: I'll admit that use case is not well supported, but unsure about set! of unbound as no-op
14:42chouserhumphrej: I'd actually recommend strongly against using a var for your *histry* in this case.
14:43chouserhumphrej: you might be interested in 'partition'
14:43chouser,(partition 3 1 (range 10))
14:43clojurebot((0 1 2) (1 2 3) (2 3 4) (3 4 5) (4 5 6) (5 6 7) (6 7 8) (7 8 9))
14:43cemerickqbg: if I wanted that, I could simply return a vector from the fn in question
14:44ska2342cemerick: currently the users of your fn will *have* to establish a binding, even if not interested in the status. I'd consider it nicer from the user standpoint if it were wrapped in an ignore-errors-like form
14:44cemerickrhickey: just a thought -- I've just written the (binding ...) workaround three times this afternoon, so I figured I'd bring it up.
14:44mebaran151any of you guys use eproject or nav?
14:45chousercemerick: what's the type of the object you return (not the binding one, the main one)?
14:45cemerickska2342: no, the current best-practice is for the author of such fns to bind the var to its existing value so that set!'s work, but have no effect. This only affects library authors, not users.
14:46cemerickchouser: a map, but the status code in question in this fn is an int that's only of interest 4-5 levels up the stack
14:46cemerickchouser: it's actually perfect for error-kit, but too simple of a problem to use error-kit for :-)
14:46rhickeycemerick: if you bind in the setting fn, that won't make it out of the binding
14:46chouserheh. every problem is too simple to use error-kit for
14:47chousercemerick: having the ignore-on-unbound-set configurable (non-default) is a bit interesting.
14:48ska2342this sounds more like a thread-local atom, not?
14:48rhickeycemerick: you could test that the var is bound before trying to set!
14:48chouseryou want naive misuse of var and set! to be flagged with an error, but if you specifically ask for such errors to be ignored on a given var, maybe that'd be good enough.
14:49rhickeydon't we just need a bound? fn ?
14:49rhickeythen you could write -set-if-bound!
14:49chouseryeah, that's better
14:49humphrejchouser: thanks let me ponder that one
14:50ska2342would bound? return false if only the root-binding is established? or would it have to distinguish between no binding, root-binding and binding-form-dynamic-binding? No too easy I guess.
14:50ska2342/No/Not/
14:51chouserska2342: right, there's .isBound already, but that's something else.
14:51cemerickska2342: that's a thought -- perhaps I should set the api up so that callers bind an atom to a var, which is reset! if non-nil. That might be simpler all-around.
14:51qbgrandom question: Is it a known issue that the master branch of clojure-contrib will no longer compile with the master branch of clojure?
14:52rhickeycemerick: and then reimplement the stack-unwinding?
14:52chouseryou'd want 'thread-bound?' or something?
14:52rhickeychouser: yes, two flavors
14:52chouserqbg: did you 'ant clean' your contrib before building?
14:53rhickeyis there a reason that contrib doesn't auto-clean?
14:53cemerickrhickey: I sense sarcasm. Did I miss something?
14:53qbgchouser: Thanks, that fixed it
14:53rhickeycemerick: no sarcasm, but what happens with nested calls when you start using an atom?
14:54cemerickyeah, not a general solution -- works in this particular case, though, where I know there's no nested calls
14:55rhickeycemerick: would not thread-bound? solve your problem?
14:55ska2342I humbly repeat my question about a thread-local atom-like-type. Is that desirable, interesting or even doable?
14:56chouserska2342: var is a thread-local atom-like
14:56cemerickrhickey: I believe so, and I'd use it. I'm just trying to finish this particular piece this afternoon. :-)
14:57rhickeycemerick: you could send me a patch with bound? and thread-bound? right now...
14:57rhickey:)
14:57rhickeyall the support is in Var already
14:58cemerickrhickey: halfway there already :-)
14:58arohnerI wrote thread-bound? a few days ago, and then threw it away because I went with another approach for the problem that needed it...
14:58cemerickstill won't be in our actual build of clojure for a while tho
15:00cemerickrhickey: when would Var.count be > 0 but yet the bindings have no entry for the var?
15:01trmswdoes anybody else get an error from (use 'clojure.contrib.http.agent): bytes already refers to: #'clojure.core/bytes in namespace: user?
15:02rhickeycemerick: you don't want count, that is an optimization. You want getThreadBinding(0 != null, but not public
15:02trmswI'm using clojure-1.1.0 and clojure-contrib-1.1.0-RC1
15:03cemerickrhickey: yeah, that's what I've done already, I was just wondering re: count
15:03rhickeybound? == hasRoot(), thread-bound? == getThreadBinding() != null
15:03rhickeycemerick: count allows Var to check an Atom prior to incurring the overhead of getting the thread local
15:03rhickeyif count is 0, no thread has a local binding
15:04chouserwhat is isBound()
15:04rhickeychouser: bound either way
15:04chouserbound only at the most recently level of 'binding'?
15:04chouseroh, || hm..
15:05rhickeyand maybe what bound? should map to
15:05rhickeybound? means deref will work, thread-bound? means set! will work
15:07rhickeystuartsierra: to your point before, breaking changes in timely releases will put more pressure for patches for prior releases. We didn't get any for 1.0
15:08stuartsierrayes
15:08technomancywhat's the easiest way to pad a string with a character if it's less than a given length? is there a built-in or contrib function for that?
15:09stuartsierra,(format "%10s" :foo)
15:09clojurebot" :foo"
15:09rhickeypoll, when fns get metadata - where do you want to put it?
15:10hiredmanon mars
15:10rhickeyhiredman: ?
15:10technomancystuartsierra: any way to do it with a character other than space?
15:11hiredmanrhickey: sorry
15:11stuartsierrarhickey: before argument list, (fn {metadata} [x] ...)
15:11rhickeystuartsierra: won't that be confusing with multiple arity?
15:11rhickeysince won't be per-arity
15:11chouserafter the 'fn'
15:12stuartsierraactually, I have no idea
15:12rhickeychouser: and if there's a name?
15:12chouserso, before the name if any
15:12chouserbefore the arg vector if only one, and before the list of arities
15:12chouserexcept
15:13chouserthat's the same "place" as var metadata on defns. :-/
15:13stuartsierraThe only time it matters is in defn, where there's confusion with Var metadata. Anywhere else we have #^
15:13rhickeyso, this is still code as data
15:13hiredmanstuartsierra: #^ has to expand into something
15:14stuartsierrahiredman: yes, but #^{...} (fn ...) could set metadata on the fn
15:14stuartsierra(def #^{...var metadata...} symbol #^{...fn metadata...} (fn ...))
15:15hiredmanstuartsierra: but #^ is a reader macro
15:15hiredmanahem
15:15hiredmanright
15:16stuartsierrahiredman: oh, right. (with-meta {...} (fn ...)) then
15:16stuartsierraBut (fn...) is a special form, so I suppose it could accept read-time metadata too.
15:17rhickeyfn is a macro
15:17rhickeyfn* is special
15:17stuartsierraoh
15:18rhickeybut the fn form can certainly take metadata on the form, once macros can get their forms
15:18chouserwe're not talking about fns support with-meta, are we?
15:18rhickeychouser: possiblty
15:19rhickeywhich argues for simple #^{:a 1} (fn []...)
15:20stuartsierraI actually prefer #^ to having metadata in a different place for different macros (defn, fn, def, ...)
15:20stuartsierraBut people will complain that it's ugly.
15:20chouser^{:a 1} (fn [] ...) :-)
15:21stuartsierrachouser: yes, I like that
15:21arohnerwhy do does the "defn metadata" need to go on the var once fns have metadata?
15:22rhickeyarohner: backwards compatibility?
15:22stuartsierraarohner: {:private true} for one, and people may still have use for Var metadata
15:22stuartsierraWould fn metdata include :pre/:post conditions?
15:23arohnerah right, thanks
15:23chousersome var metadata is used for non-fn values that don't themselves support metadata. docstring on *print-length*
15:23technomancyif IMeta is implemented in terms of protocols, does that mean we'll be able to add metadata to instances of final classes?
15:23chousertechnomancy: where would the metadata be stored?
15:24rhickeystuartsierra: yes
15:24rhickeytechnomancy: no
15:24technomancychouser: in... a metadata store? I hadn't really thought it through. =)
15:25stuartsierratechnomancy: it might be possible, but still inadvisable
15:25technomancystuartsierra: how so?
15:26hiredman:D
15:26stuartsierraWell, if IMeta is a protocol, there's nothing stopping you from extending it for any class, stashing the metadata in a weak hash map or something.
15:26rhickeythe contract of with-meta is: the same value, with metadata. You can't superimpose that on a final class
15:27rhickeyif you pretend (via an external map), you will have a performance, GC, and concurrency nightmare
15:27stuartsierrarhickey: Yes, that's why I said inadvisable. ;)
15:27technomancygotcha
15:27rhickeynevermind a problem with identity
15:28rhickeystuartsierra: you mean insoluble?
15:28technomancyhow about IFn on java.util.regex.Patterns then?
15:29stuartsierrarhickey: Insoluble to do it correctly. Hence, inadvisable to try it.
15:29rhickeytechnomancy: needs a wrapper
15:29rhickeystuartsierra: ok than :)
15:29rhickeythen
15:29stuartsierraComp. Sci. needs a word for that: "you can't do this correctly, so don't do it at all."
15:30technomancywell shucks, I'm going to have to find another 1.2-specific to get excited about then.
15:30stuartsierratechnomancy: deftype! locals-clearing!
15:31technomancyoh yeah, locals-clearing is awesome. it's just easy to forget about. =)
15:31rhickeydefprotocol, improved agent erros, direct binding
15:31stuartsierradirect binding!!!
15:31rhickeymetadata on fns, form and locals in macros
15:31technomancyI just don't have any use in mind for protocols off the top of my head anymore
15:32rhickeydirect binding is on right now in master, for clojure.*
15:32technomancyI'm sure I'll be able to think of something. =)
15:32hiredmancinc!
15:32rhickeyhiredman: not 1.2
15:32stuartsierraWhile we're on the subject, what do you say to publicly giving a target date and feature set for 1.2?
15:33technomancyisn't the feature set already fairly clear?
15:34stuartsierraI mean make it public, put a roadmap on the web.
15:34hiredmanrhickey: sure
15:34stuartsierraWith a due date.
15:34rhickeystuartsierra: most of the heavy lifting is already done. A bunch of things need some experience-based feedback. I'm not 100% in love with how map support works in deftype, we need to decide what the knobs are for direct binding, people need to try the new aagent error system...
15:34hiredmanbut that is a use for protocols
15:34stuartsierraI was thinking, if people could see what new features are coming out, and when, they would be more motivated to test.
15:35stuartsierraNot a due date per se, but a planned date. Like Ubuntu releases.
15:35rhickeystuartsierra: I think the current system is working ok, I just got too far ahead of the releases. But that means 1.2 will come much sooner than 1.1 did
15:36rhickeystuartsierra: rather than a date, I'd prefer to scope it by features. When all the features are in, then it's a matter of testing and ship
15:37stuartsierrarhickey: ok, it's your show, after all.
15:37rhickeyplus any bug fixes that make it in the meantime
15:37rhickeyall programmers do with dates is miss them
15:38rhickeystuartsierra: but I agree, fewer features per release, more frequent releases
15:38stuartsierrarhickey: that's good, that's the important part
15:39rhickeyone problem with that is insufficient feedback time, so more things might be labeled alpha
15:40technomancyprotocols aren't magic fairy dust that suddenly give me all the features I want. =)
15:40stuartsierraA description of which milestone to assign tickets to would help.
15:44rhickeystuartsierra: everything should go into backlog - I'll move them
15:44hiredmantechnomancy: http://clojure.org/rationale is still good, a functional lisp, nice datastructures, jvm libraries, the rest is just details, nothing to get too excited about
15:44stuartsierrarhickey: might be worth mentioning on http://clojure.org/patches
15:45rhickeyso, when can we move to ^{:lean :metadata} foo
15:45rhickeystuartsierra: backlog is the default
15:46stuartsierrarhickey: ok, I was just moving some old tickets from "no milestone" to backlog
15:46hiredmanis ^ still going to be pre form? just #^ without the #
15:48rhickeystuartsierra: I need to check, but I think they might have preceded setting up the default. I added a note to http://clojure.org/patches
15:48stuartsierracool, sounds good
15:49rhickeyhiredman: yes, just #^ without the #
15:52ecyrbCould someone point me to an example of using "{#^:static true}" to declare a static method in gen-class?
15:53hiredmanecyrb: completely wrong
15:53hiredman#^ is a reader macro for attaching metadata to the following form
15:54hiredmanso {#^:static true} tries to attach :static as metadata on true
15:54hiredmanwhich is nonsense
15:54rhickeyecyrb: looks like you've got a typo there
15:54rhickeyshould be #^{:static true}
15:54hiredman#^{:static true} goes before the vector specifing the method
15:54ecyrbAh. #^{:static true}
15:55cemerickrhickey: I got a little fancy with bound? and thread-bound? Figured they'd be used more commonly in literal form than in conjunction with map, etc. http://github.com/cemerick/clojure/commit/d270aae483c804c219b30cc2e5a93a764f739215 I'll put a patch on a ticket if that's what you had in mind.
15:56ecyrbThanks guys.
15:56rhickeycemerick: I think they should be ordinary functions
15:57rhickey?
15:58cemerickrhickey: I wouldn't have expected that, but OK. Trying to be explicit about vars?
15:59rhickeycemerick: well, there's the don't make macros that don't need to be macros...
16:01rhickeyheritage is: http://www.lispworks.com/documentation/HyperSpec/Body/f_boundp.htm
16:07cemerickrhickey: ok, done. I left them with rest args, though -- it's too easy to do (thread-bound? #'a #'b #'c) rather than (every? thread-bound? ...)
16:09rhickeycemerick: cool, thanks!
16:10LauJensenAnybody have some hints as to which Java classes would be appropriate for writing a proxy ?
16:13chousermy favorite is clojure.lang.IDeref :-)
16:14hiredmanI think he must have meant an http proxy
16:14chouseroh
16:14chouserheh
16:14LauJensenThats right :)
16:18chouserit doesn't seem quite right that queues print looking like lists
16:19rhickeychouser: what queues?
16:19chouserPersistentQueues
16:19rhickeyoh, those
16:19chouserwe're documenting them
16:19chouser:-)
16:20rhickeyare people using them?
16:20chousersure we are
16:21_fogus_They will once they read our great section. :-p
16:21chousernot a lot, but when you need a queue, that's what you need.
16:21chouserwhen people don't use a queue the do horrible things to vectors instead.
16:22chouserI saw that in the wild -- shoot, where's that link...
16:22LauJensenbestinclass.dk ? :)
16:23_fogus_I propose printing them as <(1 2 3)<
16:23rhickeyany proposals for an api, printed representation, tests etc?
16:23hiredman_fogus_: :|
16:23hiredmandancing queues
16:23_fogus_fish queues
16:23hiredman<()< >()>
16:23rhickeyI've always been concerned about people not understanding how to use them and getting confused vs. imperative queues, which we still need to support
16:24chouserthe api is fine as-is, maybe add a 'queue' factory fn. printed is rarish, I would be ok with #=(queue a b c)
16:24rhickeyand when we have an api for I/O queues?
16:25chouserLauJensen: nah, I think it was rosetta stone something, though I can't find it now.
16:26chouserwow there's a lot there: http://rosettacode.org/wiki/Category:Clojure
16:27cemerickrhickey: this your cue for a generalized queue interface ;-)
16:27rhickeycemerick: but it won't unify persistent and I/O queues
16:27chousercall it persistent-queue for now. *shrug*
16:28cemerickrhickey: I'm all about the tangents today.
16:28chouserah, there it is: http://rosettacode.org/wiki/FIFO#Clojure
16:29LauJensenhehe
16:29_fogus_chouser: Sounds like you just volunteered to fix that. ;)
16:29chousersomeone didn't know about PersistentQueue and wrote one on vectors that leaks every item inserted.
16:29chouser_fogus_: I *was* going to educate the world about not doing that instead, but then you went and did it.
16:39stuartsierrarhickey: want to celebrate 1.1 at LispNYC tonight?
16:40stuartsierra(and anyone else, come on down)
16:40stuartsierraTonight at 7, P&G's, 380 Columbus Ave.
16:42stuartsierraBe there, or be parenthetical.
16:43duncanmis deftype not in clojure 1.1?
16:44chouserduncanm: nope, in "master", slated for 1.2
16:53LauJensen(apply str (mapcat #(map char %) (concat [(map inc [70 110 110 99 109 104]) (reverse '(33 116 104 103))])))
17:02ninjuddis there any way to tell what type a struct object is?
17:02hiredmantype?
17:02kotarakninjudd: IPersistentMap
17:02ninjuddwhat type of struct
17:03chouserthat's not really a type, it's more like which constructor you used.
17:03chouseror in other words, no you can't.
17:03kotarakninjudd: you have to attach such information in the metadata
17:04kotarak,(let [s (create-struct :a :b)] (type (with-meta (struct s 1 2) {:type ::MyType})))
17:04clojurebot:sandbox/MyType
17:04kotarakninjudd: structs don't have necessarily a name.
17:04kotarakninjudd: what you probably want is defstruct from master
17:04ninjuddkotarak: i see, that makes sense
17:05ninjuddkotarak: does that add the metadata automatically?
17:05kotarakninjudd: no. you have to do it manually with with-meta
17:05ninjuddok
17:06kotarak(defn my-type [x y] (with-meta (struct my-type-struct x y) {:type ::MyType}))
17:06kotaraksomething like that
17:06ninjuddthere isn't a struct? method either...
17:07ninjuddreally, in this case, i just need to know if the type is PersistentStructMap
17:07kotarakninjudd: let's try it the other way around: what are you trying to do?
17:08kotarakMaybe there is a different solution?
17:09ninjuddkotarak: i'm writing a method that i want to vary its behavior depending on whether a struct is passed in
17:09chouser(instance? clojure.lang.PersistentStructMap x)
17:10ninjuddkotarak: more specifically, i want to override the behavior of print for a specific struct type
17:10kotarakninjudd: (defmethod print-method ::MyType ...)
17:11ninjuddkotarak: so i really need to make a new class in Java then?
17:11kotarakninjudd: no. you have to attach metadata with type info
17:11kotarakninjudd: print-method dispatches on type which checks for :type in the metadata
17:11ninjuddkotarak: oh, right
17:12ninjuddkotarak: ok, thanks
17:12kotarakninjudd: checking on PersistentStructMap would change the behaviour for *all* struct maps, not just your type.
17:12kotarakninjudd: np
17:13ninjuddchouser: thanks, i knew there must be some way to check the type. i'm coming from ruby, so i was looking for something like is_a? or kind_of?
17:14ninjuddclass rather
17:14kotarakninjudd: you'll find types pretty much uninteresting in Clojure, in general.
17:14kotarakA lot works by abstractions
17:18technomancysame as in Ruby actually, if you're using is_a? much something is probably wrong
17:19ninjuddtechnomancy: i'm not, i just didn't know how to do it
17:20technomancyspeaking of which, I can't be the only person who gets confused about the fact that isa? and instance? have their arguments in opposite order, can I?
17:20technomancynot to mention trying to use isa? to check if an object is an instance of a class?
17:22wiligGetting very strange error from slime when trying to use clojure.contrib.sql. I get "No matching method found: println for class swank.util.io.proxy$java.io.StringWriter$0" Any pointers?
18:08arohnertechnomancy: IIRC, you can blow your permgen in some cases just by creating too many anonymous functions
18:08arohnerit has to do with the JVM GC'ing classes
18:08arohnerthe JVM doesn't GC classes unless their owning classloader is GC'd (I think)
18:09technomancyfrom what I understand closures are generated with their own classloader for precisely this reason
18:09arohneryes. A lot of clojure creates new classloaders and lets them be GC'd for exactly this
18:10arohnerbut it wouldn't surprise me if it were possible to create a situation where your fn isn't GC'd
18:11technomancyit's odd that it would happen without being accompanied by a regular memory leak though
18:11technomancyso it's mostly just use of eval and anonymous fns that cause runtime class generation, right?
18:14arohnerI can't think of any others off the top of my head
18:14arohneraside from silly stuff like deftype in a loop
18:15arohnerproxy and friends create classes
18:18technomancyoh, good point. I'll have to check that too
18:26the-kennyAnyone who can recommend me a good elisp tutorial?
18:27trmswyou're familiar with lisp?
18:27the-kennytrmsw: Of course
18:28the-kennytrmsw: Common Lisp and Clojure, to be precise
18:28technomancythe-kenny: just forget everything you've learned in Clojure about FP and data structures that are convenient to use and you should be in good shape. =\
18:28the-kennyMaybe "Tutorial" isn't the right word. I'm searching for something like an introduction to programming Emacs
18:28technomancyin other words, Common Lisp should be a great introduction. =)
18:29the-kennytechnomancy: Sounds like.. Common Lisp
18:29the-kenny:D
18:29technomancythe-kenny: have you checked the one in M-x info? it's not bad.
18:30trmswit's probably better than any tutorial that tries to teach you lisp into the bargain
18:30technomancygenerally M-x apropos and the describe-* commands are your friends when exploring the actual APIs
18:30the-kennytechnomancy: I always forget the built-in stuff in Emacs.. I'll look at it
18:33trmswthe-kenny: somewhere there is a book on how to write Emacs modes, can't find it but I remember reading it...
18:41mtmyou're probably thinking of "Writing GNU Emacs Extensions" http://oreilly.com/catalog/9781565922617/
19:22mebaran151how do you print out slime's classpath?
19:23sethsmebaran151: not sure, but it might be using the contents of $HOME/.clojure
19:23sethsprobably more swank than slime, swank is the server side of slime
19:24mebaran151no I'm pretty sure it's getting my classpath
19:24mebaran151I just want to print it out to see what jars it's getting
19:24sethswait there was a post on the Clojure Google group recently
19:24sethschecking...
19:24mebaran151I launched it with swank-clojure-project
19:24sethsoh
19:25sethsthat method asks for a base dir, and I *think* includes the contents of the lib directory
19:26sethsthat's how I run a repl from the new branch, since lein repl uses its internal version of clojure
19:28technomancy,(System/getProperty "java.class.path")
19:28clojurebotjava.security.AccessControlException: access denied (java.util.PropertyPermission java.class.path read)
19:28technomancyshould work outside the sandbox
19:28technomancywon't work with lein swank though
19:29mebaran151no magic swank vars
19:38mebaran151cool that worked, thanks technomancy
19:38mebaran151if I had a running project, say a server, I wanted to be able to patch on the fly, could I use swank to remote connect to it?
19:38crazzyfordtechno I worked up an elisp function that works with my project layout to run tests from implimentation files
19:41lisppaste8crazzyford pasted "test" at http://paste.lisp.org/display/93316
19:41crazzyfordsomething like that
19:42sethstechnomancy: the .gitignore from lein new FOO could use a "FOO-standalone.jar" line
19:49technomancycrazzyford: what about a command instead that just toggles between implementation and test?
19:49technomancythen you could build a "run tests for this ns" command in terms of that?
19:49technomancyseths: great idea, let's see a patch. =)
19:49crazzyfordthis seemed faster
19:49crazzyfordfor refactoring stuff at least
19:50crazzyfordmove stuff around, run some tests, move more stuff around, run some tests
19:50technomancysure; I'm just saying they're both useful
19:50crazzyfordaye aye capn
19:50technomancyand one could be implemented using the other
19:51crazzyfordeventually will have a "get buffer for this implementation file"
19:51crazzyfordand then can easily switch/run tests on said buffer
19:51crazzyfordthe only thing that bothers me about clojure-test-mode atm is changing the color of output based on tests passing/failing
19:53crazzyfordI looked into it some, but it looks like the way to change face of the minibuffer is using a minibuffer hook
19:55technomancychanging the color of the message in the minibuffer? hrm. don't know if you can do that, but it'd be great if you could.
19:56crazzyfordif not might be able to flash the modeline green/red
19:56crazzyfordmaybe
19:56crazzyfordminibuffer stuff looks difficult
20:01crazzyfordido does it, so must be possible in some way
20:03crazzyfordaha (I think)
20:04crazzyfordlooks like you can use put-text-property inside the minibuffer
20:05dnolentechnomancy: how can I get lein swank to use clojure new? does it just use the clojure inside leiningen/lib by default?
20:05hiredmannew was merged into master
20:06dnolenhiredman: yes I saw that, but even so that's not the one that lein pulls down, so question is still the same :)
20:07hiredmanI imagine if you change the version in your project.clj it will pull down what you ask for
20:07qbgIf I have a symbol, how do I find the metadata that was associated with it when it was def'ed?
20:08hiredmandef attaches metadata to the var, not the symbol
20:08sethsdnolen: swank looks inside $HOME/.clojure which leiningen does not use
20:09sethsI wrote a tool to update ~/.m2 and ~/.clojure with different versions of Clojure/Contrib
20:09sethshttp://bitbucket.org/seths/clojuggle/src/
20:09technomancydnolen: it should use the version of clojure inside your project's lib/ directory
20:09sethsmay or may not solve the problem tho
20:10dnolentechnomancy: hmm doesn't seem to be doing that, i have clojure-new there.
20:10sethsto clarify: when using M-x slime
20:10technomancyleiningen will run in leiningen's version of clojure, and your project will run in its own
20:10dnolentechnomancy: do I need to build the lein-swank jar with clojure-new
20:10dnolen?
20:10technomancydnolen: the one place that doesn't apply yet is lein repl
20:11technomancydnolen: if you build lein-swank with the latest leiningen it doesn't matter since no AOT is done
20:11dnolentechnomancy: I am using lein from source
20:12technomancydnolen: how are you checking the clojure version
20:12technomancy?
20:12dnolener, not scientifically that for sure. deftype isn't available :)
20:13technomancyI mean, lein swank + M-x slime connect, running the test suite, lein repl, etc.
20:13dnolentechnomancy: I switch to the project dir, lein swank, connect from Emacs
20:13hiredman,*clojure-version*
20:13clojurebot{:interim true, :major 1, :minor 1, :incremental 0, :qualifier "alpha"}
20:13technomancydnolen: sounds like a bug; could you post to the lein mailing list?
20:14dnolentechnomancy: sure
21:07I314159is there a mod operator in clojure?
21:07mitchellhI314159: rem
21:07mitchellh,(doc rem)
21:07clojurebot"([num div]); remainder of dividing numerator by denominator."
21:08markgunnelsIf I wanted to use deftype and defprotocol, what should I point my leiningen dependencies to?
21:09dnolenmarkgunnels: something like, :dependencies [[org.clojure/clojure "1.1.0-new-SNAPSHOT"]]
21:09markgunnelsdnolen: thanks.
21:09I314159ahh - thx
21:10dnolennp
21:10markgunnelsdnolen: tried that and then ran lein repl and it greets me with:
21:11markgunnelsClojure 1.1.0-master-SNAPSHOT
21:11markgunnelsuser=> (doc deftype)
21:11markgunnelsjava.lang.Exception: Unable to resolve var: deftype in this context (NO_SOURCE_FILE:1)
21:11dnolenmarkgunnels: that might be related to an bug that I've just posted on the list
21:11dnolendo you see clojure new in your project lib folder?
21:11markgunnelsdnolen: Yes.
21:11dnolenmarkgunnels: yes probably a bug.
21:12markgunnelsdnolen: K. Suspected I was just being dense with this. Statistically more likely. :-)
21:12sethsdnolen: not a bug
21:12sethslein repl uses the built in version clojure, not what's in lib
21:12sethsit's a known issue
21:13sethsyour code in the src folder can still use deftype and defprotocol
21:13dnolenah so well missing feature than that people seem to expect :)
21:13markgunnelsseths: Ok. Thanks.
21:13sethsagreed!
21:14sethsmarkgunnels: if you are using emacs, try swank-clojure-project to get a repl with the contents of the lib/ directory
21:14markgunnelsseths: I am. That was actually what I was just trying...:-)
21:17markgunnelsseths: is there a special swank dev-dependency I need with the new branch?
21:18markgunnels#<CompilerException java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V (pprint.clj:1)>
21:18markgunnelsMake sure swank-clojure is added as a dev-dependency in your project.clj.
21:19markgunnelsseths: I may have misunderstood your earlier statement.
21:20sethsmarkgunnels: not sure, let me check
21:20sethsbtw I am just a happy user of lein, not part of the project
21:21markgunnelsseths: I am a VERY happy user of lein.
21:21markgunnelsseths: It's very nice. Thanks for your help.
21:24timothypratley,(doc mod)
21:24clojurebot"([num div]); Modulus of num and div. Truncates toward negative infinity."
21:24markgunnelsseths: Don't spend too much time on it. I'll just write a little script to launch it outside of leiningen.
21:25markgunnelsseths: Thanks again for your help.
21:28sethsmarkgunnels: happy to help!
21:29sethsmarkgunnels: I am able to use defprotocol from swank-clojure-project
21:29sethswith this in my project.clj
21:30seths :dependencies [[org.clojure/clojure "1.1.0-new-SNAPSHOT"]
21:30seths [org.clojure/clojure-contrib "1.1.0-new-SNAPSHOT"]]
21:30seths
21:30seths :dev-dependencies [[lein-clojars "0.5.0-SNAPSHOT"]
21:30seths [leiningen/lein-swank "1.0.0-SNAPSHOT"]]
21:44gstampcurses. monad tutorial part 2 is down. http://onclojure.com/2009/03/06/a-monad-tutorial-for-clojure-programmers-part-2/
21:44gstampgoogle cache to the rescue
23:36defn`in the ns macro is it correct to do [:use (foo bar baz)] where bar and baz are foo.bar and foo.baz?
23:39ts00000is there a reason why (re-find #"(.*\b(\r))+") wouldn't work?
23:40ts00000sorry, (re-find #"(.*\b(\r))+" x)
23:40defn`you have a " in the wrong spot?
23:40defn`oops nvm
23:40ts00000my bad :)
23:40chouserdefn`: you need round-parens around :use, not brackets
23:40ts00000is there something awkward with the backref syntax or something
23:40defn`chouser: do i then need to quote my namespaces below it
23:41defn`[:use clojure.set (base ext1 ext2)]
23:41chouserdefn`: I don't understand. But something like (ns foo (:use (clojure.contrib repl-utils seq-utils))) works
23:41defn`chouser: right but what about (:use (clojure core contrib set))
23:42defn`oh nvm didnt read all of it
23:42defn`thank you
23:42chouser,(re-find #"(.*\b(\r))+" "hi\r")
23:42clojurebot["hi\r" "hi\r" "\r"]
23:43chouserts00000: what's the problem?
23:43chouserdefn`: but not core or contrib. core comes in automatically with 'ns', and contrib is not itself a namespace.
23:44defn`sure just an example
23:44chouserok
23:44ts00000chouser: what I want is a block to be used in a second regex. see http://pastie.org/776064
23:44defn`chouser, i take it the same thing is true for :require and :import
23:44ts00000I want one match to contain the first block before the newline, and the second to contain the second block
23:45chouserdefn`: :require is almost identical to :use. :import is something else, though it does allow similar lists for class packages/names
23:45defn`but as far as syntax, i should be doing (:import (com.petebevin.markdown MarkdownProcessor))
23:45defn`and not [:import...]
23:45chouserdefn`: yes
23:45defn`cool, thank you
23:47chouserts00000: you're trying to break that input at the blank line?
23:47ts00000chouser: yeah, ostensibly I have a long "data packet" that consists of a lot of these sections, not all of them evenly formatted, but i'm trying to iterate closer and closer to my ideal solution; problem is clojure doesn't seem to want to provide me a match for the expression I described
23:48ts00000when I run my function designed to give me this, it just returns nil
23:48ts00000but things like (.*) do what I expect
23:48chouserthat regex appears to just be searching for a <CR> in the input
23:49ts00000http://pastie.org/776071 is a "real" example of what I want
23:49ts00000where x is the true input
23:50ts00000and yes, what I want is to search for a <CR>, and give me the match up to the <CR>
23:50chousera single regex will return a fixed number of matches. You may want something like re-seq instead of re-find, so that you can get multiple results
23:50ts00000even with re-seq, I get no matches
23:50chouserts00000: are you on a platform that uses \r for line endings rather than \n
23:52ts00000chouser: moving to \n does some things right, but not exactly what I expect; why do I get three elements in the sequence rather than two
23:52ts00000I would think that the first element is the real text, and the second element is the parsed text; is the third element the backref?
23:52chouserwhat do you mean by "backref"?
23:53ts00000backreference
23:53ts00000in the regular expression
23:53ts00000to be used during the match
23:53chouserre-find returns a vector of n things where n is the number of groups in the regex plus one
23:53chouserthe first is the whole match, the second your (.* ...)+ group, and the third your (\r) group
23:54chouserI think you might want something more like: (re-seq #"(?s).+?(?:\n\n|$)" x)
23:55ts00000yup cho, you got it. thank you
23:55ts00000working through regular expressions for the first time
23:55ts00000is the oreilly book best for gaining clue rapidly?
23:55chouserah! well, good luck to you. It's a challenging and rewarding subject. :-)
23:56chousercouldn't say, sorry.
23:56chouserI don't think your regex had any backrefs in it. were you thinking of the \b part or something else?
23:58ts00000the \b part
23:59chouserin a java regex, anyway, that matches a word boundary.
23:59chouserso, not a backreference