2010-01-12
| 00:01 | G0SUB | ctdean: which version of log4j should I use? 1.3 is obsolete, 2.0 is experimental |
| 00:02 | ctdean | G0SUB: I'm using log4j-1.2.14.jar, no idea if that's a good one |
| 00:02 | mebaran151 | defn, I've built, but it wants a program called makeinfo |
| 00:02 | mebaran151 | why can't stallman use manpages like the rest of us |
| 00:05 | Licenser_ | hmmm functional chimney: (reduce #(burn %) '(wood wood wood wood)) |
| 00:06 | somnium | Licenser_: isn't the smoke and heat side-effecty? |
| 00:06 | Licenser_ | na we just reduce the wood to ashes |
| 00:07 | Raynes | defn: You know you can get Emacs 23 from the Ubuntu repos as far back as Hardy, right? |
| 00:07 | Raynes | emacs-gtk-snapshot |
| 00:07 | Licenser_ | but somnium you're right |
| 00:08 | G0SUB | ctdean: the log file path, does it need to be absolute? |
| 00:08 | Licenser_ | so lets say: (defn burn [stuff] '(heat ashes smoke)) |
| 00:08 | ctdean | G0SUB: I don't think so |
| 00:08 | somnium | Licenser_: hmm, you may be on to something |
| 00:09 | Licenser_ | yap |
| 00:10 | arohner | hmm, I want a get-in that also does derefs as appropriate... |
| 00:10 | arohner | (get-in* foo [:a :b @ :c]) |
| 00:10 | arohner | of course, writing that, I want an update-in that does the same thing |
| 00:11 | arohner | nm, that doesn't make as much sense |
| 00:11 | hiredman | get-in is called -> |
| 00:11 | arohner | hiredman: good point |
| 00:11 | hiredman | ,(-> foo :a :b deref :c) |
| 00:11 | clojurebot | java.lang.Exception: Unable to resolve symbol: foo in this context |
| 00:12 | somnium | are any of the -$> variants in contrib? |
| 00:12 | hiredman | making update-in work on mutable structures and immutable structures would be tricky |
| 00:12 | hiredman | ,(doc -?>) |
| 00:12 | clojurebot | "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:13 | somnium | ah! |
| 00:13 | somnium | hmm |
| 00:13 | arohner | yeah, I realized I don't need [:a :b deref :c] on update-in |
| 00:14 | arohner | I wish those things had canonical names |
| 00:14 | arohner | i.e. thread-maybe |
| 00:14 | arohner | I don't want perlisms in my clojure |
| 00:14 | somnium | I meant the ones that move the argument |
| 00:14 | arohner | there's ->> |
| 00:14 | hiredman | oh, the icky templating stuff? |
| 00:14 | hiredman | *shrug* |
| 00:14 | somnium | Ive been using an anti-> for doing (-> x (range) (>> map inc)) |
| 00:15 | Licenser_ | somnium: http://gist.github.com/274938 |
| 00:15 | somnium | => (->> (-> x range) (map inc)) |
| 00:15 | somnium | but its kind of silly |
| 00:15 | mebaran151 | alright, I think I got emacs installed |
| 00:15 | hiredman | add a doto in there |
| 00:15 | mebaran151 | and I can get slime |
| 00:15 | mebaran151 | now how do I get all the goodies |
| 00:16 | hiredman | ,(doto :a (-> prn)) |
| 00:16 | clojurebot | :a |
| 00:16 | clojurebot | :a |
| 00:17 | hiredman | (doto X (-> ((partial juxt #(.write % stuff) #(.close %))))) |
| 00:18 | hiredman | of course you could just (doto X (.write stuff) .close) |
| 00:20 | mebaran151 | like the infamous paredit etc |
| 00:20 | somnium | hiredman: doto in place of >> / -$> ? |
| 00:20 | hiredman | aslong as you are using -> and ->> you might as well also use doto |
| 00:20 | somnium | Licenser: =) |
| 00:21 | somnium | hiredman: (-> 10 range (>> map inc) (nth 5)) with doto? |
| 00:27 | mebaran151 | rainbow parens etc |
| 00:27 | somnium | mebaran151: emacs-starter-kit has some good stuff, incluing elpa |
| 00:28 | mebaran151 | I've got elpa |
| 00:28 | hiredman | there is a rainbox-paren-mode out there |
| 00:28 | mebaran151 | I've got highlight parens now |
| 00:29 | somnium | mebaran151: otherwise just start collecting .el files in your .emacs :) |
| 00:30 | mebaran151 | alright |
| 00:30 | mebaran151 | so now I want to setup something like I had in netbeans |
| 00:30 | mebaran151 | where I would load the contents of a current file and smack it at the repl |
| 00:30 | hiredman | http://delicious.com/search?p=rainbow&chk=&context=userposts|clojurebot&fr=del_icio_us&lc=0 |
| 00:32 | mebaran151 | I've got parens |
| 00:36 | mebaran151 | where's a good guide to swank. like resetting the repl, etc |
| 00:37 | mebaran151 | loading the current file in repl etc |
| 00:40 | somnium | mebaran151: you can install everything from elpa |
| 00:45 | mebaran151 | will it autoload |
| 00:46 | mebaran151 | like let's say I always want highlight-parens-mode when I'm editing a clojure file,how would I do this? |
| 00:50 | Raynes | There is a rainbow paren mode? Holy shit. |
| 00:50 | Raynes | I want. |
| 00:51 | somnium | mebaran151: 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:53 | mebaran151 | so everytime I open a clojure file I have to M-x highlight-parentheses? |
| 00:53 | somnium | mebaran151: oops, its not global. std way is (add-hook 'clojure-mode-hook 'highlight-parentheses-mode) but may be an option in customize too |
| 00:56 | mebaran151 | where do I write this? |
| 00:57 | Raynes | mebaran151: .emacs |
| 00:57 | Raynes | ~/.emacs |
| 00:57 | clojurebot | emacs is best configured for Clojure with instructions at http://technomancy.us/126 |
| 00:58 | Raynes | The hell with Phil and his canonical instructions. |
| 00:58 | Raynes | ! |
| 00:58 | Raynes | :> |
| 00:59 | mebaran151 | alright let's try this |
| 00:59 | mebaran151 | how do I switch to the slime buffer |
| 01:00 | G0SUB | people, 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:00 | somnium | M-x slime |
| 01:00 | Raynes | mebaran151: 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:02 | Raynes | mebaran151: Also, checkout http://www.emacswiki.org/emacs/InteractivelyDoThings |
| 01:02 | Raynes | check out* |
| 01:02 | Raynes | Quite useful. |
| 01:04 | G0SUB | OK, I figured what the problem was. c.c.logging uses java logging even when I have log4j in the classpath |
| 01:04 | hiredman | sure |
| 01:04 | mebaran151 | so I want to duplicate this work process |
| 01:04 | G0SUB | if I call (log4j-logging) it works fine. |
| 01:04 | hiredman | logging decides which logging system to use at compile time |
| 01:04 | mebaran151 | in Netbeans, I'd type ctrl-shift-n to switch to the name space I'm working in |
| 01:05 | mebaran151 | then I'd type alt-l to load the file |
| 01:05 | mebaran151 | then I'd whack at it in the repl |
| 01:06 | Raynes | Switch 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:07 | somnium | compile wont work without the classpath setup |
| 01:07 | Raynes | ^ |
| 01:08 | somnium | http://github.com/technomancy/swank-clojure |
| 01:10 | mebaran151 | I've got swank clojure up and running |
| 01:10 | mebaran151 | can I get autocomplete |
| 01:10 | mebaran151 | so ns woudl complete my namespace |
| 01:11 | optimizer | is there something like sqlite, but for clojure? |
| 01:11 | mebaran151 | optimizer, derby? |
| 01:11 | mebaran151 | hypersonic sql |
| 01:12 | optimizer | mebaran151: nice; thanks |
| 01:33 | mebaran151 | so how would I get this setup |
| 01:33 | mebaran151 | I want three or four buffers |
| 01:33 | mebaran151 | one to list directories and files to switch between |
| 01:33 | mebaran151 | one as the main editor |
| 01:34 | mebaran151 | one as my project repl |
| 01:34 | mebaran151 | and maybe one where I could get java and clojure docs |
| 01:35 | Raynes | mebaran151: Also, C-x 3-C-x o-C-x 2 :D |
| 01:36 | Raynes | I have 3 'panes' in my set up. 2 square boxes on the right side, and a big one on the left for editing. |
| 01:37 | Raynes | I'll also note that there is an Emacs file manager. M-x dired |
| 02:09 | timothypratley | ,(.comparator (sorted-map 1 2 3 4)) |
| 02:09 | clojurebot | #< clojure.lang.RT$2@f4a444> |
| 02:10 | timothypratley | Any ideas what that is? |
| 02:12 | timothypratley | I expect it is RT.DEFAULT_COMPARATOR, but I cannot fathom why it is not an IFn |
| 02:16 | timothypratley | ah I see why - never mind I figured it out |
| 02:16 | timothypratley | a comparator need not be an IFn from java land. |
| 02:21 | Raynes | Reading about protocols. Awesome |
| 02:23 | timothypratley | Raynes: I thought you were a vim user - have you converted to emacs now? |
| 02:23 | timothypratley | (or back) |
| 02:24 | Raynes | timothypratley: I played with Vim long enough to find out that I can't work with VimClojure very well. |
| 02:24 | timothypratley | Raynes: ah - why is that? The REPL interaction, or editing preference, or project integration? |
| 02:25 | Raynes | timothypratley: Mostly the fact that I could never get it to work correctly. |
| 02:25 | Raynes | Not that that is a VimClojure problem. |
| 02:28 | timothypratley | Raynes: 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:41 | G0SUB | timothypratley: hey, need some help with c.c.logging |
| 02:42 | G0SUB | timothypratley: c.c.logging is picking up util logging even when I have log4j in classpath |
| 02:42 | G0SUB | timothypratley: it works when I call (log4j-logging) manually. |
| 03:00 | mebaran151 | thnaks Ranes |
| 03:00 | mebaran151 | *Raynes |
| 03:00 | mebaran151 | I gotta get used to buffers |
| 03:01 | Raynes | mebaran151: You're welcome. |
| 03:01 | Raynes | And either I've lost sense of time, or that was extremely delayed. :p |
| 03:03 | mebaran151 | heh, my Internet went way wonky |
| 03:03 | mebaran151 | anyway |
| 03:03 | mebaran151 | how do I open three buffers? |
| 03:03 | defn | C-x 3 |
| 03:03 | defn | C-x 2 |
| 03:04 | defn | if you want a new frame, C-x 5 2 |
| 03:04 | Raynes | I told you that a minute ago. >.> |
| 03:05 | Raynes | Well, more than a minute ago. |
| 03:05 | mebaran151 | ah |
| 03:05 | mebaran151 | that's what that did |
| 03:05 | mebaran151 | it looked arcane |
| 03:06 | mebaran151 | sorry, my internet went way wonky, packets flying and red lights flashing |
| 03:06 | mebaran151 | I'm getting swank swnak not found |
| 03:06 | mebaran151 | but it seems to work |
| 03:07 | mebaran151 | how do I get dired to open the file in a different buffer |
| 03:07 | mebaran151 | so I'd always have dired in a pane |
| 03:09 | Raynes | That's beyond me. I don't use dired. |
| 03:09 | mebaran151 | I need an emacs manual |
| 03:09 | mebaran151 | sigh |
| 03:10 | Raynes | mebaran151: http://www.gnu.org/software/emacs/manual/emacs.html |
| 03:10 | mebaran151 | a manual not written by Richard Stallman |
| 03:10 | Raynes | Hehe. |
| 03:10 | mebaran151 | who assumes that we all live in the 70's :) |
| 03:11 | Raynes | mebaran151: http://articles.techrepublic.com.com/5100-10878_11-1053058.html |
| 03:11 | somnium | mebaran151: C-x 4 d |
| 03:12 | somnium | Im starting to dig this point free stuff: http://gist.github.com/274994 |
| 03:14 | Raynes | I thought >> was in core. |
| 03:15 | hiredman | ->> |
| 03:15 | hiredman | completely different |
| 03:20 | mebaran151 | I'm beginning to remember why I wasn't a fan of emacs |
| 03:23 | timothypratley | mebaran151: why? |
| 03:24 | mebaran151 | I'd have my Netbeans setup in less than two minutes |
| 03:24 | mebaran151 | I'm trying to get a simple setup |
| 03:24 | mebaran151 | dired pointing at my project |
| 03:24 | mebaran151 | a main buffer editing a source file |
| 03:24 | mebaran151 | and a repl with my classpath |
| 03:24 | mebaran151 | I can't seem to get all these together |
| 03:24 | timothypratley | GOSUB: I'll take a closer look |
| 03:27 | Raynes | mebaran151: Emacs isn't a plug-n-play kind of thing. |
| 03:27 | mebaran151 | nope I know |
| 03:27 | mebaran151 | but I'm not sure what I'm going to get |
| 03:27 | mebaran151 | :) |
| 03:27 | mebaran151 | though I do like its parentheses highlighting a little better than Netbeans |
| 03:28 | somnium | mebaran151: do you have paredit on? |
| 03:28 | mebaran151 | I think I do |
| 03:28 | mebaran151 | I took the sign of my accidentally deleting my home dir as a sign I should learn emacs as penance |
| 03:29 | timothypratley | :) |
| 03:30 | somnium | Im not sure if paredit can keep your home-dir safe, but it may coax you out of netbeans :) |
| 03:33 | mebaran151 | oh dired might |
| 03:33 | mebaran151 | I was rm -r and there was a directly named tilde |
| 03:33 | mebaran151 | this led to certain death |
| 03:34 | mebaran151 | how do I get the repl now |
| 03:34 | mebaran151 | I've got a process |
| 03:35 | mebaran151 | how do I know if I have paredit on |
| 03:35 | timothypratley | G0SUB: 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:36 | G0SUB | timothypratley: it's a proprietary codebase, but I can create a minimal setup just for you :) |
| 03:36 | G0SUB | timothypratley: just a sec |
| 03:37 | timothypratley | GOSUB: thanks! |
| 03:39 | vy | mebaran151: In "C-h m" there should appear paredit. |
| 03:40 | mebaran151 | I don't think so |
| 03:40 | mebaran151 | how do I enable it |
| 03:41 | esj | m-x paredit-mode |
| 03:42 | mebaran151 | okay |
| 03:42 | mebaran151 | so what can I do now? |
| 03:43 | mebaran151 | I'm sorry for being such a total newb |
| 03:43 | mebaran151 | all the blogposts tell you how to setup emacs, but nobody ever tells you how to use it... |
| 03:43 | Raynes | Checkout the paredit cheatsheet. |
| 03:43 | Raynes | I have it set as my desktop background. |
| 03:44 | mebaran151 | it won't let me type a parens... |
| 03:44 | mebaran151 | this I feel is intentional |
| 03:45 | G0SUB | timothypratley: http://github.com/ghoseb/test-logging |
| 03:45 | Raynes | mebaran151: If you started paredit mode with open parens that need closing, you're kind of screwed. |
| 03:45 | Raynes | I think I got around that somehow before though... |
| 03:45 | G0SUB | timothypratley: even now it picks up util logging |
| 03:45 | esj | Raynes: your background ! That's fantastic. |
| 03:45 | timothypratley | GOSUB: thanks for that - I'll see what I can do with it. |
| 03:45 | Raynes | esj: It's the place where it's most accessible. :p |
| 03:46 | G0SUB | timothypratley: cool |
| 03:48 | mebaran151 | slime also is constantly telling me its polling |
| 03:48 | mebaran151 | can I disable this? |
| 03:48 | Raynes | Eh, that means Slime never opened, and it means something's wrong. |
| 03:48 | Raynes | Is there a *slime-repl clojure* buffer, or just an *inferior-lisp* buffer? |
| 03:49 | Raynes | If there is just an *inferior-lisp* buffer, you might want to paste what it says. |
| 03:53 | esj | mebaran151: you're probably in for a frustrating morning. |
| 03:53 | Licenser | hrm I have trouble to understand require and use I think ... |
| 03:53 | mebaran151 | it's an inferior lisp buffer |
| 03:54 | mebaran151 | it seems run clojure |
| 03:54 | mebaran151 | and it picks up my class path |
| 03:54 | esj | you also need a *slime-repl clojure* buffer |
| 03:54 | esj | which is where you clojure it up |
| 03:54 | Licenser | when I've two namespaces that both require a 3rd one, it should be loaded in both right? And they should not confligt? |
| 03:54 | mebaran151 | Polling "/tmp/slime.6498".. (Abort with `M-x slime-abort-connection'.) [1147 times]Cancelled connection attempt. |
| 03:55 | esj | mebaran: Raynes is correct |
| 03:55 | Licenser | mebaran151: your problem is likely that slime does not find the clojar jars |
| 03:55 | mebaran151 | alright |
| 03:55 | Licenser | wait a second I dig something up |
| 03:55 | mebaran151 | let's have slime find them! |
| 03:56 | esj | mebaran151: 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:56 | Licenser | you've to adjust your .emacs file |
| 03:57 | Raynes | mebaran151: At the beginning of your inferior-lisp buffer, do you see something with RestFn<init> in it? |
| 03:57 | Licenser | http://gist.github.com/275037 <- this one did the trick for me |
| 03:57 | G0SUB | timothypratley: that's a skeleton lein project. just open a repl with that project and use c.c.logging and check the *impl-name* |
| 03:57 | G0SUB | timothypratley: if you call (log4j-logging) it will work fine. just that (or ...) form is not working correctly (don't know why). |
| 03:57 | mebaran151 | I can just start slime |
| 03:57 | mebaran151 | there's like a graphic |
| 03:58 | mebaran151 | M-x slime works |
| 03:58 | Licenser | mebaran151: I had the exact same problem this fixed it for me |
| 03:58 | Licenser | slime was working swank-clojure project not |
| 03:58 | Raynes | mebaran151: Slime is NOT working unless there is a *slime-repl clojure* buffer. |
| 03:58 | Raynes | java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V to be exact. |
| 03:58 | Licenser | what I did was getting the swank-clojure and slime from the git site and put this in my config file |
| 03:59 | mebaran151 | yep |
| 03:59 | mebaran151 | I get slime-repl clojure |
| 03:59 | mebaran151 | jsut not from my project |
| 03:59 | Raynes | Oh. |
| 03:59 | mebaran151 | I have the clojure jars in my project: is this going to cause problems |
| 04:01 | mebaran151 | does swank works with 1.1 |
| 04:01 | Licenser | yes but I had the same problem you have with the one from epal or how that thing is called |
| 04:02 | somnium | mebaran151: did you read the readme at technomancy's swank-clojure on github? |
| 04:03 | mebaran151 | oh I need the swank jar |
| 04:08 | mebaran151 | huzzah |
| 04:08 | mebaran151 | I've got slime |
| 04:09 | mebaran151 | and I got it to load a file |
| 04:09 | mebaran151 | how do I get history in the repl |
| 04:09 | Licenser | grrr |
| 04:09 | somnium | C-<up> |
| 04:11 | mebaran151 | now how do I load just one form |
| 04:11 | mebaran151 | like evaluate a def |
| 04:12 | somnium | mebaran151: slime has a lot of commands, do C-h b, to be overwhelmed |
| 04:12 | somnium | (at the repl buffer) |
| 04:12 | mebaran151 | alright |
| 04:12 | mebaran151 | a more featureful repl |
| 04:12 | Licenser | so 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:14 | somnium | Licenser: yes, why? |
| 04:14 | Licenser | because I keep getting problems like 'Alias modules already exists in namespace net.licenser.epic.modules.cycle, aliasing net.licenser.epic.modules' |
| 04:16 | somnium | Licenser: Im guessing theres more requiring going on than just a b and c? |
| 04:17 | Licenser | yea :( |
| 04:19 | timothypratley | GOSUB: 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:20 | timothypratley | GOSUB: 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:21 | somnium | Licenser: if the repl's been up for awhile it might be lingering vars |
| 04:21 | Licenser | I really get confused |
| 04:21 | timothypratley | GOSUB: Whereas when using uncompiled contrib, this behaviour would not happen |
| 04:21 | Raynes | mebaran151: C-x C-e with the cursor immediately after the last paren in the sexp you wish to eval. |
| 04:22 | Licenser | I geuss I can't require A from B and B from A? |
| 04:22 | timothypratley | GOSUB: I could be way off the mark here but I'll experiment a bit more with it. |
| 04:23 | somnium | only if you can explain how to the compiler |
| 04:23 | Licenser | teehee |
| 04:25 | Raynes | Licenser: That is a circle dependency. Those are bad. |
| 04:25 | Licenser | :( |
| 04:27 | timothypratley | GOSUB: sorry that made no sense hahaha forget what I said just then. |
| 04:28 | Licenser | can I entirely flush the repl from everything I 'tought' it? |
| 04:29 | Raynes | I believe you would have to restart it for that. |
| 04:30 | Licenser | hmm hmm |
| 04:31 | esj | on that subject is there an undef ? |
| 04:31 | esj | i couldn't find it the other day |
| 04:32 | Raynes | (doc ns-unmap) |
| 04:32 | clojurebot | "([ns sym]); Removes the mappings for the symbol from the namespace." |
| 04:32 | Raynes | Aha. |
| 04:34 | kanak | I 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:34 | Raynes | kanak: Did you also install Slime via ELPA? |
| 04:35 | fliebel | Good morning! |
| 04:35 | Raynes | Morning. |
| 04:35 | kanak | Raynes: I only installed swank-clojure from ELPA. I haven't installed slime separately |
| 04:36 | Licenser | yap flushing the repl helped |
| 04:36 | Raynes | kanak: Check to see if slime and slime-repl are installed in ELPA. |
| 04:36 | Raynes | If not, install them and try again. |
| 04:36 | esj | Raynes: hooray. That's a weird name, no ? |
| 04:36 | Raynes | esj: I didn't name it. ;) |
| 04:37 | esj | the naive might think that would be to do with the map function perhaps ;) |
| 04:37 | kanak | Raynes: It says slime 20091016 and slime-repl 20091016 are installed |
| 04:37 | Raynes | kanak: In that case, you might need to take this one to the swank-clojure mailing list. :\ |
| 04:37 | kanak | Raynes: will do. thank you for your help. |
| 04:39 | fliebel | Clojure 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:39 | Raynes | fliebel: Clojure is awesome at concurrency. |
| 04:40 | mebaran151 | but I think it's not good for the concurrency fliebel once |
| 04:40 | mebaran151 | *wants |
| 04:40 | mebaran151 | as in, it's meant to prevent those kinds of race ocnditions! |
| 04:41 | mebaran151 | fliebel, you'd probably want to use Thread/sleep with a random value to simulate differences in response time |
| 04:41 | fliebel | That is what I was struggling with. |
| 04:41 | mebaran151 | yeah you want a race condition :) |
| 04:42 | fliebel | hmhm, and I don't want to fake it, I want to make different players and test who's the best. |
| 04:42 | mebaran151 | you could use a ref to moderate which player slaps its cards first |
| 04:42 | mebaran151 | (whoever reads first wins...) |
| 04:42 | mebaran151 | and randomized sleep to simulate different reaction times |
| 04:44 | fliebel | hmmm… 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:44 | Chousuke | that's not very interesting though. |
| 04:45 | Chousuke | essentially, the winner will be decided by luck. :/ |
| 04:45 | fliebel | Chousuke: How would you do it then? |
| 04:45 | Chousuke | I don't know. |
| 04:45 | fliebel | The idea is that the winner is decided based on the most efficient way to check the cards. |
| 04:47 | fliebel | There 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:47 | Chousuke | well, if you arrow direct reads of the stack then that would be most efficient. |
| 04:47 | gregh | you could model the actual comparison operations or whatever at a higher level than just clojure code |
| 04:47 | fliebel | And, 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:48 | mebaran151 | is there anything in emacs where I can select a bunch of region of text and align the code |
| 04:49 | mebaran151 | format it based on clojure spec |
| 04:49 | Raynes | That would be nice, wouldn't it? |
| 04:50 | somnium | M-x indent-region? |
| 04:51 | Raynes | Well, there ya go. |
| 04:51 | timothypratley | GOSUB: 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:53 | mebaran151 | somnium, thanks |
| 04:53 | mebaran151 | I got emacs almost as nice as netbeans now |
| 04:53 | mebaran151 | and I can hold side by side buffers which is nice |
| 04:53 | mebaran151 | slime is a little bit more comfortable than the Netbeans repl |
| 04:53 | somnium | almost!? :/ |
| 04:55 | mebaran151 | well dired doesn't quite do what I want |
| 04:55 | mebaran151 | and I'm still scared whenever I do a buffer command |
| 04:55 | mebaran151 | I don't know them yet |
| 04:55 | somnium | mebaran151: that will pass |
| 04:55 | mebaran151 | yeah I think it will |
| 04:55 | somnium | theres nav if you dont like dired, on elpa |
| 04:56 | mebaran151 | I was wondering if you could put swank clojure in a production app |
| 04:56 | mebaran151 | and dial into it if it started acting up |
| 04:56 | mebaran151 | no dired itself is fine |
| 05:03 | Licenser | hmmm 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:06 | gregh | that's a vague explanation :) |
| 05:07 | Licenser | yes 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:08 | Licenser | what 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:11 | Licenser | so 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:11 | Licenser | |
| 05:25 | mebaran151 | how do I make parenmatch highlighting default |
| 05:27 | spariev | mebaran151: (show-paren-mode 1) in .emacs |
| 05:29 | mebaran151 | it's nice |
| 05:29 | spariev | mebaran151: 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:30 | mebaran151 | can't watch screencasts: no soundcard :( |
| 05:31 | esj | mebaran151: the link I posted earlier works too. |
| 05:31 | esj | (he uses Ubuntu, i'm osx with aquamacs and it still works) |
| 05:32 | mebaran151 | I'm on Ubuntu |
| 05:32 | mebaran151 | what link? |
| 05:32 | spariev | mebaran151: anyway, there is his .emacs in that post with lots of useful emacs-fu |
| 05:32 | mebaran151 | ah yeah I saw it |
| 05:36 | Raynes | Laurent is an Emacs God. |
| 05:37 | Licenser | when I do a require :reload will that concatinate to all the require's in the file I require? |
| 05:39 | esj | i think its :reload-all ? But I may be imagining. |
| 05:40 | Licenser | esj: way thank you! |
| 05:40 | esj | np |
| 05:43 | Licenser | this is going to save me lots of trouble |
| 05:43 | timothypratley | Anyone 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:44 | timothypratley | it must be loading its own version somehow but I'm not sure where to start looking. |
| 05:54 | G0SUB | timothypratley: any news? |
| 05:56 | timothypratley | GOSUB: I've established that the problem occurs using lein, but not without, but still trying to figure out why. |
| 05:58 | timothypratley | GOSUB: 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:59 | timothypratley | GOSUB: But I'm sure the answer is not far away :) |
| 06:02 | Raynes | What would be a better way to write this: (dosync (alter stack #(cons 2 %))) |
| 06:03 | Raynes | cons' argument list doesn't allow me to just do cons 2. |
| 06:05 | G0SUB | timothypratley: cool. |
| 06:07 | G0SUB | timothypratley: but why, oh why? everything is in classpath, alright. |
| 06:08 | G0SUB | timothypratley: and oh, it happens inside slime repl too. not just lein repl. (using clojure-project) |
| 06:12 | timothypratley | GOSUB: That's handy to know!!! |
| 06:12 | timothypratley | GOSUB: The test I did with a custom REPL was using latest contrib/clojure |
| 06:13 | timothypratley | GOSUB: When I do custom REPL with the jars from lein/lib dir.... problem occurs |
| 06:14 | timothypratley | GOSUB: I'm starting to think this is an old bug that got fixed (hence why we couldn't see it in the source) |
| 06:18 | Licenser | hmm 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:38 | G0SUB | timothypratley: any idea what the bug might be ? |
| 06:43 | timothypratley | GOSUB: 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:44 | G0SUB | timothypratley: that fact that it's private makes matters worse |
| 06:47 | timothypratley | GOSUB: *nod* yup |
| 06:48 | Licenser | hmm I think to think I have some odd bug in the printer o.O |
| 06:50 | Raynes | Also, this was the better way: (defn flip [f] (fn [& args] (apply f (reverse args)))) |
| 06:51 | Raynes | Followed by, (dosync (alter stack (flip cons) x))) |
| 06:51 | Raynes | Flip is probably already defined in core, but I couldn't find it. |
| 06:52 | Chousuke | it's not. |
| 06:53 | Licenser | ah I know what it comes from, lazyness :D |
| 06:54 | Raynes | Chousuke: Cool, I did something right! :D |
| 06:54 | Raynes | Chousuke: I'm used to using flip in Haskell, so it was the obvious solution here. |
| 07:00 | mebaran151 | anybody here know the transaction syntax for clojureql? |
| 07:05 | hamza | hey 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:09 | mebaran151 | I don't think it is natively, but I have a coworker that has a macro that almost does it |
| 07:09 | mebaran151 | as 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:10 | hamza | (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:11 | mebaran151 | but a function isn't simple like a data-structure |
| 07:11 | mebaran151 | it's variables are bound to its environment |
| 07:11 | mebaran151 | to really serialize a function, you'd have serialize its environment as well |
| 07:12 | mebaran151 | if 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:14 | timothypratley | GOSUB: 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:15 | hamza | yeah i am after the actual represantation.. |
| 07:20 | optimizer | is RAII possible in clojure? |
| 07:22 | somnium | hamza: you could try something like this http://gist.github.com/275149 |
| 07:28 | hamza | am i missing something? (defn-src atest [] (println "test")) i am getting unable to resolve symbol body? |
| 07:30 | somnium | hamza: ah, the tilde is wrong in the gist, updated it |
| 07:31 | hamza | somnium: greate thanks a lot just what i was looking for.. |
| 07:35 | defn | When I add a dependency to leiningen, where does it all pull from? |
| 07:35 | defn | I see some people adding things like org.markdownj/markdownj to their project.clj, but it's not in the repo anywhere |
| 07:35 | defn | the clojars repo i mean |
| 07:36 | LauJensen | I would guess it checks Maven Central |
| 07:36 | Raynes | defn: It pulls from Maven Central, Clojars, and clojure-snapshots as far as I can tell. |
| 07:36 | defn | thanks LauJensen -- didnt know what to google on that |
| 07:37 | Raynes | defn: clojure-snapshots would be build.clojure.org/snapshots |
| 07:37 | defn | hmm, wtf is this markdownj coming from |
| 07:37 | defn | [org.markdownj/markdownj "0.3.0-1.0.2b4"] |
| 07:37 | defn | it's not in maven2 or in clojars |
| 07:38 | Raynes | I'm pretty sure it's in maven central. |
| 07:38 | defn | you would think, but i go into maven2/org/... |
| 07:38 | defn | and no markdownj |
| 07:40 | defn | ah-ha! |
| 07:40 | defn | http://code.google.com/p/markdownj/wiki/Maven |
| 07:41 | defn | i need to add a repository to markdown as a dependency and then i can get it |
| 07:41 | defn | whoa im tired |
| 07:41 | Raynes | Add a repository to markdown as a dependency? |
| 07:41 | defn | i need to add a repository in my project.clj and then i can get it |
| 07:42 | defn | yeah sorry about that, that is just incomprehensible |
| 07:42 | Raynes | How do you add a repository to project.clj? ;o |
| 07:42 | LauJensen | defn, did you check out my latest blogpost where in I show how to add your own jars to a lein config? |
| 07:43 | Raynes | LauJensen: Link pwease. |
| 07:43 | LauJensen | www.bestinclass.dk |
| 07:43 | defn | LauJensen: i didnt see that but im interested |
| 07:43 | LauJensen | click blog - click top post |
| 07:43 | defn | leiningen is still a strange mistress to me |
| 07:44 | defn | i can do some basics like :dev-dependencies, :dependencies, :main, but havent messed with any others |
| 07:44 | Raynes | LauJensen: I referred to you as an Emacs God earlier. Do I get points? |
| 07:44 | Raynes | :p |
| 07:45 | LauJensen | No, but because of your good motives I wont slap you for blasphemy |
| 07:45 | defn | dude LauJensen ! I stop checking my RSS feeds for 5 days and you manage to put a ton of awesome content up |
| 07:45 | defn | also, you are an emacs god, your videos showed me about fuzzy completion in slime |
| 07:45 | defn | :) |
| 07:45 | LauJensen | Yea the Hadoop stuff is pretty fun |
| 07:45 | LauJensen | I hope to do some massive image processing soon :) |
| 07:46 | defn | im excited about the enlive stuff |
| 07:46 | defn | i read up on it, but im still not 100% on how to use it |
| 07:46 | LauJensen | anyway, gotta duck out a little while, will be back in 5 hours or so |
| 07:47 | defn | LauJensen: what's clojure-mode-el? |
| 07:47 | defn | is it el or clojure-mode-l? |
| 07:47 | LauJensen | clojure-mode.el |
| 07:47 | LauJensen | The Emacs Lisp file which contains Clojure-mode |
| 07:47 | defn | oh -- gotcha |
| 07:49 | defn | LauJensen: i had no idea how to do a keyboard macro on a region |
| 07:49 | defn | that rules |
| 07:50 | defn | ive just been doing C-u 20 C-x e |
| 07:50 | defn | or whatever, to do multiple lines |
| 07:51 | defn | where i make sure to put a M-x next-line |
| 07:51 | defn | and M-x beginning-of-line |
| 07:52 | defn | LauJensen: using enlive to get those function is nice and all, but couldn't you just use ns-publics? |
| 07:53 | LauJensen | Yes of course - But how would you show off Enlive doing that? |
| 07:53 | defn | :D |
| 07:54 | defn | LauJensen: i have an odd request for a video |
| 07:54 | LauJensen | The important part is the (info ...) - that way you can fix stuff yourself |
| 07:54 | LauJensen | Whats the request? |
| 07:54 | defn | i want to see 2 hours of emacs + clojure with no particular theme, just you working on "stuff" |
| 07:55 | defn | that includes switching windows, looking stuff up, etc. |
| 07:55 | LauJensen | Ah |
| 07:55 | LauJensen | I 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:55 | defn | yeah that'd be cool |
| 07:55 | defn | id also like to know more about *organizing* clojure projects |
| 07:56 | defn | like with a webapp im messing with, im having a very hard time separating functionality out into separate files |
| 07:56 | defn | since they all seem to rely on one another |
| 07:57 | LauJensen | Ok - 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:58 | defn | sounds good, thanks again |
| 07:59 | LauJensen | np |
| 08:06 | esj | defn: nice requests, I could use that stuff too. |
| 08:07 | gerr | hello |
| 08:07 | gerr | what's wrong with this: (defprotocol Show (show [x])) |
| 08:08 | gerr | (deftype Person [name age] Show (show [x] (str (:name x) (:age x)))) |
| 08:08 | gerr | java.lang.IllegalArgumentException: Can't define method not in interfaces: show (NO_SOURCE_FILE:2) |
| 08:09 | gerr | ,(defprotocol Show (show [x])) |
| 08:09 | clojurebot | DENIED |
| 08:14 | defn | esj: ive been thinking a lot about organization |
| 08:14 | defn | esj: i think it's important to pay attention to the type that a function returns |
| 08:14 | Raynes | gerr: http://gist.github.com/275175 |
| 08:14 | Raynes | gerr: Sorry for the delay. |
| 08:14 | esj | defn: me too actually, getting things properly structured is a good part of the battle. |
| 08:14 | gerr | Raynes: ok |
| 08:15 | Raynes | It appears that 'this' is implicit. |
| 08:15 | defn | so for instance, a "controller" function in my compojure app can return anything, EXCEPT html |
| 08:15 | defn | instead of making some function (defn gen-page [] (html (interpose .......))) |
| 08:15 | Raynes | gerr: You can access the fields of the type directly in the protocol functions. |
| 08:15 | defn | you just put the (html x) part into a layout file |
| 08:16 | Raynes | I didn't realize that initially earlier, and had hell with it. |
| 08:16 | gerr | Raynes: but in defprotocol, i still need one arg? |
| 08:16 | Raynes | gerr: Yes. |
| 08:16 | Raynes | It's 'this'. |
| 08:17 | gerr | hmm, thx |
| 08:17 | {newbie} | deftype? is clojure gaining an builtin OO system? |
| 08:18 | Raynes | {newbie}: Not really. No more than Haskell has an OOP system because of it's algebraic datatypes. |
| 08:18 | cemerick | ~deftype? |
| 08:18 | clojurebot | deftype is see datatype |
| 08:18 | cemerick | ~datatype? |
| 08:18 | clojurebot | datatype is see datatypes |
| 08:18 | cemerick | ~datatypes? |
| 08:18 | clojurebot | http://www.assembla.com/wiki/show/clojure/Datatypes |
| 08:18 | cemerick | sheesh |
| 08:18 | cemerick | {newbie}: see ^^ |
| 08:19 | Raynes | gerr: 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:19 | Raynes | s/directly/explicitly/ |
| 08:20 | gerr | Raynes: ..(Show [] [x]..) two arg list is abit odd |
| 08:21 | Raynes | gerr: Also, see the examples in (doc defprotocol) |
| 08:21 | gerr | ok |
| 08:23 | rhickey | so, who's written code that depends on defmacro creating (internally) a fn with the same signature? |
| 08:23 | Raynes | gerr: The resulting functions from defprotocol dispatch on their first argument, and that's why they have to have at least one argument. |
| 08:24 | gerr | Raynes: i see |
| 08:34 | Raynes | Somebody needs to write a book and host it for free online, like Real World Haskell. |
| 08:38 | cemerick | vy: functions in BNF? |
| 08:38 | cemerick | overkill 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:39 | vy | cemerick: In some sort of BNF, for instance, CLHS is quite in this area. |
| 08:39 | vy | s/quite/quite good/ |
| 08:39 | vy | _fogus_: +1 |
| 08:41 | _fogus_ | Chouser and I have adopted a similar format for our book |
| 08:46 | chouser | rhickey: now *that's* an interesting question. what are you up to? |
| 08:47 | chouser | I don't have any real code like that. |
| 08:47 | chouser | Should 'restart' be named 'restart-agent'? |
| 08:47 | cemerick | seems like a bad idea in general |
| 08:49 | chouser | I guess if you were trying to write your own (modified?) version of macroexpand or something. |
| 08:49 | rhickey | chouser: I'm thinking of supplying 2 more implicit args to defmacro expansion fns - &env and &whole |
| 08:50 | chouser | ooh |
| 08:50 | rhickey | cemerick: right, I consider any such code as relying on implementation details |
| 08:50 | rhickey | and thus subject to breakage |
| 08:51 | rhickey | the latter, &whole, might be the path for fn metadata |
| 08:54 | rhickey | &env will preclude the implementation-dep inside things like local-bindings here: http://gist.github.com/254110 |
| 09:28 | midget | Hey. |
| 09:28 | midget | Do you know how to twist on the knife? |
| 09:28 | midget | I can`t make it right - always cut myself |
| 09:30 | esj | well, that would be a mutating operation, so we can't help you there. |
| 09:31 | Drakeson | how do you add a repository to the 3 default ones in leiningen? |
| 09:32 | Drakeson | for instance, I want to add http://mirrors.ibiblio.org/pub/mirrors/maven2 |
| 10:01 | lisppaste8 | someone-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:19 | Raynes | Drakeson: :repositories |
| 10:21 | Raynes | Of course, there isn't any example of how to actually use that, so I can't help you there. |
| 10:54 | chouser | ,({(int 5) :ok} (long 5) :not-ok) |
| 10:58 | chouser | ,({(int 5) :ok} (long 5) :not-ok) |
| 10:58 | clojurebot | :not-ok |
| 10:59 | chouser | can we use Clojure's = instead of Java's .equals() for map key comparison? |
| 10:59 | chouser | this just bit me hard. |
| 11:05 | cemerick | 1.equals(1L) is false ?!? Crazy. |
| 11:05 | rhickey | chouser: not without breaking the contract of j.u.Map |
| 11:07 | chouser | arararagag |
| 11:10 | chouser | I just spent longer than I'd care to admit tracking down a map lookup failure. |
| 11:11 | chouser | the 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:11 | cemerick | that's not friendly at all. |
| 11:12 | chouser | so then I added debugging code to walk through the map, and discovered that the key and lookup value were = |
| 11:12 | rhickey | chouser: how did you end up with a long? |
| 11:12 | chouser | checking that now. I think the long came from a protobuf |
| 11:13 | cemerick | pr should probably attach suffixes to numbers as long as stuff like this is possible. |
| 11:13 | cemerick | or, optionally so, perhaps |
| 11:13 | chouser | yeah, 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:14 | chouser | but then I looked it up using the original int |
| 11:15 | chouser | I even knew about the problem with different number types as map keys, and still didn't "get" it |
| 11:15 | chouser | ,(= (int 5) (long 5)) |
| 11:15 | clojurebot | true |
| 11:16 | chouser | ,(= (hash (int 5)) (hash (long 5))) |
| 11:16 | clojurebot | true |
| 11:18 | rhickey | this is an area with no universally good answer |
| 11:18 | chouser | no kidding |
| 11:18 | chouser | well |
| 11:18 | rhickey | as long as you can have different types represent the same value |
| 11:18 | chouser | .equals() could be potentially do the "right thing" couldn't it? |
| 11:19 | rhickey | you mean if JAva changed it? |
| 11:19 | chouser | right |
| 11:19 | chouser | I guess it still couldn't support new number types like Ratio |
| 11:19 | rhickey | what about (.equals 1 1.0) ? |
| 11:20 | chouser | I 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:20 | chouser | because they print differently, I would have spotted 1.0 much sooner. |
| 11:21 | chouser | Of course I'd hate for either ints or longs to print with decorations be default |
| 11:21 | chouser | and I wouldn't have thought of trying a non-default print option until after I'd identified the real problem. |
| 11:22 | chouser | *print-dup* already prints them differently |
| 11:22 | chouser | didn't even occur to me to try that. |
| 11:23 | cemerick | stuff like this is going to cause so much pain when people start seriously targeting other hosts |
| 11:23 | Spockz|lap | stuff like what? |
| 11:30 | stuartsierra | ,(.equals (long 1) (int 1)) |
| 11:30 | clojurebot | false |
| 11:30 | arohner | chouser: yeah, that problem bit me hard a few months ago |
| 11:31 | arohner | different printing would have helped me catch it much sooner |
| 11:31 | stuartsierra | ,(with-out-str (binding [*print-dup* true] (pr (long 1) (int 1)))) |
| 11:31 | clojurebot | "#=(java.lang.Long. \"1\") 1" |
| 11:31 | arohner | what's the problem with making longs print as "1L" or whatever? |
| 11:31 | chouser | ugly |
| 11:32 | stuartsierra | Isn't that what Java's long syntax uses? |
| 11:32 | chouser | but maybe it'd be worth it. |
| 11:32 | arohner | that's not very convincing to me when we already print 1.0 and 1M |
| 11:32 | stuartsierra | ,(pr-str 12345678901234567890) |
| 11:32 | clojurebot | java.lang.ExceptionInInitializerError |
| 11:33 | stuartsierra | ,(pr-str (BigInteger. "12345678901234567890")) |
| 11:33 | clojurebot | "12345678901234567890" |
| 11:33 | stuartsierra | ,(binding [*print-dup* true] (pr-str (BigInteger. "12345678901234567890"))) |
| 11:33 | clojurebot | "#=(java.math.BigInteger. \"12345678901234567890\")" |
| 11:33 | cemerick | 1L is a lot prettier than #=(java.lang.Long. "1") |
| 11:34 | chouser | heh. true. |
| 11:34 | cemerick | I'd love to have literals like that in general, to avoid stuff like (int 1) |
| 11:35 | stuartsierra | Yes, Java uses 1L for (long 1). |
| 11:37 | chouser | (int 1) also means primitive in some contexts. I assume 1I or whatever wouldn't? |
| 11:38 | stuartsierra | chouser: probably not |
| 11:38 | stuartsierra | 1L would probably mean (java.lang.Long. "1") to the Clojure reader. |
| 11:39 | arohner | why not? |
| 11:39 | arohner | it probably doesn't now, but why couldn't it? |
| 11:40 | stuartsierra | I guess it could, in a 'loop' head. |
| 11:40 | cemerick | 1L should just expand out to (long 1), which will get boxed as necessary anyway |
| 11:40 | arohner | the reader reads 1M appropriately, so I don't see why it can't do 1L just as easily |
| 11:42 | stuartsierra | cemerick: that assumes that "L" is a reader macro |
| 11:43 | cemerick | stuartsierra: it should probably be considered something lower-level than that. Not dispatching on #, etc. |
| 11:44 | cemerick | the reader can emit whatever symbols it wants as its tokenizing |
| 11:56 | rhickey | Long-term (pardon the pun) I think longs and doubles will win out as defaults, making ints as rare as shorts |
| 11:56 | stuartsierra | rhickey: That wouldn't have prevented chouser's original problem caused by interop with protobuf. |
| 11:56 | rhickey | stuartsierra: sure it would, if Clojure never boxed to Integer, only to Long |
| 11:57 | stuartsierra | Until some other library decides to down-cast long to int! |
| 11:57 | rhickey | stuartsierra: but only boxed things end up as map keys |
| 11:58 | rhickey | so back to Long on box |
| 11:58 | stuartsierra | Ah, I think I see |
| 11:58 | stuartsierra | In other words, there wouldn't be any auto-boxed java.lang.Integer |
| 11:58 | rhickey | in 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:58 | stuartsierra | Just java.lang.Long |
| 11:59 | leafw | considering 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:59 | stuartsierra | rhickey: But aren't automatic integer upgrades a cornestone of Lisp? :) |
| 12:00 | rhickey | stuartsierra: I now consider that a mistake for Lisps |
| 12:00 | stuartsierra | Huh, interesting. |
| 12:01 | rhickey | I agree that 'bad math' is unacceptable, but exception on overflow is fine, as long as explicit bigints are there and contagious |
| 12:01 | cemerick | sort of inevitable given hardware history |
| 12:02 | chouser | interesting |
| 12:02 | rhickey | In DotLisp I did exception on overflow, and it is better for 95% of the use cases |
| 12:03 | rhickey | If you know you will have bigints, use 42BIG (or whatever) |
| 12:03 | chouser | but a protobuf can emit a boxed Integer too -- that would be the same problem in reverse. |
| 12:03 | rhickey | chouser: a boxed integer how? |
| 12:03 | rhickey | user boxing? |
| 12:03 | rhickey | reflection? |
| 12:04 | chouser | oh |
| 12:04 | rhickey | if the lang only does Long boxes, and fixes reflection boxes, then only user boxing is an issue |
| 12:05 | rhickey | oh, and Java-land boxing |
| 12:05 | chouser | right, it's coming from java-land |
| 12:05 | rhickey | the Java wrapper for protobufs boxes? |
| 12:06 | LauJensen | So the compiler will handle all incoming Ints being cast to longs and the same outgoing if need be ? |
| 12:06 | rhickey | rather than generating classes with primitive fields? |
| 12:06 | chouser | oh, i see what you're saying. let me check. |
| 12:13 | chouser | the generated methods return primitives, but I'm building the clojure map from a java.util.Map |
| 12:13 | chouser | so it's java or protobuf doing the boxking, not Clojure |
| 12:14 | djpowell | if someone calls (mymacro String), is there anyway to resolve the symbol: String in that macro, into the class object: java.lang.String |
| 12:14 | chouser | ,(resolve 'String) |
| 12:14 | clojurebot | java.lang.String |
| 12:14 | djpowell | ah |
| 12:17 | rhickey | chouser: 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:17 | rhickey | every now and the I contemplate these changes, but dread the pushback |
| 12:17 | rhickey | breakage |
| 12:18 | chouser | yeah. In this case, I have a loop that's converting and can easily adjust the number type. |
| 12:18 | chouser | but what should I adjust to? with your proposed change, it would be easy: Long. |
| 12:18 | rhickey | right |
| 12:19 | chouser | today, I guess I'll want to convert to the minimal acceptible type. is there a fn for that? |
| 12:19 | rhickey | also, longs are on the table to get primitive arg/return support |
| 12:19 | rhickey | chouser: so 1 is Byte? |
| 12:19 | chouser | :-( |
| 12:20 | rhickey | exactly |
| 12:20 | chouser | no, I want to match what Clojure would do for a similar literal |
| 12:20 | chouser | so that when the protobut has {5 10] |
| 12:20 | chouser | so that when the protobut has {5 10} and I type {5 10} in the code, they match |
| 12:20 | chouser | eh |
| 12:21 | chouser | maybe. 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:21 | chouser | both sound like trouble. |
| 12:22 | rhickey | if Clojure defaulted to Long, I'd be happy printing all others with suffixes |
| 12:23 | rhickey | but 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:23 | rhickey | that is the map you are building and handing to Clojure |
| 12:24 | rhickey | basically, types matter when numbers are used as keys |
| 12:25 | rhickey | Java could have made different decisions in the boxed number tower, but that's water under the bridge |
| 12:26 | rhickey | so, Long integers by default, exceptions on overflow, suffixes for all others? |
| 12:27 | chouser | I'm on board. |
| 12:27 | chouser | :-) |
| 12:27 | cemerick | very happy about Longs and suffixes |
| 12:28 | rhickey | cemerick: and on overflow? |
| 12:28 | chouser | who are these people that cause you pain when you make beneficial breaking changes. |
| 12:28 | chouser | ? |
| 12:28 | cemerick | rhickey: aren't things going to get promoted automatically anyway? |
| 12:28 | chouser | and can I have a little one-on-one time with them? |
| 12:28 | rhickey | I hardly ever make breaking changes |
| 12:28 | rhickey | cemerick: no, that's the change |
| 12:29 | chouser | I know. because you fear these bullies. ;-) |
| 12:30 | rhickey | what'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:31 | rhickey | cemerick: it ends up that promotion from primitive to boxed (BigInteger) is a primary perf disaster |
| 12:31 | rhickey | cemerick: because on the bytecode level no single type can hold both |
| 12:31 | cemerick | clearly, I don't do enough maths |
| 12:31 | cemerick | ,(-> Integer/MAX_VALUE inc) |
| 12:31 | clojurebot | 2147483648 |
| 12:32 | cemerick | that's interesting -- that fails in my repl with an overflow |
| 12:32 | rhickey | here too |
| 12:33 | cemerick | anyway, that (sometimes?!?!?) fails, but this is OK currently: |
| 12:33 | cemerick | ,(-> Integer/MAX_VALUE Integer. inc) |
| 12:33 | clojurebot | 2147483648 |
| 12:33 | chouser | ((identity inc) Integer/MAX_VALUE) |
| 12:34 | _fogus_ | Are we playing, avoid the overflow exception game? |
| 12:34 | rhickey | but Integer/MAX_VALUE is tricky as you are already into Java primitive rules |
| 12:35 | cemerick | rhickey: 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:36 | rhickey | cemerick: with no Java interop in play, the rules are the traditional lisp ones - unbounded integers |
| 12:36 | cemerick | ,(inc (int 2147483647)) |
| 12:36 | clojurebot | 2147483648 |
| 12:37 | rhickey | the change would be that unqualified integers would be longs, and would throw on overflow rather than auto-convert to bigints |
| 12:37 | cemerick | I'm really curious about why clojurebot isn't erroring on that. |
| 12:37 | cemerick | oh, I see |
| 12:38 | cemerick | rhickey: 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:40 | lpetit | Hello, is it normal to have an ArrayIndexOutOfBoundsException throw from clojure.lang code, more precisely PersistentArrayMap$Seq.first() (line 217) ? |
| 12:40 | chouser | lpetit: when you give a non-even number of items in a literal {}, yes. |
| 12:41 | chouser | cemerick: but it's not just perf, I think -- it's problems like the one I just had. |
| 12:41 | lpetit | Ah, 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:42 | chouser | ,{1} |
| 12:42 | clojurebot | java.lang.ArrayIndexOutOfBoundsException: 1 |
| 12:42 | lpetit | ,(equals {1} {2}) |
| 12:42 | clojurebot | 1 |
| 12:43 | lpetit | ,(= {1} {2}) |
| 12:43 | clojurebot | 1 |
| 12:43 | chouser | ,(first {1}) |
| 12:43 | clojurebot | 1 |
| 12:43 | lpetit | ,{1} |
| 12:43 | clojurebot | java.lang.ArrayIndexOutOfBoundsException: 1 |
| 12:43 | chouser | noo |
| 12:43 | chouser | ,(val (first {1})) |
| 12:43 | clojurebot | 1 |
| 12:43 | chouser | no! those are failing for me. |
| 12:43 | lpetit | gargl |
| 12:43 | lpetit | (clojure-version) |
| 12:44 | lpetit | ,(clojure-version) |
| 12:44 | clojurebot | "1.1.0-alpha-SNAPSHOT" |
| 12:44 | chouser | anyway, those maps are invalid. Don't do that. |
| 12:44 | chouser | lunch. |
| 12:44 | cemerick | chouser: how does overflow impact the issue of concrete types of map keys? |
| 12:44 | lpetit | Well, it's from something read by the reader from a user source code editor ... |
| 12:45 | lpetit | So the reader seems to not complain, and the exception is throw later |
| 12:45 | lpetit | (doc read-string) |
| 12:45 | clojurebot | "([s]); Reads one object from the string s" |
| 12:45 | lpetit | ,(read-string "{1}") |
| 12:45 | clojurebot | 1 |
| 12:45 | lpetit | ,(read-string "{1 2}") |
| 12:45 | clojurebot | {1 2} |
| 12:46 | lpetit | ,(read-string "{1}") |
| 12:46 | clojurebot | 1 |
| 12:46 | lpetit | ok clojurebot is fooling us there |
| 12:48 | unfo- | any help to why my join-channel function is not being called? https://gist.github.com/5005a3004cf58b1b7df3 |
| 12:49 | lpetit | Anyway, I now know how and where to catch the problem, thanks |
| 12:52 | stuartsierra | rhickey: Personally, I think rapid change is good IF it comes with a predictable cycle of stable releases |
| 12:54 | cemerick | stuartsierra: 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:57 | stuartsierra | I'm working on Contrib. |
| 12:59 | stuartsierra | And I think Clojure itself needs more releases. 1.1 added a whole pile of stuff that could have been let out incrementally. |
| 12:59 | cemerick | more tests + a maven repo + build process would make weekly releases entirely plausible, if warranted. |
| 13:00 | stuartsierra | Maybe not weekly, but at least every 6 months. Weekly would be a lot of extra work for rhickey. |
| 13:01 | cemerick | Shouldn't be. mvn release:prepare release:perform, and you're done. *shrug* |
| 13:02 | cemerick | I'm probably not seeing a lot of stuff that is happening around release time. |
| 13:03 | stuartsierra | cemerick: Not until we have a Maven build for Clojure. That's another mountain to climb. |
| 13:04 | cemerick | stuartsierra: we'll have to bag rhickey first. ;-) |
| 13:07 | stuartsierra | right |
| 13:25 | unfo- | 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:26 | Chousuke | well, you can call class on it |
| 13:27 | technomancy | unfo-: C-c S-i gives you a nice inspector if you're using slime |
| 13:28 | unfo- | technomancy, nope, not using it since emacs is bizarre to me :) coding with IDEA and standard REPL |
| 13:28 | technomancy | then I guess you need to use the class function |
| 13:29 | unfo- | ty |
| 13:40 | patrkris | LauJensen: is it possible to say to clojureql that utf8 must be used when connecting to mysql? |
| 13:41 | LauJensen | patrkris: 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:42 | LauJensen | Uuh check it out, Clojure almost in top10 again on Hacker News :) |
| 13:43 | patrkris | patrkris: 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:43 | LauJensen | patrkris: Gimme a sec I'll check |
| 13:43 | patrkris | LauJensen: thanks |
| 13:44 | LauJensen | patrkris: In the URL set "//localhost/db&characterEncoding=UTF-8" |
| 13:44 | LauJensen | 2.nd argument to make-connection-info |
| 13:44 | patrkris | LauJensen: coolio, thanks |
| 13:45 | unfo- | fffffuuuuu! I had a samename struct as I had a local variable in a few places... great confusion |
| 13:46 | hiredman | use ’ |
| 13:46 | hiredman | or <x> |
| 13:52 | unfo- | https://gist.github.com/5005a3004cf58b1b7df3 -- why does my map fail? |
| 13:52 | hiredman | map is lazy |
| 13:53 | unfo- | aaaaah! didn't know that |
| 13:53 | unfo- | so I need to use a do* function there? the doall or wotnot |
| 13:53 | unfo- | or was it dorun |
| 13:53 | hiredman | sure, you might just replace the call to map with a call to doseq |
| 13:53 | unfo- | ok. thanks! |
| 13:54 | hiredman | doseq is like for, but not lazy, and it evaluates to nil |
| 13:54 | LauJensen | hehe |
| 13:54 | LauJensen | "doseq is not like for because..." :) |
| 13:56 | LauJensen | Does anybody know where _ato Alex Osborne is hiding these days? |
| 14:02 | unfo- | (dorun (map myfun mylist)) worked wonders :-) |
| 14:03 | unfo- | 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:03 | unfo- | hiredman, very much appreciated! :) |
| 14:05 | technomancy | clojurebot: map? |
| 14:05 | clojurebot | map is *LAZY* |
| 14:07 | unfo- | :-) |
| 14:08 | unfo- | REPL is deceptive in this because it gives me the result I am expecting immediately |
| 14:09 | LauJensen | Yea I've been tripped up by that as well |
| 14:09 | unfo- | but now for something completely different after I submit this patch to my github |
| 14:11 | mebaran151 | I think I'm finally comfortable in emacs |
| 14:11 | mebaran151 | my penance for accidentally deleting my homedir is completed |
| 14:12 | LauJensen | hqhq |
| 14:12 | LauJensen | i mean... haha :) |
| 14:12 | mebaran151 | eah |
| 14:12 | mebaran151 | I'm gonna stick around |
| 14:12 | mebaran151 | I got the the layout I like, and tab completed bufffers are kind of groovy |
| 14:12 | mebaran151 | I'm just looking for a good window manager now |
| 14:13 | mebaran151 | as in a quick way to switch between emacs panes |
| 14:13 | LauJensen | C-x b, aint working? |
| 14:13 | mebaran151 | I mean |
| 14:13 | mebaran151 | I have three different windows open |
| 14:13 | mebaran151 | I'd like to switch between the repl and a pane |
| 14:13 | mebaran151 | of doc editing really fast |
| 14:14 | LauJensen | C-x o ? |
| 14:14 | mebaran151 | well it's a little basic |
| 14:14 | technomancy | mebaran151: C-c C-z switches to the repl from any clojure buffer |
| 14:14 | mebaran151 | but what about switching back :) |
| 14:14 | technomancy | I don't know if there's a reverse |
| 14:14 | mebaran151 | yeah |
| 14:14 | mebaran151 | I'd like something a little more general |
| 14:14 | mebaran151 | forwards and backwards |
| 14:14 | mebaran151 | I'd also like an undo that doesn't make me cry |
| 14:14 | ska2342 | mebaran151: checkout iswitchb, mtorus, windmove and windresize |
| 14:15 | LauJensen | mebaran151: the undo makes you cry? I really like it |
| 14:15 | technomancy | emacs' undo mechanism is carefully architected in order to avoid creating time-travel paradoxes |
| 14:15 | technomancy | trust me, you really don't want to have to think about what happens when alternate timelines interact. |
| 14:16 | mebaran151 | I haven't successfully undone yet |
| 14:16 | mebaran151 | hg rollback! |
| 14:16 | mebaran151 | hg revert |
| 14:16 | ska2342 | mebaran151: you can setup a slime-selector-method for switching between clojure code files and the repl, back and forth |
| 14:16 | mebaran151 | ah that was another questiong |
| 14:17 | mebaran151 | how do I control where the slime error pane renders itself |
| 14:17 | chouser | vim undo lets you go to any version of the file since you opened it -- even branches that have been undone. |
| 14:17 | LauJensen | Its 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:17 | chouser | just fyi |
| 14:18 | mebaran151 | chouser, I'm a big vim fan |
| 14:19 | mebaran151 | it's the only thing I use for sysadmin |
| 14:20 | technomancy | there's no way to calculate an md5 sum of a file without slurping it all into memory, is there? |
| 14:20 | technomancy | unless you shell out or something |
| 14:20 | ska2342 | mebaran151: I seem to remember to get the slime selector method from Bill Clementson, here: http://bc.tech.coop/blog/docs/clojure-emacs.el |
| 14:21 | chouser | technomancy: it doesn't all have to be in memory at once |
| 14:22 | Chousuke | technomancy: IIRC you can feed the MD5 calculator thingy data in chunks |
| 14:22 | mebaran151 | yeah so I remembered |
| 14:22 | mebaran151 | I think it takes an input stream |
| 14:25 | technomancy | aha, you can call "update" on it with just a few bytes. sweet. |
| 14:26 | humphrej | I've got a clojure syntax question.. |
| 14:26 | mebaran151 | heh, playing in Erc |
| 14:26 | mebaran151 | this is actually a far more convenient way to ask coding questions |
| 14:26 | Hun | mebaran151: try rcirc. it feels more clean :) |
| 14:26 | humphrej | I don't think In understand binding |
| 14:27 | mebaran151 | can I get it from packages? |
| 14:27 | humphrej | http://pastebin.com/d727cc1bd |
| 14:27 | Hun | it's included by default since emacs22 |
| 14:27 | Hun | M-x irc |
| 14:27 | humphrej | My question is why do I get the error if the set! is within the map func |
| 14:28 | chouser | humphrej: you probably understand 'binding' ok -- the problem there is that map is lazy |
| 14:28 | chouser | so 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:29 | humphrej | I see - it does work if I enclose everything in a huge binding |
| 14:29 | humphrej | inc the usage of the lazy seq |
| 14:30 | chouser | right. or realize the seq before leaving the binding you've got. |
| 14:30 | cemerick | is 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:31 | chouser | humphrej: via 'doall' for example. |
| 14:32 | humphrej | reason I ask is that I found this page http://www.findinglisp.com/blog/2004/11/investing-with-lisp.html |
| 14:32 | humphrej | and was wondering the best way to implement the make-history-function in clojure |
| 14:34 | humphrej | I was thinking keeping it lazy would be nice as then the source seq could be a seque or somesuch |
| 14:34 | rhickey | cemerick: what happens in other threads? |
| 14:35 | fliebel | Can someone answer me this very simple question: How do I empty a vector in an agent? |
| 14:35 | cemerick | rhickey: 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:36 | rhickey | cemerick: I'm confused - what's the use case? |
| 14:37 | cemerick | rhickey: 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:38 | cemerick | I 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:38 | chouser | fliebel: (send empty agt) ? |
| 14:38 | ska2342 | cemerick: wrap it in a try catch in your fn? |
| 14:39 | cemerick | ska2342: surely you're joking :-P |
| 14:39 | ska2342 | cemerick: Hm, I'm not so sure.. Going back to the REPL for a moment to try this |
| 14:39 | fliebel | chouser: I did not think of the possibility that such a stupid function would be in core. |
| 14:40 | cemerick | ska2342: oh, I'm sure it'll work, but that's hardcore ugly. |
| 14:41 | rhickey | fliebel: what's stupid about empty ? |
| 14:41 | chouser | fliebel: it's actually quite important to allow fns to support a variety of collections. |
| 14:41 | ska2342 | cemerick: uglier than changing the behaviour of a special form for a rare use-case? |
| 14:41 | chouser | (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:42 | qbg | cemerick: That would be solved beautifully with multiple return values |
| 14:42 | cemerick | ska2342: not so rare, IMO, but regardless, uglier than what's necessary now |
| 14:42 | fliebel | rhickey: 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:42 | ska2342 | yay, multiple-value-bind, here we come :-) |
| 14:42 | rhickey | cemerick: I'll admit that use case is not well supported, but unsure about set! of unbound as no-op |
| 14:42 | chouser | humphrej: I'd actually recommend strongly against using a var for your *histry* in this case. |
| 14:43 | chouser | humphrej: you might be interested in 'partition' |
| 14:43 | chouser | ,(partition 3 1 (range 10)) |
| 14:43 | clojurebot | ((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:43 | cemerick | qbg: if I wanted that, I could simply return a vector from the fn in question |
| 14:44 | ska2342 | cemerick: 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:44 | cemerick | rhickey: just a thought -- I've just written the (binding ...) workaround three times this afternoon, so I figured I'd bring it up. |
| 14:44 | mebaran151 | any of you guys use eproject or nav? |
| 14:45 | chouser | cemerick: what's the type of the object you return (not the binding one, the main one)? |
| 14:45 | cemerick | ska2342: 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:46 | cemerick | chouser: 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:46 | cemerick | chouser: it's actually perfect for error-kit, but too simple of a problem to use error-kit for :-) |
| 14:46 | rhickey | cemerick: if you bind in the setting fn, that won't make it out of the binding |
| 14:46 | chouser | heh. every problem is too simple to use error-kit for |
| 14:47 | chouser | cemerick: having the ignore-on-unbound-set configurable (non-default) is a bit interesting. |
| 14:48 | ska2342 | this sounds more like a thread-local atom, not? |
| 14:48 | rhickey | cemerick: you could test that the var is bound before trying to set! |
| 14:48 | chouser | you 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:49 | rhickey | don't we just need a bound? fn ? |
| 14:49 | rhickey | then you could write -set-if-bound! |
| 14:49 | chouser | yeah, that's better |
| 14:49 | humphrej | chouser: thanks let me ponder that one |
| 14:50 | ska2342 | would 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:50 | ska2342 | /No/Not/ |
| 14:51 | chouser | ska2342: right, there's .isBound already, but that's something else. |
| 14:51 | cemerick | ska2342: 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:51 | qbg | random question: Is it a known issue that the master branch of clojure-contrib will no longer compile with the master branch of clojure? |
| 14:52 | rhickey | cemerick: and then reimplement the stack-unwinding? |
| 14:52 | chouser | you'd want 'thread-bound?' or something? |
| 14:52 | rhickey | chouser: yes, two flavors |
| 14:52 | chouser | qbg: did you 'ant clean' your contrib before building? |
| 14:53 | rhickey | is there a reason that contrib doesn't auto-clean? |
| 14:53 | cemerick | rhickey: I sense sarcasm. Did I miss something? |
| 14:53 | qbg | chouser: Thanks, that fixed it |
| 14:53 | rhickey | cemerick: no sarcasm, but what happens with nested calls when you start using an atom? |
| 14:54 | cemerick | yeah, not a general solution -- works in this particular case, though, where I know there's no nested calls |
| 14:55 | rhickey | cemerick: would not thread-bound? solve your problem? |
| 14:55 | ska2342 | I humbly repeat my question about a thread-local atom-like-type. Is that desirable, interesting or even doable? |
| 14:56 | chouser | ska2342: var is a thread-local atom-like |
| 14:56 | cemerick | rhickey: I believe so, and I'd use it. I'm just trying to finish this particular piece this afternoon. :-) |
| 14:57 | rhickey | cemerick: you could send me a patch with bound? and thread-bound? right now... |
| 14:57 | rhickey | :) |
| 14:57 | rhickey | all the support is in Var already |
| 14:58 | cemerick | rhickey: halfway there already :-) |
| 14:58 | arohner | I 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:58 | cemerick | still won't be in our actual build of clojure for a while tho |
| 15:00 | cemerick | rhickey: when would Var.count be > 0 but yet the bindings have no entry for the var? |
| 15:01 | trmsw | does anybody else get an error from (use 'clojure.contrib.http.agent): bytes already refers to: #'clojure.core/bytes in namespace: user? |
| 15:02 | rhickey | cemerick: you don't want count, that is an optimization. You want getThreadBinding(0 != null, but not public |
| 15:02 | trmsw | I'm using clojure-1.1.0 and clojure-contrib-1.1.0-RC1 |
| 15:03 | cemerick | rhickey: yeah, that's what I've done already, I was just wondering re: count |
| 15:03 | rhickey | bound? == hasRoot(), thread-bound? == getThreadBinding() != null |
| 15:03 | rhickey | cemerick: count allows Var to check an Atom prior to incurring the overhead of getting the thread local |
| 15:03 | rhickey | if count is 0, no thread has a local binding |
| 15:04 | chouser | what is isBound() |
| 15:04 | rhickey | chouser: bound either way |
| 15:04 | chouser | bound only at the most recently level of 'binding'? |
| 15:04 | chouser | oh, || hm.. |
| 15:05 | rhickey | and maybe what bound? should map to |
| 15:05 | rhickey | bound? means deref will work, thread-bound? means set! will work |
| 15:07 | rhickey | stuartsierra: 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:08 | stuartsierra | yes |
| 15:08 | technomancy | what'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:09 | stuartsierra | ,(format "%10s" :foo) |
| 15:09 | clojurebot | " :foo" |
| 15:09 | rhickey | poll, when fns get metadata - where do you want to put it? |
| 15:10 | hiredman | on mars |
| 15:10 | rhickey | hiredman: ? |
| 15:10 | technomancy | stuartsierra: any way to do it with a character other than space? |
| 15:11 | hiredman | rhickey: sorry |
| 15:11 | stuartsierra | rhickey: before argument list, (fn {metadata} [x] ...) |
| 15:11 | rhickey | stuartsierra: won't that be confusing with multiple arity? |
| 15:11 | rhickey | since won't be per-arity |
| 15:11 | chouser | after the 'fn' |
| 15:12 | stuartsierra | actually, I have no idea |
| 15:12 | rhickey | chouser: and if there's a name? |
| 15:12 | chouser | so, before the name if any |
| 15:12 | chouser | before the arg vector if only one, and before the list of arities |
| 15:12 | chouser | except |
| 15:13 | chouser | that's the same "place" as var metadata on defns. :-/ |
| 15:13 | stuartsierra | The only time it matters is in defn, where there's confusion with Var metadata. Anywhere else we have #^ |
| 15:13 | rhickey | so, this is still code as data |
| 15:13 | hiredman | stuartsierra: #^ has to expand into something |
| 15:14 | stuartsierra | hiredman: yes, but #^{...} (fn ...) could set metadata on the fn |
| 15:14 | stuartsierra | (def #^{...var metadata...} symbol #^{...fn metadata...} (fn ...)) |
| 15:15 | hiredman | stuartsierra: but #^ is a reader macro |
| 15:15 | hiredman | ahem |
| 15:15 | hiredman | right |
| 15:16 | stuartsierra | hiredman: oh, right. (with-meta {...} (fn ...)) then |
| 15:16 | stuartsierra | But (fn...) is a special form, so I suppose it could accept read-time metadata too. |
| 15:17 | rhickey | fn is a macro |
| 15:17 | rhickey | fn* is special |
| 15:17 | stuartsierra | oh |
| 15:18 | rhickey | but the fn form can certainly take metadata on the form, once macros can get their forms |
| 15:18 | chouser | we're not talking about fns support with-meta, are we? |
| 15:18 | rhickey | chouser: possiblty |
| 15:19 | rhickey | which argues for simple #^{:a 1} (fn []...) |
| 15:20 | stuartsierra | I actually prefer #^ to having metadata in a different place for different macros (defn, fn, def, ...) |
| 15:20 | stuartsierra | But people will complain that it's ugly. |
| 15:20 | chouser | ^{:a 1} (fn [] ...) :-) |
| 15:21 | stuartsierra | chouser: yes, I like that |
| 15:21 | arohner | why do does the "defn metadata" need to go on the var once fns have metadata? |
| 15:22 | rhickey | arohner: backwards compatibility? |
| 15:22 | stuartsierra | arohner: {:private true} for one, and people may still have use for Var metadata |
| 15:22 | stuartsierra | Would fn metdata include :pre/:post conditions? |
| 15:23 | arohner | ah right, thanks |
| 15:23 | chouser | some var metadata is used for non-fn values that don't themselves support metadata. docstring on *print-length* |
| 15:23 | technomancy | if IMeta is implemented in terms of protocols, does that mean we'll be able to add metadata to instances of final classes? |
| 15:23 | chouser | technomancy: where would the metadata be stored? |
| 15:24 | rhickey | stuartsierra: yes |
| 15:24 | rhickey | technomancy: no |
| 15:24 | technomancy | chouser: in... a metadata store? I hadn't really thought it through. =) |
| 15:25 | stuartsierra | technomancy: it might be possible, but still inadvisable |
| 15:25 | technomancy | stuartsierra: how so? |
| 15:26 | hiredman | :D |
| 15:26 | stuartsierra | Well, 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:26 | rhickey | the contract of with-meta is: the same value, with metadata. You can't superimpose that on a final class |
| 15:27 | rhickey | if you pretend (via an external map), you will have a performance, GC, and concurrency nightmare |
| 15:27 | stuartsierra | rhickey: Yes, that's why I said inadvisable. ;) |
| 15:27 | technomancy | gotcha |
| 15:27 | rhickey | nevermind a problem with identity |
| 15:28 | rhickey | stuartsierra: you mean insoluble? |
| 15:28 | technomancy | how about IFn on java.util.regex.Patterns then? |
| 15:29 | stuartsierra | rhickey: Insoluble to do it correctly. Hence, inadvisable to try it. |
| 15:29 | rhickey | technomancy: needs a wrapper |
| 15:29 | rhickey | stuartsierra: ok than :) |
| 15:29 | rhickey | then |
| 15:29 | stuartsierra | Comp. Sci. needs a word for that: "you can't do this correctly, so don't do it at all." |
| 15:30 | technomancy | well shucks, I'm going to have to find another 1.2-specific to get excited about then. |
| 15:30 | stuartsierra | technomancy: deftype! locals-clearing! |
| 15:31 | technomancy | oh yeah, locals-clearing is awesome. it's just easy to forget about. =) |
| 15:31 | rhickey | defprotocol, improved agent erros, direct binding |
| 15:31 | stuartsierra | direct binding!!! |
| 15:31 | rhickey | metadata on fns, form and locals in macros |
| 15:31 | technomancy | I just don't have any use in mind for protocols off the top of my head anymore |
| 15:32 | rhickey | direct binding is on right now in master, for clojure.* |
| 15:32 | technomancy | I'm sure I'll be able to think of something. =) |
| 15:32 | hiredman | cinc! |
| 15:32 | rhickey | hiredman: not 1.2 |
| 15:32 | stuartsierra | While we're on the subject, what do you say to publicly giving a target date and feature set for 1.2? |
| 15:33 | technomancy | isn't the feature set already fairly clear? |
| 15:34 | stuartsierra | I mean make it public, put a roadmap on the web. |
| 15:34 | hiredman | rhickey: sure |
| 15:34 | stuartsierra | With a due date. |
| 15:34 | rhickey | stuartsierra: 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:34 | hiredman | but that is a use for protocols |
| 15:34 | stuartsierra | I was thinking, if people could see what new features are coming out, and when, they would be more motivated to test. |
| 15:35 | stuartsierra | Not a due date per se, but a planned date. Like Ubuntu releases. |
| 15:35 | rhickey | stuartsierra: 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:36 | rhickey | stuartsierra: 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:37 | stuartsierra | rhickey: ok, it's your show, after all. |
| 15:37 | rhickey | plus any bug fixes that make it in the meantime |
| 15:37 | rhickey | all programmers do with dates is miss them |
| 15:38 | rhickey | stuartsierra: but I agree, fewer features per release, more frequent releases |
| 15:38 | stuartsierra | rhickey: that's good, that's the important part |
| 15:39 | rhickey | one problem with that is insufficient feedback time, so more things might be labeled alpha |
| 15:40 | technomancy | protocols aren't magic fairy dust that suddenly give me all the features I want. =) |
| 15:40 | stuartsierra | A description of which milestone to assign tickets to would help. |
| 15:44 | rhickey | stuartsierra: everything should go into backlog - I'll move them |
| 15:44 | hiredman | technomancy: 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:44 | stuartsierra | rhickey: might be worth mentioning on http://clojure.org/patches |
| 15:45 | rhickey | so, when can we move to ^{:lean :metadata} foo |
| 15:45 | rhickey | stuartsierra: backlog is the default |
| 15:46 | stuartsierra | rhickey: ok, I was just moving some old tickets from "no milestone" to backlog |
| 15:46 | hiredman | is ^ still going to be pre form? just #^ without the # |
| 15:48 | rhickey | stuartsierra: 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:48 | stuartsierra | cool, sounds good |
| 15:49 | rhickey | hiredman: yes, just #^ without the # |
| 15:52 | ecyrb | Could someone point me to an example of using "{#^:static true}" to declare a static method in gen-class? |
| 15:53 | hiredman | ecyrb: completely wrong |
| 15:53 | hiredman | #^ is a reader macro for attaching metadata to the following form |
| 15:54 | hiredman | so {#^:static true} tries to attach :static as metadata on true |
| 15:54 | hiredman | which is nonsense |
| 15:54 | rhickey | ecyrb: looks like you've got a typo there |
| 15:54 | rhickey | should be #^{:static true} |
| 15:54 | hiredman | #^{:static true} goes before the vector specifing the method |
| 15:54 | ecyrb | Ah. #^{:static true} |
| 15:55 | cemerick | rhickey: 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:56 | ecyrb | Thanks guys. |
| 15:56 | rhickey | cemerick: I think they should be ordinary functions |
| 15:57 | rhickey | ? |
| 15:58 | cemerick | rhickey: I wouldn't have expected that, but OK. Trying to be explicit about vars? |
| 15:59 | rhickey | cemerick: well, there's the don't make macros that don't need to be macros... |
| 16:01 | rhickey | heritage is: http://www.lispworks.com/documentation/HyperSpec/Body/f_boundp.htm |
| 16:07 | cemerick | rhickey: 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:09 | rhickey | cemerick: cool, thanks! |
| 16:10 | LauJensen | Anybody have some hints as to which Java classes would be appropriate for writing a proxy ? |
| 16:13 | chouser | my favorite is clojure.lang.IDeref :-) |
| 16:14 | hiredman | I think he must have meant an http proxy |
| 16:14 | chouser | oh |
| 16:14 | chouser | heh |
| 16:14 | LauJensen | Thats right :) |
| 16:18 | chouser | it doesn't seem quite right that queues print looking like lists |
| 16:19 | rhickey | chouser: what queues? |
| 16:19 | chouser | PersistentQueues |
| 16:19 | rhickey | oh, those |
| 16:19 | chouser | we're documenting them |
| 16:19 | chouser | :-) |
| 16:20 | rhickey | are people using them? |
| 16:20 | chouser | sure we are |
| 16:21 | _fogus_ | They will once they read our great section. :-p |
| 16:21 | chouser | not a lot, but when you need a queue, that's what you need. |
| 16:21 | chouser | when people don't use a queue the do horrible things to vectors instead. |
| 16:22 | chouser | I saw that in the wild -- shoot, where's that link... |
| 16:22 | LauJensen | bestinclass.dk ? :) |
| 16:23 | _fogus_ | I propose printing them as <(1 2 3)< |
| 16:23 | rhickey | any proposals for an api, printed representation, tests etc? |
| 16:23 | hiredman | _fogus_: :| |
| 16:23 | hiredman | dancing queues |
| 16:23 | _fogus_ | fish queues |
| 16:23 | hiredman | <()< >()> |
| 16:23 | rhickey | I'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:24 | chouser | the api is fine as-is, maybe add a 'queue' factory fn. printed is rarish, I would be ok with #=(queue a b c) |
| 16:24 | rhickey | and when we have an api for I/O queues? |
| 16:25 | chouser | LauJensen: nah, I think it was rosetta stone something, though I can't find it now. |
| 16:26 | chouser | wow there's a lot there: http://rosettacode.org/wiki/Category:Clojure |
| 16:27 | cemerick | rhickey: this your cue for a generalized queue interface ;-) |
| 16:27 | rhickey | cemerick: but it won't unify persistent and I/O queues |
| 16:27 | chouser | call it persistent-queue for now. *shrug* |
| 16:28 | cemerick | rhickey: I'm all about the tangents today. |
| 16:28 | chouser | ah, there it is: http://rosettacode.org/wiki/FIFO#Clojure |
| 16:29 | LauJensen | hehe |
| 16:29 | _fogus_ | chouser: Sounds like you just volunteered to fix that. ;) |
| 16:29 | chouser | someone didn't know about PersistentQueue and wrote one on vectors that leaks every item inserted. |
| 16:29 | chouser | _fogus_: I *was* going to educate the world about not doing that instead, but then you went and did it. |
| 16:39 | stuartsierra | rhickey: want to celebrate 1.1 at LispNYC tonight? |
| 16:40 | stuartsierra | (and anyone else, come on down) |
| 16:40 | stuartsierra | Tonight at 7, P&G's, 380 Columbus Ave. |
| 16:42 | stuartsierra | Be there, or be parenthetical. |
| 16:43 | duncanm | is deftype not in clojure 1.1? |
| 16:44 | chouser | duncanm: nope, in "master", slated for 1.2 |
| 16:53 | LauJensen | (apply str (mapcat #(map char %) (concat [(map inc [70 110 110 99 109 104]) (reverse '(33 116 104 103))]))) |
| 17:02 | ninjudd | is there any way to tell what type a struct object is? |
| 17:02 | hiredman | type? |
| 17:02 | kotarak | ninjudd: IPersistentMap |
| 17:02 | ninjudd | what type of struct |
| 17:03 | chouser | that's not really a type, it's more like which constructor you used. |
| 17:03 | chouser | or in other words, no you can't. |
| 17:03 | kotarak | ninjudd: you have to attach such information in the metadata |
| 17:04 | kotarak | ,(let [s (create-struct :a :b)] (type (with-meta (struct s 1 2) {:type ::MyType}))) |
| 17:04 | clojurebot | :sandbox/MyType |
| 17:04 | kotarak | ninjudd: structs don't have necessarily a name. |
| 17:04 | kotarak | ninjudd: what you probably want is defstruct from master |
| 17:04 | ninjudd | kotarak: i see, that makes sense |
| 17:05 | ninjudd | kotarak: does that add the metadata automatically? |
| 17:05 | kotarak | ninjudd: no. you have to do it manually with with-meta |
| 17:05 | ninjudd | ok |
| 17:06 | kotarak | (defn my-type [x y] (with-meta (struct my-type-struct x y) {:type ::MyType})) |
| 17:06 | kotarak | something like that |
| 17:06 | ninjudd | there isn't a struct? method either... |
| 17:07 | ninjudd | really, in this case, i just need to know if the type is PersistentStructMap |
| 17:07 | kotarak | ninjudd: let's try it the other way around: what are you trying to do? |
| 17:08 | kotarak | Maybe there is a different solution? |
| 17:09 | ninjudd | kotarak: i'm writing a method that i want to vary its behavior depending on whether a struct is passed in |
| 17:09 | chouser | (instance? clojure.lang.PersistentStructMap x) |
| 17:10 | ninjudd | kotarak: more specifically, i want to override the behavior of print for a specific struct type |
| 17:10 | kotarak | ninjudd: (defmethod print-method ::MyType ...) |
| 17:11 | ninjudd | kotarak: so i really need to make a new class in Java then? |
| 17:11 | kotarak | ninjudd: no. you have to attach metadata with type info |
| 17:11 | kotarak | ninjudd: print-method dispatches on type which checks for :type in the metadata |
| 17:11 | ninjudd | kotarak: oh, right |
| 17:12 | ninjudd | kotarak: ok, thanks |
| 17:12 | kotarak | ninjudd: checking on PersistentStructMap would change the behaviour for *all* struct maps, not just your type. |
| 17:12 | kotarak | ninjudd: np |
| 17:13 | ninjudd | chouser: 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:14 | ninjudd | class rather |
| 17:14 | kotarak | ninjudd: you'll find types pretty much uninteresting in Clojure, in general. |
| 17:14 | kotarak | A lot works by abstractions |
| 17:18 | technomancy | same as in Ruby actually, if you're using is_a? much something is probably wrong |
| 17:19 | ninjudd | technomancy: i'm not, i just didn't know how to do it |
| 17:20 | technomancy | speaking 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:20 | technomancy | not to mention trying to use isa? to check if an object is an instance of a class? |
| 17:22 | wilig | Getting 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:08 | arohner | technomancy: IIRC, you can blow your permgen in some cases just by creating too many anonymous functions |
| 18:08 | arohner | it has to do with the JVM GC'ing classes |
| 18:08 | arohner | the JVM doesn't GC classes unless their owning classloader is GC'd (I think) |
| 18:09 | technomancy | from what I understand closures are generated with their own classloader for precisely this reason |
| 18:09 | arohner | yes. A lot of clojure creates new classloaders and lets them be GC'd for exactly this |
| 18:10 | arohner | but it wouldn't surprise me if it were possible to create a situation where your fn isn't GC'd |
| 18:11 | technomancy | it's odd that it would happen without being accompanied by a regular memory leak though |
| 18:11 | technomancy | so it's mostly just use of eval and anonymous fns that cause runtime class generation, right? |
| 18:14 | arohner | I can't think of any others off the top of my head |
| 18:14 | arohner | aside from silly stuff like deftype in a loop |
| 18:15 | arohner | proxy and friends create classes |
| 18:18 | technomancy | oh, good point. I'll have to check that too |
| 18:26 | the-kenny | Anyone who can recommend me a good elisp tutorial? |
| 18:27 | trmsw | you're familiar with lisp? |
| 18:27 | the-kenny | trmsw: Of course |
| 18:28 | the-kenny | trmsw: Common Lisp and Clojure, to be precise |
| 18:28 | technomancy | the-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:28 | the-kenny | Maybe "Tutorial" isn't the right word. I'm searching for something like an introduction to programming Emacs |
| 18:28 | technomancy | in other words, Common Lisp should be a great introduction. =) |
| 18:29 | the-kenny | technomancy: Sounds like.. Common Lisp |
| 18:29 | the-kenny | :D |
| 18:29 | technomancy | the-kenny: have you checked the one in M-x info? it's not bad. |
| 18:30 | trmsw | it's probably better than any tutorial that tries to teach you lisp into the bargain |
| 18:30 | technomancy | generally M-x apropos and the describe-* commands are your friends when exploring the actual APIs |
| 18:30 | the-kenny | technomancy: I always forget the built-in stuff in Emacs.. I'll look at it |
| 18:33 | trmsw | the-kenny: somewhere there is a book on how to write Emacs modes, can't find it but I remember reading it... |
| 18:41 | mtm | you're probably thinking of "Writing GNU Emacs Extensions" http://oreilly.com/catalog/9781565922617/ |
| 19:22 | mebaran151 | how do you print out slime's classpath? |
| 19:23 | seths | mebaran151: not sure, but it might be using the contents of $HOME/.clojure |
| 19:23 | seths | probably more swank than slime, swank is the server side of slime |
| 19:24 | mebaran151 | no I'm pretty sure it's getting my classpath |
| 19:24 | mebaran151 | I just want to print it out to see what jars it's getting |
| 19:24 | seths | wait there was a post on the Clojure Google group recently |
| 19:24 | seths | checking... |
| 19:24 | mebaran151 | I launched it with swank-clojure-project |
| 19:24 | seths | oh |
| 19:25 | seths | that method asks for a base dir, and I *think* includes the contents of the lib directory |
| 19:26 | seths | that's how I run a repl from the new branch, since lein repl uses its internal version of clojure |
| 19:28 | technomancy | ,(System/getProperty "java.class.path") |
| 19:28 | clojurebot | java.security.AccessControlException: access denied (java.util.PropertyPermission java.class.path read) |
| 19:28 | technomancy | should work outside the sandbox |
| 19:28 | technomancy | won't work with lein swank though |
| 19:29 | mebaran151 | no magic swank vars |
| 19:38 | mebaran151 | cool that worked, thanks technomancy |
| 19:38 | mebaran151 | if 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:38 | crazzyford | techno I worked up an elisp function that works with my project layout to run tests from implimentation files |
| 19:41 | lisppaste8 | crazzyford pasted "test" at http://paste.lisp.org/display/93316 |
| 19:41 | crazzyford | something like that |
| 19:42 | seths | technomancy: the .gitignore from lein new FOO could use a "FOO-standalone.jar" line |
| 19:49 | technomancy | crazzyford: what about a command instead that just toggles between implementation and test? |
| 19:49 | technomancy | then you could build a "run tests for this ns" command in terms of that? |
| 19:49 | technomancy | seths: great idea, let's see a patch. =) |
| 19:49 | crazzyford | this seemed faster |
| 19:49 | crazzyford | for refactoring stuff at least |
| 19:50 | crazzyford | move stuff around, run some tests, move more stuff around, run some tests |
| 19:50 | technomancy | sure; I'm just saying they're both useful |
| 19:50 | crazzyford | aye aye capn |
| 19:50 | technomancy | and one could be implemented using the other |
| 19:51 | crazzyford | eventually will have a "get buffer for this implementation file" |
| 19:51 | crazzyford | and then can easily switch/run tests on said buffer |
| 19:51 | crazzyford | the only thing that bothers me about clojure-test-mode atm is changing the color of output based on tests passing/failing |
| 19:53 | crazzyford | I looked into it some, but it looks like the way to change face of the minibuffer is using a minibuffer hook |
| 19:55 | technomancy | changing 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:56 | crazzyford | if not might be able to flash the modeline green/red |
| 19:56 | crazzyford | maybe |
| 19:56 | crazzyford | minibuffer stuff looks difficult |
| 20:01 | crazzyford | ido does it, so must be possible in some way |
| 20:03 | crazzyford | aha (I think) |
| 20:04 | crazzyford | looks like you can use put-text-property inside the minibuffer |
| 20:05 | dnolen | technomancy: how can I get lein swank to use clojure new? does it just use the clojure inside leiningen/lib by default? |
| 20:05 | hiredman | new was merged into master |
| 20:06 | dnolen | hiredman: yes I saw that, but even so that's not the one that lein pulls down, so question is still the same :) |
| 20:07 | hiredman | I imagine if you change the version in your project.clj it will pull down what you ask for |
| 20:07 | qbg | If I have a symbol, how do I find the metadata that was associated with it when it was def'ed? |
| 20:08 | hiredman | def attaches metadata to the var, not the symbol |
| 20:08 | seths | dnolen: swank looks inside $HOME/.clojure which leiningen does not use |
| 20:09 | seths | I wrote a tool to update ~/.m2 and ~/.clojure with different versions of Clojure/Contrib |
| 20:09 | seths | http://bitbucket.org/seths/clojuggle/src/ |
| 20:09 | technomancy | dnolen: it should use the version of clojure inside your project's lib/ directory |
| 20:09 | seths | may or may not solve the problem tho |
| 20:10 | dnolen | technomancy: hmm doesn't seem to be doing that, i have clojure-new there. |
| 20:10 | seths | to clarify: when using M-x slime |
| 20:10 | technomancy | leiningen will run in leiningen's version of clojure, and your project will run in its own |
| 20:10 | dnolen | technomancy: do I need to build the lein-swank jar with clojure-new |
| 20:10 | dnolen | ? |
| 20:10 | technomancy | dnolen: the one place that doesn't apply yet is lein repl |
| 20:11 | technomancy | dnolen: if you build lein-swank with the latest leiningen it doesn't matter since no AOT is done |
| 20:11 | dnolen | technomancy: I am using lein from source |
| 20:12 | technomancy | dnolen: how are you checking the clojure version |
| 20:12 | technomancy | ? |
| 20:12 | dnolen | er, not scientifically that for sure. deftype isn't available :) |
| 20:13 | technomancy | I mean, lein swank + M-x slime connect, running the test suite, lein repl, etc. |
| 20:13 | dnolen | technomancy: I switch to the project dir, lein swank, connect from Emacs |
| 20:13 | hiredman | ,*clojure-version* |
| 20:13 | clojurebot | {:interim true, :major 1, :minor 1, :incremental 0, :qualifier "alpha"} |
| 20:13 | technomancy | dnolen: sounds like a bug; could you post to the lein mailing list? |
| 20:14 | dnolen | technomancy: sure |
| 21:07 | I314159 | is there a mod operator in clojure? |
| 21:07 | mitchellh | I314159: rem |
| 21:07 | mitchellh | ,(doc rem) |
| 21:07 | clojurebot | "([num div]); remainder of dividing numerator by denominator." |
| 21:08 | markgunnels | If I wanted to use deftype and defprotocol, what should I point my leiningen dependencies to? |
| 21:09 | dnolen | markgunnels: something like, :dependencies [[org.clojure/clojure "1.1.0-new-SNAPSHOT"]] |
| 21:09 | markgunnels | dnolen: thanks. |
| 21:09 | I314159 | ahh - thx |
| 21:10 | dnolen | np |
| 21:10 | markgunnels | dnolen: tried that and then ran lein repl and it greets me with: |
| 21:11 | markgunnels | Clojure 1.1.0-master-SNAPSHOT |
| 21:11 | markgunnels | user=> (doc deftype) |
| 21:11 | markgunnels | java.lang.Exception: Unable to resolve var: deftype in this context (NO_SOURCE_FILE:1) |
| 21:11 | dnolen | markgunnels: that might be related to an bug that I've just posted on the list |
| 21:11 | dnolen | do you see clojure new in your project lib folder? |
| 21:11 | markgunnels | dnolen: Yes. |
| 21:11 | dnolen | markgunnels: yes probably a bug. |
| 21:12 | markgunnels | dnolen: K. Suspected I was just being dense with this. Statistically more likely. :-) |
| 21:12 | seths | dnolen: not a bug |
| 21:12 | seths | lein repl uses the built in version clojure, not what's in lib |
| 21:12 | seths | it's a known issue |
| 21:13 | seths | your code in the src folder can still use deftype and defprotocol |
| 21:13 | dnolen | ah so well missing feature than that people seem to expect :) |
| 21:13 | markgunnels | seths: Ok. Thanks. |
| 21:13 | seths | agreed! |
| 21:14 | seths | markgunnels: if you are using emacs, try swank-clojure-project to get a repl with the contents of the lib/ directory |
| 21:14 | markgunnels | seths: I am. That was actually what I was just trying...:-) |
| 21:17 | markgunnels | seths: is there a special swank dev-dependency I need with the new branch? |
| 21:18 | markgunnels | #<CompilerException java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V (pprint.clj:1)> |
| 21:18 | markgunnels | Make sure swank-clojure is added as a dev-dependency in your project.clj. |
| 21:19 | markgunnels | seths: I may have misunderstood your earlier statement. |
| 21:20 | seths | markgunnels: not sure, let me check |
| 21:20 | seths | btw I am just a happy user of lein, not part of the project |
| 21:21 | markgunnels | seths: I am a VERY happy user of lein. |
| 21:21 | markgunnels | seths: It's very nice. Thanks for your help. |
| 21:24 | timothypratley | ,(doc mod) |
| 21:24 | clojurebot | "([num div]); Modulus of num and div. Truncates toward negative infinity." |
| 21:24 | markgunnels | seths: Don't spend too much time on it. I'll just write a little script to launch it outside of leiningen. |
| 21:25 | markgunnels | seths: Thanks again for your help. |
| 21:28 | seths | markgunnels: happy to help! |
| 21:29 | seths | markgunnels: I am able to use defprotocol from swank-clojure-project |
| 21:29 | seths | with this in my project.clj |
| 21:30 | seths | :dependencies [[org.clojure/clojure "1.1.0-new-SNAPSHOT"] |
| 21:30 | seths | [org.clojure/clojure-contrib "1.1.0-new-SNAPSHOT"]] |
| 21:30 | seths | |
| 21:30 | seths | :dev-dependencies [[lein-clojars "0.5.0-SNAPSHOT"] |
| 21:30 | seths | [leiningen/lein-swank "1.0.0-SNAPSHOT"]] |
| 21:44 | gstamp | curses. monad tutorial part 2 is down. http://onclojure.com/2009/03/06/a-monad-tutorial-for-clojure-programmers-part-2/ |
| 21:44 | gstamp | google cache to the rescue |
| 23:36 | defn` | in the ns macro is it correct to do [:use (foo bar baz)] where bar and baz are foo.bar and foo.baz? |
| 23:39 | ts00000 | is there a reason why (re-find #"(.*\b(\r))+") wouldn't work? |
| 23:40 | ts00000 | sorry, (re-find #"(.*\b(\r))+" x) |
| 23:40 | defn` | you have a " in the wrong spot? |
| 23:40 | defn` | oops nvm |
| 23:40 | ts00000 | my bad :) |
| 23:40 | chouser | defn`: you need round-parens around :use, not brackets |
| 23:40 | ts00000 | is there something awkward with the backref syntax or something |
| 23:40 | defn` | chouser: do i then need to quote my namespaces below it |
| 23:41 | defn` | [:use clojure.set (base ext1 ext2)] |
| 23:41 | chouser | defn`: I don't understand. But something like (ns foo (:use (clojure.contrib repl-utils seq-utils))) works |
| 23:41 | defn` | chouser: right but what about (:use (clojure core contrib set)) |
| 23:42 | defn` | oh nvm didnt read all of it |
| 23:42 | defn` | thank you |
| 23:42 | chouser | ,(re-find #"(.*\b(\r))+" "hi\r") |
| 23:42 | clojurebot | ["hi\r" "hi\r" "\r"] |
| 23:43 | chouser | ts00000: what's the problem? |
| 23:43 | chouser | defn`: but not core or contrib. core comes in automatically with 'ns', and contrib is not itself a namespace. |
| 23:44 | defn` | sure just an example |
| 23:44 | chouser | ok |
| 23:44 | ts00000 | chouser: what I want is a block to be used in a second regex. see http://pastie.org/776064 |
| 23:44 | defn` | chouser, i take it the same thing is true for :require and :import |
| 23:44 | ts00000 | I want one match to contain the first block before the newline, and the second to contain the second block |
| 23:45 | chouser | defn`: :require is almost identical to :use. :import is something else, though it does allow similar lists for class packages/names |
| 23:45 | defn` | but as far as syntax, i should be doing (:import (com.petebevin.markdown MarkdownProcessor)) |
| 23:45 | defn` | and not [:import...] |
| 23:45 | chouser | defn`: yes |
| 23:45 | defn` | cool, thank you |
| 23:47 | chouser | ts00000: you're trying to break that input at the blank line? |
| 23:47 | ts00000 | chouser: 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:48 | ts00000 | when I run my function designed to give me this, it just returns nil |
| 23:48 | ts00000 | but things like (.*) do what I expect |
| 23:48 | chouser | that regex appears to just be searching for a <CR> in the input |
| 23:49 | ts00000 | http://pastie.org/776071 is a "real" example of what I want |
| 23:49 | ts00000 | where x is the true input |
| 23:50 | ts00000 | and yes, what I want is to search for a <CR>, and give me the match up to the <CR> |
| 23:50 | chouser | a 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:50 | ts00000 | even with re-seq, I get no matches |
| 23:50 | chouser | ts00000: are you on a platform that uses \r for line endings rather than \n |
| 23:52 | ts00000 | chouser: 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:52 | ts00000 | I 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:52 | chouser | what do you mean by "backref"? |
| 23:53 | ts00000 | backreference |
| 23:53 | ts00000 | in the regular expression |
| 23:53 | ts00000 | to be used during the match |
| 23:53 | chouser | re-find returns a vector of n things where n is the number of groups in the regex plus one |
| 23:53 | chouser | the first is the whole match, the second your (.* ...)+ group, and the third your (\r) group |
| 23:54 | chouser | I think you might want something more like: (re-seq #"(?s).+?(?:\n\n|$)" x) |
| 23:55 | ts00000 | yup cho, you got it. thank you |
| 23:55 | ts00000 | working through regular expressions for the first time |
| 23:55 | ts00000 | is the oreilly book best for gaining clue rapidly? |
| 23:55 | chouser | ah! well, good luck to you. It's a challenging and rewarding subject. :-) |
| 23:56 | chouser | couldn't say, sorry. |
| 23:56 | chouser | I don't think your regex had any backrefs in it. were you thinking of the \b part or something else? |
| 23:58 | ts00000 | the \b part |
| 23:59 | chouser | in a java regex, anyway, that matches a word boundary. |
| 23:59 | chouser | so, not a backreference |