#clojure log - Oct 15 2008

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:37 Chouser: jcrites: -> is good, as is ..

0:43 johnwayner: ah cool...proxy-super

0:44 The API doc for proxy lead me to believe that didn't exist. So thanks :)

1:14 Lau_of_DK: Morning gents

1:58 Morning hoeck :)

1:58 I noticed you hadn't annoted my lisppaste with a simple yet effective solution *wink* *hint* *hint*

2:59 joel`: This is the error I get when I start swank-clojure:

2:59 http://paste.lisp.org/display/63396

2:59 can anyone help me

3:01 user=> java.lang.Exception: Unable to resolve symbol: *1 in this context

3:01 tWip: use latest SVN clojure

3:02 joel`: I'll have to build clojure after checking out from SVN right?

3:02 tWip: yes

3:02 joel`: ok, thanks

3:02 tWip: your paste seems to complain about progn not *1... that might be something else

3:04 joel`: 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

3:05 seemlingly because of the exception JVM throws, as above

3:07 I am new to Clojure, where can I find instructions to build clojure from source?

3:08 ah, got it. never mind

3:12 Lau_of_DK: Is 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 ?

3:13 jdz: Lau_of_DK: read the source of the reader?

3:14 hoeck: Lau_of_DK: good morning, or: http://clojure.org/reader

3:16 Lau_of_DK: Thanks alot hoeck

3:16 jdz, thats exactly what I wanted to avoid :)

3:17 jdz: Lau_of_DK: reading source is a *very* good way to learn programming.

3:17 especially the source of geniuses

3:18 Lau_of_DK: true, but it feeds into my discontentment of the current documentation

3:18 jdz: (i might be exaggerating a bit)

4:08 joel`: hey guys

4:08 the latest svn checked out clojure gives the following error on boot

4:08 Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.eval__1 (boot.clj:0)

4:12 yangsx: jole`: clojure is fasting moving, just use older version, svn 1060 is safe for me

4:12 joel`: ok :)

4:16 nice, 1060 works

4:16 Lau_of_DK: joel, did you remember to clean-up before trying the new version?

4:17 joel`: I checked it out to a different directory

4:22 Lau_of_DK: apparently, the problem was with swank

4:22 The error when starting slime is: user=> java.lang.Exception: Unable to resolve symbol: *1 in this context

4:22 clojure.lang.Compiler$CompilerException: core.clj:124: Unable to resolve symbol: *1 in this context

4:22 core.clj, line 24 is:

4:22 (dothread-keeping [*out* *ns* *current-connection* *1 *2 *3 *warn-on-reflection*]

4:23 hmm

4:26 any clue ?

4:33 hoeck: joel`: the *1 *2 *3 are referencing the last repl-results, you may comment them out

4:35 phew, everyone is using slime these days, maybe i should abandon ilisp mode

4:40 joel`: wow - It worked now

4:40 6 hours !!

4:40 thanks hoeck !!

4:40 holy crap .. phew

4:41 yea slime is nice

4:42 hoeck: what side effects might losing *1 *2 *3 have on swank-clojure?

4:43 hoeck: joel`: not having those shortcut-symbols available at the repl

4:43 joel`: ah

4:44 :-) works for me

4:45 by the way, emacs clojure-mode is neat :-)

4:45 hoeck: but I'm downloading slime right now, ilisp mode is really slow here

4:45 haven't had a chance to try it yet :(

4:45 joel`: I see.

4:46 I checked out 1060 clojure, and the latest swank-clojure on the git

4:46 If you want, I'll send you core.clj and basic.clj (swank-clojure) - or you might run into the same problems I did.

4:46 I'll also send you my .emacs file, if you wish.

4:47 hoeck: i have an .xemacs file : )

4:47 joel`: uhh, ok. :)

4:49 hoeck: but i'm on windows, don't know how to install slime there

4:49 joel`: I see.

4:49 did you check out the wiki ?

4:52 hoeck: yeah, and the slime homepage, now I'm trying to load the bare *.el files

5:10 Lau_of_DK: user=> (def lst '(1 2 3 4))

5:10 #'user/lst

5:10 user=> `~@lst

5:10 java.lang.IllegalStateException: splice not in list

5:10 Why cant this list be spliced in backquotes ?

5:10 hoeck: Lau_of_DK: because its not in a list, try `(~@lst)

5:11 Lau_of_DK: Thanks

5:11 Mental distortion it seems

5:12 hoeck: np

5:24 joel: how do you start clojure from slime, do you use a shellscript or directly from emacs?

5:25 joel`: directly from emacs

5:25 you execute (slime 'clojure) and it loads

5:27 hoeck: and how do you set the clojure.jar and java path?

5:38 joel`: hmm

5:38 one sec, will tell you

5:38 follow the instructions at: http://en.wikibooks.org/wiki/Clojure_Programming#Emacs_.2F_Slime_Integration

5:38 That should do it.

6:33 hello rhickey

6:33 rhickey: joel`: hi

9:55 * hoeck is now a happy slime user

10:11 * rhickey wonders what he's missing not using Slime, just clojure-mode

10:12 blackdog: a world of hurt; i see nothing but issues with it :)

10:12 on the group

10:13 asbjxrn: Completion?

10:13 danm_: rhickey: do you just run a repl in a shell or something?

10:14 rhickey: inferior-lisp

10:14 asbjxrn: There is also some handling of the stacktrace when a exception happens.

10:14 rhickey: asbjxrn: I get some hippie completion with clojure-mode, what's the basis for completion in Slime?

10:14 asbjxrn: But I just started using slime (with clojure) a day or two ago so I haven't explored much.

10:15 blackdog: what's hippie completion ?

10:15 M-\

10:15 asbjxrn: Oh, I never got completion in clojure-mode, maybe it was added later(?) and I never used it?

10:18 rhickey: blackdog: just completes by trying to find word in loaded buffers

10:19 blackdog: yep, i have it now,

10:19 drewr: M-/ ...not M-\

10:19 rhickey: so, I just load up boot.clj and get a lot for free that way

10:20 achim_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:21 asbjxrn: Hmm. 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:23 I 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:24 Am I doing something wrong, or is this a known issue? (I guess this is not really a clojure question :)

10:28 drewr: One 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:33 achim_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:58 blackdog: (doc cond) could do with a mention of :else

11:04 wwmorgan: blackdog: :else doesn't actually mean anything in the context of cond

11:04 you could replace it with :foo

11:05 blackdog: oh, ok, i was looking at defmacro doc and it used :else,

11:05 in boot.clj

11:07 wwmorgan: Yes. So rhickey's convention is to use :else, but you can use anything that always evaluates to logical truth

11:08 blackdog: yes, i see, looking at defmacro cond, so that means it could take multiple :thing and only the last would be useful

11:09 wwmorgan: the _first_ one, I believe: (cond :foo 1 :bar 2) => 1

11:09 blackdog: ok, thanks for the clarification

11:09 Chouser: Using :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:10 wwmorgan: that's true: I have seen some code like (cond (> x 5) foo (< x 4) bar)

11:10 Chouser: before I knew the convention I assumed the proper value to use was "true"

11:10 but of course ":else" is much nicer

11:25 rhickey: wwmorgan: there are cases where no :else is desired, defaults to nil then

11:30 danlarkin: I like CL/scheme's use of the truth literal for "else", but it's all the same in the end I guess eh

11:33 rhickey: danlarkin: 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:47 danlarkin: rhickey: makes sense

11:55 drewr: I'm not seeing a method in Keyword.java to return a string representation without a colon. Is there existing functionality somewhere for that?

11:55 wwmorgan: drewr: (name :foo) => "foo"

11:56 drewr: wwmorgan: Thanks.

12:52 hircus: has anyone tried the latest SVN revision? it's giving me weird errors

12:53 http://paste.lisp.org/display/68573

12:54 Chouser: hircus: it's an "intermediate" checkin -- you might prefer one revision earlier

12:54 hircus: Chouser: aha, thanks

12:56 Chouser: or you can try adding ./gen to your java classpath, but i haven't done that.

12:57 drewr: Chouser: That works, but it's relative to user.dir.

13:03 hircus: switching to r1067 for now -- I don't feel like messing with my SLIME/swank set-up

13:03 bless git-svn for being able to roll back to a previous revision without hitting the server :)

13:09 danlarkin: <3 git-svn

13:10 * drewr <3 git

13:11 rhickey: rev 1069 removes interim use of gen dir

13:12 hircus: rhickey: neat

13:13 danlarkin: hg is what I use whenever I don't need svn integration -- unless the project is Unix-specific. but both are great :)

13:14 * drewr also <3 new object pretty printing

13:20 Chouser: git-svn is lovely

15:18 arnfred: is there any way I can repeat the last command in the clojure REPL without copying and pasting it?

15:19 or is there a way I can reload a file without specifying the whole path?

15:19 rhickey: arnfred: are you running a raw repl, or using emacs/jline etc?

15:19 danlarkin: *1 I believe?

15:19 arnfred: raw repl

15:20 rhickey: danlarkin: *1 gives you the last result

15:20 arnfred: I'm using vim

15:20 so I haven't gotten any integration set up

15:21 rhickey: arnfred: using some enhanced command line is recommended - the above or rlwrap

15:21 they all have command history

15:22 there are some vim users here, perhaps will chime in with what they do

15:22 arnfred: I'll take a look at rlwrap, thanks

15:23 and btw thanks for a kick-ass language : )

15:24 rhickey: arnfred: you're welcome! also check out Chimp: http://kotka.de/projects/chimp.html

15:24 discussed here: http://groups.google.com/group/clojure/browse_frm/thread/2085d67f987a14a8/2ef06654cec81a3c

15:28 drewr: I'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:29 There's no reason why those batches can't be run simultaneously in order to maximize bandwidth.

15:29 I'm thinking of dispatching an agent for each batch that:

15:31 Starts with a PK offset, creates a connection, runs the query, closes the connection.

15:32 I only want to run 10 at a time.

15:34 They need to find out if there is any data left to retrieve first.

15:34 This quickly gets much more complicated.

15:34 Do you guys know of a good example of this kind of behavior (in any language) to look at?

15:35 rhickey: drewr: can you not get the total size up front?

15:36 drewr: I could.

15:36 rhickey: then you could turn the set of batches into a sequence and pmap it

15:38 it only runs #availableProcessors threads ahead

15:39 drewr: Thanks, I'll work with that and see what I come up with.

15:52 Chouser: (-> "hi" prn with-out-str)

15:52 Abusive. Please don't do it.

16:00 drewr: Since what I want to parallelize isn't processor bound but network bound, would I gain performance by surpassing availableProcessors?

16:04 rhickey: maybe, you could make a variant of pmap that took a number-of-agents arg

16:04 wwmorgan: drewr: do you want exactly one threading fetching from the database at any given time?

16:04 s/threading/thread

16:07 drewr: wwmorgan: Not necessarily. I was thinking 5 or 10 threads each using a separate connection would be a good starting point.

16:27 chmu: Is it illeal to use vars created with (with-local-vars) in closures?

16:27 eg, (def foo (with-local-vars [x 123] (fn [] (var-get x))))

16:28 Chouser: that var x won't be bound anymore by the time you call foo

16:29 if you want lexical behavior (like closures are) you'll need a lexical local, like (let) creates

16:29 chmu: Chouser: Ok, but I want update the value.

16:29 scottj: I'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:30 Chouser: chmu: 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:30 cemerick: scottj: you're thinking of groups

16:31 scottj: the regex for the example you cite would be foo(\d+)bar

16:31 Chouser: scottj: (re-find #"foo([0-9]*)bar" "foo1234bar")

16:32 yeah, \d is fine as long as you quote it again for clojure. :-/

16:32 chmu: Chouser: Is it possible to created unnamed vars "non-locally" then?

16:33 drewr: scottj: If you just want the numbers, (re-find #"[0-9]+" "foo1234bar").

16:33 No grouping there.

16:34 Chouser: chmu: 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:34 chmu: 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:34 drewr: scottj: BTW, #"" is Clojure syntax for a java.util.regex.Pattern.

16:35 Chouser: chmu: if you want a mutable thing to hang onto its value as seen from any thread, you want a ref

16:36 chmu: Chouser: Ok, thanks. I will try refs instead.

16:37 Chouser: chmu: sorry if I mislead you into using vars before.

16:38 chmu: Chouser: No worries :)

16:46 scottj: (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:51 Chouser: scottj: be aware that the double-backslashes will need to be single-backslashes in some hopefully imminent version of clojure.

16:52 rhickey: Chouser: is that regex patch compatible with latest? I'll put it in right now

16:53 Chouser: scottj: and to get re-groups to work, you need to call .find on the matcher first -- it mutates each time you call .find

16:53 rhickey: I'll check.

16:55 rhickey: "patch" appears to guess correctly

16:55 arnfred: is there any predefined functions for folding a list in clojure?

16:55 kotarak: rhickey: 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:55 rhickey: arnfred: reduce is foldl

16:56 arnfred: rhickey, that works, thanks!

17:05 rhickey: Chouser: the future is now - regex patch applied (rev 1070)

17:05 thanks!

17:09 Chouser: excellent, thank you.

17:10 rhickey: I'll be sending all support traffic your way :)

17:10 Chouser: heh, I bet.

17:10 rhickey: Actually I think it is very straightforward, just happens to be a breaking change

17:10 Chouser: well, my exhaustive test suite passes (all 3 tests) so I'm sure we're good.

17:13 drewr: I'll run my nonexistent test suite on it just to make sure.

17:14 rhickey: Chouser: do you have a proposed modification to the reader docs?

17:14 Chouser: nope, but I can work on that.

17:14 gotta go

17:30 kotarak: rhickey: I'm sorry for my previous message. The problem is not the message, it's my stupidity. I'm sorry for the inconvenience....

17:31 rhickey: kotarak: no problem

17:31 everyone makes mistakes!

17:31 kotarak: I messed up gen-interface usage.

17:31 * drewr especially

17:32 * kotarak should not program, when midnight's approaching...

18:24 nicknull: i 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:24 bah

19:21 Chouser: rhickey: looks like the existing Regex reader docs are sufficiently vague that they're still accurate.

19:21 rhickey: uh oh

19:21 Chouser: :-)

19:22 I'll see what I can do.

19:23 nicknull: how do you so regexps in clojure?

19:23 rhickey: Something expressing in terms of - just like Java pattern strings except ___

19:23 nicknull: \d+ for example

19:23 rhickey: nicknull: #"regexpatternhere"

19:24 nicknull: # again? is the shorthand for lambdas a regexp?

19:24 Chouser: nicknull: (re-find #"\d+" "abcde12345fghij")

19:24 nicknull: liek (map #(* % 2) '(1 2 3))

19:25 Chouser: nicknull: nope, you need to look at the char after # -- #() vs #{} vs #""

19:25 rhickey: nicknull: # is a general reader escape character

19:25 nicknull: oh yeah i see

19:26 rhickey: the 2 things it tells you are - the next character matters, and it happens at read time

19:26 Chouser: (find-doc "regex")

19:27 nicknull: "{} when is that used?

19:27 multimethods?

19:28 does regexes have to be imported?

19:28 and downloaded too?

19:29 (import regex) just hangs the interpreter... i knwo its wrong but shouldnt it generate an error instead?

19:29 Chouser: Huh. #{} is not documented at http://clojure.org/reader

19:29 nicknull: nope, import nothing for the regex features we've discussed so far.

19:29 rhickey: Chouser: sure it is, right after maps

19:30 Chouser: rhickey: oh, sorry -- looking under "Dispatch (#)"

19:30 rhickey: but not in the dispatch section

19:30 nicknull: (re-find #"\d+" "abcde12345fghij") -> java.lang.Exception: Unsupported escape character: \d

19:30 where is the doc for the regex.syntax then?

19:30 Chouser: nicknull: need a newer version. :-)

19:30 nicknull: \d+ is standard...

19:31 Chouser: i have sep 16 of clojure

19:31 Chouser: we're talking about a patch that Rich put in mere hours ago.

19:31 nicknull: lol ok

19:32 Chouser: For your version you need to quote your \ like: #"\\d+"

19:32 rhickey: Chouser: added a mention of set syntax in dispatch section

19:32 Chouser: rhickey: thanks :-)

19:33 nicknull: and re-findall doesn exist? is there some equal?

19:33 Chouser: Java doesn't have a regex literal syntax, right? so the old behavior looks more like Java than the new behavior does.

19:34 nicknull: (find-doc "regex")

19:34 nicknull: perhaps you want re-seq

19:34 rhickey: Chouser: right, the old format was the string you'd have to use in Java, prefixed by #

19:35 nicknull: ah re-seq

19:36 yes, 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:28 pjb3: rhickey: I saw the breaking change for regex literals, I'm in favor of that

20:29 rhickey: pjb3: ok - change is in rev 1070

20:30 pjb3: rhickey: 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:31 rhickey: pjb3: 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:32 pjb3: sounds good

20:32 just wondering if that was the plan, to have version numbers

20:32 rhickey: We discussed my plans for release numbers yesterday: http://clojure-log.n01se.net/date/2008-10-14.html

20:34 * pjb3 catching up on yesterday's discussion

20:43 pjb3: The only reason I think of version numbers is just to let people know if they should expect non-backward compatible changes

20:43 So all the code that runs on clojure 1.0.0 should theoretically work with 1.0.x, aside from any bugs

20:44 where as 1.1 may have minor changes that could break things, or 1.1 has new features that 1.0 doesn't

20:44 basically the way the JVM works

20:44 1.5.0 vs. 1.5.1 vs. 1.6

20:44 or, Java I should say

20:45 rhickey: Everyone 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:46 with a 3 place system, major.minor.rev, I could still get my year.release.rev logic

20:47 * rhickey hates branching

22:39 emacsen: rhickey, so, I just read, you spoke with Guy Steele, etc. in the audience. Did they give you any feedback?

22:40 rhickey: emacsen: no - Guy left during the talk after mine and wasn't at the conference the following day.

22:42 emacsen: that's too bad. It'd be nice to know what he thinks, especially in light of his participation with Fortress too

22:42 since it also runs on the JVM

22:42 (not stating the other obvious connections)

22:43 rhickey: I'll see him again at OOPSLA on Monday

22:43 emacsen: true. Can't wait to see the video from that, if there is any

22:44 rottcodd: what's the idiomatic way of reading the lines of a file into a vector?

22:46 rhickey: (vec (line-seq rdr))

22:47 rottcodd: thanks

22:48 (I knew it would be a 1 liner but didn't know about line-seq)

22:50 Chouser: getting a rdr for a filename is only barely a one-liner (without duck-streams)

22:51 rottcodd: (new BufferedReader (new FileReader filename))

22:51 Chouser: hm

22:51 (-> filename FileReader. BufferedReader. line-seq vec)

22:51 I guess those count as 1 liners.

22:52 rottcodd: I mainly wanted to avoid explicit recursion

22:53 Chouser: ok.

22:53 sorry, the number of classes need to do java.io generally annoys me.

23:13 pjb3: So I've been trying to figure out this class loader issue when using gen-class-and-load

23:13 http://gist.github.com/16843

23:14 The java code is for velocity, to change the way it does look ups of properties

23:14 To use keywords for clojure maps

23:15 The velocity.clj is my attempt to try do that in clojure

23:16 Anyway, the error I get when velocity tries to load is: java.lang.Exception: The specified class for Uberspect (clojure.velocity.ClojureUberspectImpl)

23:16 But if I eval this: (Class/forName "clojure.velocity.ClojureUberspectImpl")

23:16 it finds the class

23:17 I've traced through the velocity source code, and it calls Class.forName("clojure.velocity.ClojureUberspectImpl")

23:17 so why would that work in clojure but not in Java?

Logging service provided by n01se.net