#clojure logs

2008-10-15

00:37Chouserjcrites: -> is good, as is ..
00:43johnwaynerah cool...proxy-super
00:44johnwaynerThe API doc for proxy lead me to believe that didn't exist. So thanks :)
01:14Lau_of_DKMorning gents
01:58Lau_of_DKMorning hoeck :)
01:58Lau_of_DKI noticed you hadn't annoted my lisppaste with a simple yet effective solution *wink* *hint* *hint*
02:59joel`This is the error I get when I start swank-clojure:
02:59joel`http://paste.lisp.org/display/63396
02:59joel`can anyone help me
03:01joel`user=> java.lang.Exception: Unable to resolve symbol: *1 in this context
03:01tWipuse latest SVN clojure
03:02joel`I'll have to build clojure after checking out from SVN right?
03:02tWipyes
03:02joel`ok, thanks
03:02tWipyour paste seems to complain about progn not *1... that might be something else
03:04joel`the repl starts and I'm able to use it .. but the slime connection doesn't happen, and I can't eval code directly from clojure-mode
03:05joel`seemlingly because of the exception JVM throws, as above
03:07joel`I am new to Clojure, where can I find instructions to build clojure from source?
03:08joel`ah, got it. never mind
03:12Lau_of_DKIs there a guide somewhere to all the syntactic bits of Clojure, like all the little curls you can put in Macros for different effectns, and all the #^ and #() and so on ?
03:13jdzLau_of_DK: read the source of the reader?
03:14hoeckLau_of_DK: good morning, or: http://clojure.org/reader
03:16Lau_of_DKThanks alot hoeck
03:16Lau_of_DKjdz, thats exactly what I wanted to avoid :)
03:17jdzLau_of_DK: reading source is a *very* good way to learn programming.
03:17jdzespecially the source of geniuses
03:18Lau_of_DKtrue, but it feeds into my discontentment of the current documentation
03:18jdz(i might be exaggerating a bit)
04:08joel`hey guys
04:08joel`the latest svn checked out clojure gives the following error on boot
04:08joel`Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.eval__1 (boot.clj:0)
04:12yangsxjole`: clojure is fasting moving, just use older version, svn 1060 is safe for me
04:12joel`ok :)
04:16joel`nice, 1060 works
04:16Lau_of_DKjoel, did you remember to clean-up before trying the new version?
04:17joel`I checked it out to a different directory
04:22joel`Lau_of_DK: apparently, the problem was with swank
04:22joel`The error when starting slime is: user=> java.lang.Exception: Unable to resolve symbol: *1 in this context
04:22joel`clojure.lang.Compiler$CompilerException: core.clj:124: Unable to resolve symbol: *1 in this context
04:22joel`core.clj, line 24 is:
04:22joel` (dothread-keeping [*out* *ns* *current-connection* *1 *2 *3 *warn-on-reflection*]
04:23joel`hmm
04:26joel`any clue ?
04:33hoeckjoel`: the *1 *2 *3 are referencing the last repl-results, you may comment them out
04:35hoeckphew, everyone is using slime these days, maybe i should abandon ilisp mode
04:40joel`wow - It worked now
04:40joel`6 hours !!
04:40joel`thanks hoeck !!
04:40joel`holy crap .. phew
04:41joel`yea slime is nice
04:42joel`hoeck: what side effects might losing *1 *2 *3 have on swank-clojure?
04:43hoeckjoel`: not having those shortcut-symbols available at the repl
04:43joel`ah
04:44joel`:-) works for me
04:45joel`by the way, emacs clojure-mode is neat :-)
04:45hoeckbut I'm downloading slime right now, ilisp mode is really slow here
04:45hoeckhaven't had a chance to try it yet :(
04:45joel`I see.
04:46joel`I checked out 1060 clojure, and the latest swank-clojure on the git
04:46joel`If you want, I'll send you core.clj and basic.clj (swank-clojure) - or you might run into the same problems I did.
04:46joel`I'll also send you my .emacs file, if you wish.
04:47hoecki have an .xemacs file : )
04:47joel`uhh, ok. :)
04:49hoeckbut i'm on windows, don't know how to install slime there
04:49joel`I see.
04:49joel`did you check out the wiki ?
04:52hoeckyeah, and the slime homepage, now I'm trying to load the bare *.el files
05:10Lau_of_DKuser=> (def lst '(1 2 3 4))
05:10Lau_of_DK#'user/lst
05:10Lau_of_DKuser=> `~@lst
05:10Lau_of_DKjava.lang.IllegalStateException: splice not in list
05:10Lau_of_DKWhy cant this list be spliced in backquotes ?
05:10hoeckLau_of_DK: because its not in a list, try `(~@lst)
05:11Lau_of_DKThanks
05:11Lau_of_DKMental distortion it seems
05:12hoecknp
05:24hoeckjoel: how do you start clojure from slime, do you use a shellscript or directly from emacs?
05:25joel`directly from emacs
05:25joel`you execute (slime 'clojure) and it loads
05:27hoeckand how do you set the clojure.jar and java path?
05:38joel`hmm
05:38joel`one sec, will tell you
05:38joel`follow the instructions at: http://en.wikibooks.org/wiki/Clojure_Programming#Emacs_.2F_Slime_Integration
05:38joel`That should do it.
06:33joel`hello rhickey
06:33rhickeyjoel`: hi
10:12blackdoga world of hurt; i see nothing but issues with it :)
10:12blackdogon the group
10:13asbjxrnCompletion?
10:13danm_rhickey: do you just run a repl in a shell or something?
10:14rhickeyinferior-lisp
10:14asbjxrnThere is also some handling of the stacktrace when a exception happens.
10:14rhickeyasbjxrn: I get some hippie completion with clojure-mode, what's the basis for completion in Slime?
10:14asbjxrnBut I just started using slime (with clojure) a day or two ago so I haven't explored much.
10:15blackdogwhat's hippie completion ?
10:15blackdogM-\
10:15asbjxrnOh, I never got completion in clojure-mode, maybe it was added later(?) and I never used it?
10:18rhickeyblackdog: just completes by trying to find word in loaded buffers
10:19blackdogyep, i have it now,
10:19drewrM-/ ...not M-\
10:19rhickeyso, I just load up boot.clj and get a lot for free that way
10:20achim_p_the two things i like about slime: it shows the arglists of the function call you're writing in the minibuffer, and it handles history input-wise, not line-wise. other than that, it doesn't make much of a difference to me, but then, i started using emacs with clojure, so i might be missing something
10:21asbjxrnHmm. looks like the error-dialog in slime is not that useful for clojure, expanding a level at the stack trace only shows [no locals] even if there are locals.
10:23asbjxrnI have a strange problem with a swing/awt app. Sometimes when I launch it with java -jar foo.jar it doesn't react to keypresses. If I double-click in finder, it always works (so far.)
10:24asbjxrnAm I doing something wrong, or is this a known issue? (I guess this is not really a clojure question :)
10:28drewrOne nice thing about Clojure's Swank/SLIME is that execution happens in a separate thread automatically, so when I have a long-running db query or calculation I can still have a responsive REPL.
10:33achim_p_rhickey: slime uses ns-publics for completion, which works pretty well (see "simple-completions" in http://github.com/jochu/swank-clojure/tree/master/swank/commands/basic/basic.clj)
10:58blackdog(doc cond) could do with a mention of :else
11:04wwmorganblackdog: :else doesn't actually mean anything in the context of cond
11:04wwmorganyou could replace it with :foo
11:05blackdogoh, ok, i was looking at defmacro doc and it used :else,
11:05blackdogin boot.clj
11:07wwmorganYes. So rhickey's convention is to use :else, but you can use anything that always evaluates to logical truth
11:08blackdogyes, i see, looking at defmacro cond, so that means it could take multiple :thing and only the last would be useful
11:09wwmorganthe _first_ one, I believe: (cond :foo 1 :bar 2) => 1
11:09blackdogok, thanks for the clarification
11:09ChouserUsing :else is a pretty good convention -- it could probably still stand to be mentioned in the docs, even if it's not enforced by anything.
11:10wwmorganthat's true: I have seen some code like (cond (> x 5) foo (< x 4) bar)
11:10Chouserbefore I knew the convention I assumed the proper value to use was "true"
11:10Chouserbut of course ":else" is much nicer
11:25rhickeywwmorgan: there are cases where no :else is desired, defaults to nil then
11:30danlarkinI like CL/scheme's use of the truth literal for "else", but it's all the same in the end I guess eh
11:33rhickeydanlarkin: sometimes T/true is one of the return values, :else rarely is - without the extra parens of CL's cond, this matters more for Clojure's readability
11:47danlarkinrhickey: makes sense
11:55drewrI'm not seeing a method in Keyword.java to return a string representation without a colon. Is there existing functionality somewhere for that?
11:55wwmorgandrewr: (name :foo) => "foo"
11:56drewrwwmorgan: Thanks.
12:52hircushas anyone tried the latest SVN revision? it's giving me weird errors
12:53hircushttp://paste.lisp.org/display/68573
12:54Chouserhircus: it's an "intermediate" checkin -- you might prefer one revision earlier
12:54hircusChouser: aha, thanks
12:56Chouseror you can try adding ./gen to your java classpath, but i haven't done that.
12:57drewrChouser: That works, but it's relative to user.dir.
13:03hircusswitching to r1067 for now -- I don't feel like messing with my SLIME/swank set-up
13:03hircusbless git-svn for being able to roll back to a previous revision without hitting the server :)
13:09danlarkin<3 git-svn
13:11rhickeyrev 1069 removes interim use of gen dir
13:12hircusrhickey: neat
13:13hircusdanlarkin: hg is what I use whenever I don't need svn integration -- unless the project is Unix-specific. but both are great :)
13:20Chousergit-svn is lovely
15:18arnfredis there any way I can repeat the last command in the clojure REPL without copying and pasting it?
15:19arnfredor is there a way I can reload a file without specifying the whole path?
15:19rhickeyarnfred: are you running a raw repl, or using emacs/jline etc?
15:19danlarkin*1 I believe?
15:19arnfredraw repl
15:20rhickeydanlarkin: *1 gives you the last result
15:20arnfredI'm using vim
15:20arnfredso I haven't gotten any integration set up
15:21rhickeyarnfred: using some enhanced command line is recommended - the above or rlwrap
15:21rhickeythey all have command history
15:22rhickeythere are some vim users here, perhaps will chime in with what they do
15:22arnfredI'll take a look at rlwrap, thanks
15:23arnfredand btw thanks for a kick-ass language : )
15:24rhickeyarnfred: you're welcome! also check out Chimp: http://kotka.de/projects/chimp.html
15:24rhickeydiscussed here: http://groups.google.com/group/clojure/browse_frm/thread/2085d67f987a14a8/2ef06654cec81a3c
15:28drewrI'd like to parallelize fetching from a database. Right now I pull down chunks of a few hundred rows and concat them together in a lazy stream.
15:29drewrThere's no reason why those batches can't be run simultaneously in order to maximize bandwidth.
15:29drewrI'm thinking of dispatching an agent for each batch that:
15:31drewrStarts with a PK offset, creates a connection, runs the query, closes the connection.
15:32drewrI only want to run 10 at a time.
15:34drewrThey need to find out if there is any data left to retrieve first.
15:34drewrThis quickly gets much more complicated.
15:34drewrDo you guys know of a good example of this kind of behavior (in any language) to look at?
15:35rhickeydrewr: can you not get the total size up front?
15:36drewrI could.
15:36rhickeythen you could turn the set of batches into a sequence and pmap it
15:38rhickeyit only runs #availableProcessors threads ahead
15:39drewrThanks, I'll work with that and see what I come up with.
15:52Chouser(-> "hi" prn with-out-str)
15:52ChouserAbusive. Please don't do it.
16:00drewrSince what I want to parallelize isn't processor bound but network bound, would I gain performance by surpassing availableProcessors?
16:04rhickeymaybe, you could make a variant of pmap that took a number-of-agents arg
16:04wwmorgandrewr: do you want exactly one threading fetching from the database at any given time?
16:04wwmorgans/threading/thread
16:07drewrwwmorgan: Not necessarily. I was thinking 5 or 10 threads each using a separate connection would be a good starting point.
16:27chmuIs it illeal to use vars created with (with-local-vars) in closures?
16:27chmueg, (def foo (with-local-vars [x 123] (fn [] (var-get x))))
16:28Chouserthat var x won't be bound anymore by the time you call foo
16:29Chouserif you want lexical behavior (like closures are) you'll need a lexical local, like (let) creates
16:29chmuChouser: Ok, but I want update the value.
16:29scottjI'm new to regular expressions, and I just read the Sun Java Tutorial on them, but is there not an easy way to designate inside my regex what I section I really care about and want returned? For example, if I want to find the numbers that are surrounded by "foo" and "bar", isn't there an easier way than returning "foo1234bar" and then manually breaking it apart?
16:30Chouserchmu: ok, I'm not sure but I think vars aren't going to work for you then. I guess you'd have to use a ref instead.
16:30cemerickscottj: you're thinking of groups
16:31cemerickscottj: the regex for the example you cite would be foo(\d+)bar
16:31Chouserscottj: (re-find #"foo([0-9]*)bar" "foo1234bar")
16:32Chouseryeah, \d is fine as long as you quote it again for clojure. :-/
16:32chmuChouser: Is it possible to created unnamed vars "non-locally" then?
16:33drewrscottj: If you just want the numbers, (re-find #"[0-9]+" "foo1234bar").
16:33drewrNo grouping there.
16:34Chouserchmu: You're pushing my knowledge here, but I don't think so. Even named vars (def foo) only get to keep their thread-local values within a (binding) call.
16:34Chouserchmu: once you "return" out of the binding, they drop back to their root values (which aren't really meant to be changed much at runtime).
16:34drewrscottj: BTW, #"" is Clojure syntax for a java.util.regex.Pattern.
16:35Chouserchmu: if you want a mutable thing to hang onto its value as seen from any thread, you want a ref
16:36chmuChouser: Ok, thanks. I will try refs instead.
16:37Chouserchmu: sorry if I mislead you into using vars before.
16:38chmuChouser: No worries :)
16:46scottj(re-seq #"foo([0-9[\\.E\\-]]+)bar" "foo1.23E-4bar foo12bar") this seems to work for me, but I don't understand why I can't replace re-seq with (re-groups (re-matcher
16:51Chouserscottj: be aware that the double-backslashes will need to be single-backslashes in some hopefully imminent version of clojure.
16:52rhickeyChouser: is that regex patch compatible with latest? I'll put it in right now
16:53Chouserscottj: and to get re-groups to work, you need to call .find on the matcher first -- it mutates each time you call .find
16:53Chouserrhickey: I'll check.
16:55Chouserrhickey: "patch" appears to guess correctly
16:55arnfredis there any predefined functions for folding a list in clojure?
16:55kotarakrhickey: can you check the error message, when a class is not found in an import? It now says "NoClassDefFoundError: <vector - 1 items>". It would by nice, if it said, which class it doesn't find...
16:55rhickeyarnfred: reduce is foldl
16:56arnfredrhickey, that works, thanks!
17:05rhickeyChouser: the future is now - regex patch applied (rev 1070)
17:05rhickeythanks!
17:09Chouserexcellent, thank you.
17:10rhickeyI'll be sending all support traffic your way :)
17:10Chouserheh, I bet.
17:10rhickeyActually I think it is very straightforward, just happens to be a breaking change
17:10Chouserwell, my exhaustive test suite passes (all 3 tests) so I'm sure we're good.
17:13drewrI'll run my nonexistent test suite on it just to make sure.
17:14rhickeyChouser: do you have a proposed modification to the reader docs?
17:14Chousernope, but I can work on that.
17:14Chousergotta go
17:30kotarakrhickey: I'm sorry for my previous message. The problem is not the message, it's my stupidity. I'm sorry for the inconvenience....
17:31rhickeykotarak: no problem
17:31rhickeyeveryone makes mistakes!
17:31kotarakI messed up gen-interface usage.
18:24nicknulli noticed a really cool thing about clojure(maybe all lips then). if i have defined a class(in my own class-system) i can add new methods after it is defined and an instance created without having to restart the interpreter. very nice and handy sometimes!
18:24nicknullbah
19:21Chouserrhickey: looks like the existing Regex reader docs are sufficiently vague that they're still accurate.
19:21rhickeyuh oh
19:21Chouser:-)
19:22ChouserI'll see what I can do.
19:23nicknullhow do you so regexps in clojure?
19:23rhickeySomething expressing in terms of - just like Java pattern strings except ___
19:23nicknull\d+ for example
19:23rhickeynicknull: #"regexpatternhere"
19:24nicknull# again? is the shorthand for lambdas a regexp?
19:24Chousernicknull: (re-find #"\d+" "abcde12345fghij")
19:24nicknullliek (map #(* % 2) '(1 2 3))
19:25Chousernicknull: nope, you need to look at the char after # -- #() vs #{} vs #""
19:25rhickeynicknull: # is a general reader escape character
19:25nicknulloh yeah i see
19:26rhickeythe 2 things it tells you are - the next character matters, and it happens at read time
19:26Chouser(find-doc "regex")
19:27nicknull"{} when is that used?
19:27nicknullmultimethods?
19:28nicknulldoes regexes have to be imported?
19:28nicknulland downloaded too?
19:29nicknull(import regex) just hangs the interpreter... i knwo its wrong but shouldnt it generate an error instead?
19:29ChouserHuh. #{} is not documented at http://clojure.org/reader
19:29Chousernicknull: nope, import nothing for the regex features we've discussed so far.
19:29rhickeyChouser: sure it is, right after maps
19:30Chouserrhickey: oh, sorry -- looking under "Dispatch (#)"
19:30rhickeybut not in the dispatch section
19:30nicknull(re-find #"\d+" "abcde12345fghij") -> java.lang.Exception: Unsupported escape character: \d
19:30nicknullwhere is the doc for the regex.syntax then?
19:30Chousernicknull: need a newer version. :-)
19:30nicknull\d+ is standard...
19:31nicknullChouser: i have sep 16 of clojure
19:31Chouserwe're talking about a patch that Rich put in mere hours ago.
19:31nicknulllol ok
19:32ChouserFor your version you need to quote your \ like: #"\\d+"
19:32rhickeyChouser: added a mention of set syntax in dispatch section
19:32Chouserrhickey: thanks :-)
19:33nicknulland re-findall doesn exist? is there some equal?
19:33ChouserJava doesn't have a regex literal syntax, right? so the old behavior looks more like Java than the new behavior does.
19:34Chousernicknull: (find-doc "regex")
19:34Chousernicknull: perhaps you want re-seq
19:34rhickeyChouser: right, the old format was the string you'd have to use in Java, prefixed by #
19:35nicknullah re-seq
19:36nicknullyes, v nice i look clojure more and more, it svery nice to work with and very mature for being so young. and very practical contrary to other lisps
20:28pjb3rhickey: I saw the breaking change for regex literals, I'm in favor of that
20:29rhickeypjb3: ok - change is in rev 1070
20:30pjb3rhickey: I saw you applied the non-backwards compatible change for regex literals, which I like, but I'm wondering if there is going to be a point where clojure have specific releases
20:31rhickeypjb3: I'm going to get a few breaking changes in before 1.0, the regex, binding forms in vectors, and whatever I need for AOT compilation
20:32pjb3sounds good
20:32pjb3just wondering if that was the plan, to have version numbers
20:32rhickeyWe discussed my plans for release numbers yesterday: http://clojure-log.n01se.net/date/2008-10-14.html
20:43pjb3The only reason I think of version numbers is just to let people know if they should expect non-backward compatible changes
20:43pjb3So all the code that runs on clojure 1.0.0 should theoretically work with 1.0.x, aside from any bugs
20:44pjb3where as 1.1 may have minor changes that could break things, or 1.1 has new features that 1.0 doesn't
20:44pjb3basically the way the JVM works
20:44pjb31.5.0 vs. 1.5.1 vs. 1.6
20:44pjb3or, Java I should say
20:45rhickeyEveryone has their own interpretation of each 'place' - we were only discussing major.minor, and there are those who think breaking changes warrant major increment
20:46rhickeywith a 3 place system, major.minor.rev, I could still get my year.release.rev logic
22:39emacsenrhickey, so, I just read, you spoke with Guy Steele, etc. in the audience. Did they give you any feedback?
22:40rhickeyemacsen: no - Guy left during the talk after mine and wasn't at the conference the following day.
22:42emacsenthat's too bad. It'd be nice to know what he thinks, especially in light of his participation with Fortress too
22:42emacsensince it also runs on the JVM
22:42emacsen(not stating the other obvious connections)
22:43rhickeyI'll see him again at OOPSLA on Monday
22:43emacsentrue. Can't wait to see the video from that, if there is any
22:44rottcoddwhat's the idiomatic way of reading the lines of a file into a vector?
22:46rhickey(vec (line-seq rdr))
22:47rottcoddthanks
22:48rottcodd(I knew it would be a 1 liner but didn't know about line-seq)
22:50Chousergetting a rdr for a filename is only barely a one-liner (without duck-streams)
22:51rottcodd(new BufferedReader (new FileReader filename))
22:51Chouserhm
22:51Chouser(-> filename FileReader. BufferedReader. line-seq vec)
22:51ChouserI guess those count as 1 liners.
22:52rottcoddI mainly wanted to avoid explicit recursion
22:53Chouserok.
22:53Chousersorry, the number of classes need to do java.io generally annoys me.
23:13pjb3So I've been trying to figure out this class loader issue when using gen-class-and-load
23:13pjb3http://gist.github.com/16843
23:14pjb3The java code is for velocity, to change the way it does look ups of properties
23:14pjb3To use keywords for clojure maps
23:15pjb3The velocity.clj is my attempt to try do that in clojure
23:16pjb3Anyway, the error I get when velocity tries to load is: java.lang.Exception: The specified class for Uberspect (clojure.velocity.ClojureUberspectImpl)
23:16pjb3But if I eval this: (Class/forName "clojure.velocity.ClojureUberspectImpl")
23:16pjb3it finds the class
23:17pjb3I've traced through the velocity source code, and it calls Class.forName("clojure.velocity.ClojureUberspectImpl")
23:17pjb3so why would that work in clojure but not in Java?