#clojure log - Sep 17 2008

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

1:09 Chouser: ow, my head: (->[i(range 10)](for i))

1:15 arohner: Chouser: uh, huh?

1:15 what does that do?

1:43 Chouser: It's the same as (for [i (range 10)] i)

1:44 Which is the same as (range 10)

1:44 but it sure looks scary, eh?

1:45 arohner: yeah

11:15 parth_m: Hello. Does (import ..) have a * equivalent. E.g (import '(java.io *)) doesnt seem to work.

11:17 rhickey: parth_m: no *, by design

11:17 parth_m: Ok. Thanks.

13:08 rhickey: interesting diff, what's new in API docs: http://clojure.org/page/diff/api/38385322

13:19 StartsWithK: Returns the immediate superclass and direct interfaces of c, if any

13:19 its missing a dot at the end.

13:20 what software are you using for clojure.org?

13:20 rhickey: wikispaces

13:21 achim_p: very cool. rhickey: congrats on the release!

13:21 rhickey: achim_p: thanks

13:23 StartsWithK: rhickey: when using genclass with :main true, maybe there could be some switch to tell clojure to process command line arguments like it would when used with clojure.lang.Script

13:23 achim_p: rhickey: do you generate these or convert them by hand?

13:24 rhickey: StartsWithK: I don't see why

13:24 achim_p: there are newlines missing before ":state" in gen-class

13:24 rhickey: achim_p: I generate them from the in-source comments

13:26 StartsWithK: rhickey: now *command-line-args* are not populated with command line arguments

13:26 achim_p: they were missing earlier. not that i mind much - just thought i'd mention it :)

13:27 rhickey: achim_p: the trick is for me to remember to fix them while I'm in the file for a real change...

13:28 StartsWithK: It seems to me once you write main you can do whatever you want, whereas in a script there is no alternative to *command-line-args*

13:35 achim_p: btw., regarding gen-class: there's no way to call super.anything() in an overridden method, is there?

13:37 rhickey: achim_p: there is this trick - binding the method handler to nil, then re-invoking the method on this

13:42 StartsWithK: will (Class.) be expanded to (clojure/new Class) and (.method Obj) to (clojure/. Obj (method))?

13:43 i have this stupid idea about replacing standard . and new..

13:43 rhickey: StartsWithK: I can't help you with that

13:46 achim_p: rhickey: i'm not quite sure how to do that :) is there any example code on this somewhere? i scanned the obvious places ...

13:47 rhickey: something like: (defn Foo-method [this arg] (binding [Foo-method nil] (.method this arg)))

13:48 achim_p: ah, i see. thanks a lot!

13:53 StartsWithK: i wasn't thinking about replacing . and new functionality, just to wrap them

13:53 rhickey: StartsWithK: as special ops, that seems perilous

13:55 StartsWithK: thats why i still didn't to it, still thinking about thing that could go wrong

13:55 rhickey: StartsWithK: what are you trying to achieve?

13:56 StartsWithK: for now i have (setp obj :UseSomething true :FirstName "Kreso")

13:56 so i woudl integrate that wiht doto

13:56 that wourks ok

13:56 oh setp expands to (doto obj (setUseSomething tru) (setFirstName "kreso"))

13:57 rhickey: StartsWithK: JavaBean property support might come to . at some point

13:57 StartsWithK: next i would add multimethods patch and ctor, one would let me use (doto (object) (myMethod args))

13:58 this would let me not write wrappers to libs, just patch parts i would like to change

13:59 lets say (doto (JMenuItem "&Exit [ctrl+x") :Enabled false (on :action-performed (fn [e] (bla))))

13:59 * JMenuItem.

13:59 so there would be my ctor, one that can read "&Exit [ctrl+x]" and patcheh method (on)

14:01 so far (on) setp and similar can't be used with doto.. i just don't know how smart this would be

14:03 * StartsWithK is away

14:52 * Chouser didn't know about alter-var-root

14:54 Chouser: Is that any better than using def to mutate global state?

14:58 The docs for descendants says it works on Java type inheritance. In practice it doesn't work on Java classes.

21:44 gnuvince_: How do I load the set library?

21:46 rhickey_: it's loaded automatically, called clojure.set

21:48 gnuvince_: Does that also import the union/difference/etc functions into the user namespace?

21:49 Chouser: you can say (use 'clojure.set) to import all the names into your current namespace

21:50 rhickey_: no, just loads it, you can (refer 'clojure.set)

21:50 Chouser: oh, sorry.

21:50 (ns user (:use clojure.set))

21:51 or (ns user (:require [clojure.set :as set])) and then you can use set/union, set/select, etc.

21:53 gnuvince_: Ah

21:53 I didn't know about the / syntax

21:54 (clojure.set/union s1 s2)

21:54 Chouser: ah, right.

21:55 gnuvince_: Is it syntactic sugar for a special form?

21:56 Chouser: I think that's the full syntax for a symbol -- symbols have an optional namespace part, and the name part

21:57 gnuvince_: OK.

21:57 By the way, I just want to say that I find Clojure to be a *very* nice language.

22:03 rhickey_: gnuvince_: great!

22:05 gnuvince_: Hopefully I can try to convert my Python webcomic scraper to Clojure to try it with something a little more "real"

22:09 Chouser: I've done some scraping with tagsoup and zip-filter

Logging service provided by n01se.net