#clojure log - Nov 01 2008

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

0:14 sunwukong: hi

0:16 browsing the closure-contrib files I've noticed that cond-let evaluates the first true test twice

0:17 I've created a patch for it - what's the stadard way to get this into svn?

0:33 danlarkin: sunwukong: http://clojure.org/contributing

0:35 sunwukong: that's nice, but seems an awful lot of work for a 3-line change :)

0:38 lisppaste8: sunwukong pasted "cond-let fix" at http://paste.lisp.org/display/69541

1:35 asbjxrn: Anyone using java debuggers together with slime?

1:36 Seems to me that slime captures exceptions and prevents the debugger from getting to it?

5:53 AWizzArd: Moin

5:53 kotarak: salut

7:43 Lau_of_DK: Good day, folks

7:43 kotarak: Salut Lau

8:52 Lau_of_DK: rhickey, last I was head you said that AOT would subsume gen-class functions. Firstly, you cant use words like "subsume" with danish people, and second, would you please explain the practical implications of AOT ?

8:52 head = here

8:54 rhickey: http://dictionary.reference.com/browse/subsume

8:55 Lau_of_DK: Yes sir, Im aware of dictionaries. I fail to see how I can prepare my code for the removal of gen-class when Im currently depending on it. So I was hoping for some insight into how AOT will be used in Clojure.

8:58 ReplRat_: AOT?

8:58 rhickey: Lau_of_DK: Don't worry about genclass being removed yet, there's no alternative anyway. I can't say how it will work until I've finished designing it. That won't happen until next week. Fundamentally it will be the same - generated classes will map methods to Clojure vars. All that might change is the syntax and organization, and for the better.

8:58 Lau_of_DK: Alright thanks - That puts me at ease :)

8:58 kotarak: ReplRat_: ahead of time compilation

8:59 ReplRat_: compiling clojure to .class files

9:02 pjb3: Go Vote! http://thediscoblog.com/2008/10/19/poll-which-language-is-better-suited-for-jvm-concurrency/

9:03 and not for Obama or McCain :)

9:18 vy: rhickey: Do you consider moving documentation pages on clojure.org to a documentation scheme -- e.g. DocBook, LaTeX, etc.?

9:36 Chousuke: maybe restructuredtext, if you don't want to learn a complex markup language. :)

11:34 Drakeson: (def a [1 2 3]) (a 0) -> 1, wouldn't it be nicer if (a 0 3) -> [1 2 3], or maybe (a 0 2) -> [1 3], or maybe (a [0 2 0]) -> [1 3 1] ?

11:36 or maybe (def a [[1 2][3 4]]) (a 0 1) -> 3

11:37 err, 2, that is

11:42 Chouser: (get-in a [0 1]) for the latter case

11:42 Drakeson: but (a 0 1) is not used for anything else.

11:42 Chouser: (map a [0 2]) for the former

11:43 Drakeson: Chouser: well, I am arguing about the builtins, (again).

11:45 Chouser: get-in has neighbors assoc-in and update-in

11:45 (assoc-in a [0 1] 99) -> [[1 99] [3 4]]

11:45 (update-in a [0 1] #(* 10 %)) -> [[1 20] [3 4]]

11:47 Drakeson: I'm not arguing with you, I'm just not sure which of these behaviors is so much mor common than the others that it should become the default when you use a vector as a function.

11:49 Drakeson: for (a 0 1) to mean (get-in a [0 1]) sounds natural when (a 0) gives you (get-in a [0])

11:50 don't you agree?

11:51 well, at least, do you agree that (a 0 1) should have a meaning?

11:52 Chouser: I think it's better to have no meaning than the "wrong" one. Once it has a meaning, it'll be *very* difficult to change it later.

11:53 having said that, get-in would seem reasonable. ...except I don't think I've ever actually used get-in in a program

11:53 I've used update-in, but not get-in

11:54 Drakeson: I used to do a lot of matrix processing (using MATLAB). It was hard to replicate in CL, (no "good" support for vectors, no compact syntax for vectors, etc.)

11:55 so I would appreciate having many array-related facilities

11:57 in matlab 1:10 means (range 1 10), and a[1:10] is produces a sub-array of "a" with elements 1,2,...,10.

11:57 (a <vector>) could mean the same (i.e. (map a <vector>))

12:22 duck1123: what does "Can't let qualified name: view/session" mean?

12:23 Chouser: it means you're writing a macro

12:23 duck1123: session is one of my variable, but not on the line it says

12:23 yes

12:23 kotarak: use '~ in the macro

12:23 Chouser: if you're trying to capture a name, right, use '~

12:23 if you're not trying to, use gensym or foo#

13:06 lisppaste8: duck1123 pasted "Compojure putting 'POST' in namespace" at http://paste.lisp.org/display/69557

13:07 duck1123: could someone help me figure out why this isn't working?

13:07 I can do forms just fine, except for when they're in a macro

15:15 Lau_of_DK: When experimenting with Gen-class, Im not allowed to create multiple objects with the same name (my wish was of course to overwrite) - how do I get around this limitation ?

15:20 Come on gents, can somebody please help me a little with these classes?

15:20 gnuvince_: Good day

15:21 Lau_of_DK: Good evening Vincent

15:36 Anybody here who can share a few words on java classes, and then perhaps gen-class?

15:49 sohail: Lau_of_DK, that's probably a Java thing

15:50 Lau_of_DK: ok - how do I go around it?

15:50 I cant come up with a new name everytime I test-run the class

15:50 sohail: Lau_of_DK, you might have to

15:52 Lau_of_DK: hehe

15:52 sohail are you proficient in Java?

15:53 sohail: Lau_of_DK, not at all :-)

15:54 Lau_of_DK: alrighty

17:11 user=> (gen-and-load-class "HLayout" :method [["getLayout" [] QWidget]])

17:11 #=HLayout

17:11 user=> java.lang.IllegalArgumentException: Unable to resolve classname: HLayout (NO_SOURCE_FILE:35)

17:11 So first it generates the class, and the it denies any knowledge of having done so ?

17:12 kotarak: Lau_of_DK: use 'some.namespace.HLayout and then import.

17:14 Lau_of_DK: right... :)

17:14 Now I caused Java to throw a Segfault

17:25 danlarkin: is it possible to have the slime REPL print the return value of a form when I eval it from another buffer with C-x C-e?

17:26 Chousuke: it prints it in the minibuffer doesn't it?

17:27 danlarkin: if I have (first [1 2]) in my buffer and I eval it slime just prints: ;;;; (first [1 2]) ...

17:28 does it print 1 for you?

17:49 Chousuke: danlarkin: in the minibuffer it does.

17:49 danlarkin: Chousuke: ahh look at that. fantastic! Thanks :)

18:57 Lau_of_DK: Is Java supposed to automatically use .class file on the classpath, or is it only .jar ? And if its the case, are they supposed to maintain their original libraries hierachy, like /foo/bar/Baz.class ?

19:09 StartsWithK_: Lau_of_DK: sure, you can have directories with .class files and then you could just add them to class path with something like -cp rootdir

19:11 Lau_of_DK: so if I have /home/lau/code/com/lau/net/*.class and I need the namespace .com.lau.net *

19:11 How do I add that to CP ?

19:19 AWizzArd: Oh, Bill Clementson now also tries out Clojure

19:38 danlarkin: is there a predicate that will be true for vectors and lists but not maps?

19:38 aside from (or (vector? foo) (list? foo))

19:47 Chousuke: (compose not map?)

19:47 ;P

19:47 comp* too

19:48 danlarkin: heh, mostly I wanted a name for my function... I'm going with decode-list-vector

19:48 even though it's kindof a lame name

19:49 Chousuke: if it's going to be a predicate to test whether it's a list or a vector, why not just list-or-vector?

19:50 with the ? in the name

19:52 danlarkin: lisppaste8: url

19:52 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

19:52 danlarkin pasted "example" at http://paste.lisp.org/display/69570

19:53 danlarkin: oh... formatting got messed up, but you see what I'm going for?

19:53 I decided to just exploit the procedural nature of cond and put map? before coll?

19:55 StartsWithK_: is there a zipper that can work with all clojure data strucutures (maps and sets too)?

19:56 or, what would be a best way to scan macro body for specific code fragments?

19:56 Chousuke: danlarkin: don't forget that sets are collections too

19:58 danlarkin: Chousuke: whoops! Luckily it turns out I want sets to be processed the same way as lists & vectors. Too bad decode-list-or-vector-or-set is a horrible name

19:58 I guess I'll go with decode-coll

19:59 Chousuke: or decode-nonmap

20:40 danlarkin: anyone familiar with cond-let from clojure-contrib? I'm getting java.lang.Exception: Unsupported binding form: clojure.lang.PersistentList@e2c88ceb

20:42 lisppaste8: danlarkin pasted "cond-let" at http://paste.lisp.org/display/69573

21:41 danlarkin: So how's everyone getting around having two functions that call eachother

21:41 since one has to be defined first

21:53 Chouser: (def foo) first, then you can write a function that calls foo.

21:53 re-def foo later.

21:57 danlarkin: Mmm :-/

22:19 Anyone have a need for a custom Throwable yet? I guess you've gotta use gen-class to get that eh

22:22 Chouser: if you want to know what name to use when you catch it, yeah.

22:26 danlarkin: Chouser: I guess I'll stick with Exception for the time being

23:00 So I wrote a simple little JSON encoder, what kind of directory structure and files should I make to upload to github?

23:03 Chouser: at least directories that match the namespace: org.danlarkin.json should be defined in org/danlarkin/json/json.clj

23:03 it seems common to put another src dir above that (src/org/dan...)

23:04 danlarkin: is it acceptable to have a namespace with no dots? (ns clojure-json)

23:05 I know it's possible, but is it frowned upon or something...

23:06 Chouser: well, I think clojure sort of adopts Java's conventions there, where they recommend using a domain name you control in order to avoid conflicts.

23:06 http://java.sun.com/docs/books/jls/third_edition/html/packages.html

23:07 danlarkin: Ah

23:07 Chouser: especially section 7.7, I guess.

23:09 danlarkin: just seems egomaniacal for me to make everyone type org.danlarkin.json

23:09 :)

23:09 Chouser: heh.

23:09 actually, it's the other way around -- might be egomaniacal to assume clojure-json means your package.

23:11 it's why we have use and alias for packages. I can say (ns mything (:require [org.danlarkin.json :as json])) at the top of my file, and then just json/print or whatever when I want to use it.

23:11 danlarkin: so I'll have a README, LICENSE and src/org/danlarkin/json/json.clj -- should I be providing an ant build file too or something?

23:12 Chouser: I don't know. I've never written an ant build file.

23:13 I guess if you want to let people download a .jar instead of making them use git, then you'll have to package it up -- you should provide the script or whatever you use to do that packaging, I suppose.

23:14 danlarkin: well to use this json encoder one would presumably have to make a jar and add it to the classpath, is that correct?

23:15 Chouser: no, you can add the src directory to your classpath

23:15 that's how I use clojure-contrib. git svn rebase to keep it current, and clojure-contrib/src in my classpath. No rebuilding anything.

23:16 danlarkin: ah ha, that is better than building it indeed

23:59 tada http://github.com/danlarkin/clojure-json/tree/master

Logging service provided by n01se.net