8:45 leafw: hi. I'd appreciate an example on how to use the (bean *obj*)
9:15 hi all. I'd appreciate very much an example on how to use the (bean *obj*) -particularly on how to retrieve then the values/pointers
9:17 rhickey: user=> (bean (java.util.Date.))
9:17 {:year 108, :class class java.util.Date, :seconds 52, :time 1209906832244, :day 0, :minutes 13, :timezoneOffset 240, :hours 9, :date 4, :month 4}
9:21 leafw: my problem is then how to access the map
9:22 (let [b (bean java.util.Date.))] (println (b :year))) ??
9:23 [that fails, of course)
9:34 rhickey: (:year b)
9:34 or (get (bean (java.util.Date.)) :year)
9:50 I made bean extend APersistentMap so implements IFn like other maps
9:51 so ((bean (java.util.Date.)) :year) now works
10:14 meredydd: (moving from #enclojure for keeping-on-topic reasons)
10:14 rhickey: What's your reasoning behind disallowing wildcard imports?
10:14 rhickey: meredydd: there is no programmatic way to enumerate packages. IDEs do it by parsing all the jar files, Clojure doesn't read the jar files
10:15 meredydd: Uh-huh - I've looked up how it's done. So, you just don't want a hack that nasty in the language core?
10:15 rhickey: no
10:15 It would bring a tom of names into Clojure namespaces
10:15 meredydd: (uhhh...was that a 'no, that's not it', or a 'yes, I dont')
10:15 rhickey: tn
10:15 ton
10:15 meredydd: uh-huh...
10:16 (pretty much the point, isn't it?)
10:16 rhickey: making a mess is the point?
10:16 Namespaces are reified things, having unused cruft in there is not productive
10:16 it's not merely a lookup list for the compiler
10:17 meredydd: ?
10:17 (ahh...which it pretty much is for Java, as far as I can see)
10:17 (or do you object to the same in Java?)
10:18 rhickey: In Java there's no way for the programmer to interact with the 'namespace' in use in a module, in Clojure there is
10:18 (ns-imports *ns*)
10:18 (ns-imports (find-ns 'clojure)) etc
10:19 meredydd: uh-huh
10:20 I see. And you want that to be a useful tool for introspection, rather than a great big dumping-ground full of all of java.util, java.io...
10:20 rhickey: right, I don't want to see an entire package because someone was too lazy and used *
10:20 so for now only java.lang and a couple of util things are auto-imported
10:20 everything else must be explicit
10:21 meredydd: Okay.
10:21 And people like me who want to start using Clojure to swing around big bits of our own applications are either going to write a lot of manual imports, or write hackity macros while you're not looking.
10:22 rhickey: that's okay, it's still important for Clojure to have a recommended approach
10:23 meredydd: Yep. And you have a coherent reason for wanting it that way.
10:24 And, of course, the obligatory fanboyism - I am truly impressed with what you've done here, and I anxiously await more.
10:24 (hmm. Although right now, 'more' is more a matter of a working Enclojure than anything else.)
11:27 Chouser: With my sparse Java experience, I very much prefer reading code that has no wildcard imports. That way I have a fighting chance of finding the classes that are being used.
11:28 I wonder if "refer" (and or the stuff from lib.clj) would be better off also not doing wildcards.
11:29 rhickey: that stuff's about loading Clojure code - are you suggesting naming each imported function?
11:30 Chouser: yeah, I tend to use :only on refer for the same reason I don't use wildcard imports in Java.
11:30 rhickey: Granularity-wise a clojure lib is roughly equal to a java class
11:30 but hey, more power to you!
11:36 Chouser: heh
11:37 I just don't like referring to an unusual name with no suggestion of where it came from.
11:38 (refer 'bing) (refer 'bang) (refer 'boom) (optimise {...}) ; go fish!
11:38 rhickey: (resolve 'optimise)
11:39 not arguing your point, it's a good practice :)
11:42 Chouser: well, there is that. As long as you can get a REPL with the same context as the code you're reading. ...which is rather easier to do in Clojure than Java.
11:43 Hm, any reason someone couldn't create a Java REPL, compiling Java source on the fly just like you do with Clojure?
11:43 I guess if I ever wanted to write Java code, I might care.
11:44 rhickey: see: http://
11:46 jteo: the verboseness of java code makes that an effort.
11:56 leafw: Chouser: bean shell is essentially that. Java on the fly and without the static type verbosity
11:57 (but a very poor scripting language compared to clojure)
11:57 * rhickey forgot about beanshell
12:09 rhickey: I've added docs for gen-class - feedback welcome!
12:29 leafw: another one about beans: can one not just get but also set?
12:29 rhickey: leafw: no set yet
12:29 leafw: oks
12:30 is it planned?
12:31 rhickey: the semantics are muddy - maps are immutable and logically the altering operations produce new values
12:31 whereas I think people may expect changes to flow through to the underlying object
12:32 bean is not meant for that
12:32 leafw: ok
12:32 I am just used to jython
12:33 where beans are direct for both get/set
12:33 and change the underlying object.
12:34 rhickey: it would be, IMO, be desirable to have the map alter ops produce new maps, but no flow-through alteration
12:35 lisppaste8: aking pasted "recursive shootyout" at http://
12:35 aking: rhickey: to practice Clojure, I thought I'd convert some of the shootout benchmark progs. Here's the recursive one
12:35 It seems to run about 16x slower then the java server one
12:36 leafw: I hope I haven't said anything silly: http://
12:36 the wiki is just starting, more to come soon.
12:36 aking: That includes removing the startup time
12:36 ANything (other than changing the algorithm) I missed?
12:37 rhickey: That's the arithmetic, not the recursion. Not sure the declarations are useful - you should avoid them unless proven to be so
12:37 aking: rhickey: yeah.. I noticed there was almost no difference in speed with or without them
12:38 rhickey: aking: clojure looks much better without in that case
12:38 aking: also - the println seems to put an extra space before and after a number?
12:39 rhickey: The algorithms seem fine
12:39 aking: yes, pr functions put spaces between multiple args, use str first if you want to avoid that
12:40 aking: ok - thanks
12:43 rhickey: Is there an example of getting command line arguments into clojure?
12:43 rhickey: aking: *command-line-args*
12:45 leafw: looks fine
12:47 aking: rhickey: thanks - found a reference to it in the Feb 25th news :)
12:48 rhickey: aking: yeah, there are a few non-fn vars like that undocumented, sorry
12:49 aking: rhickey: no prob - I should generally look in the clojure source first before asking
12:50 jteo: rhickey: on a scale of 1 to 10, where you are with regards to stability of the clojure "core" language?
12:51 rhickey: jteo: I'm probably the wrong one to ask :) - anyone else want to chime in?
12:51 or are you talking about feature stability?
12:52 jteo: feature?
12:52 technically, anything doable in the jvm or java libs is already a feature. ;)
12:55 rhickey: I haven't run out of ideas, but I don't have anything significant about what I've already done that I'm looking to change. Clojure is pretty small and that is also a feature IMO.
12:57 For instance, I just added gen-class, which doesn't alter anything that already exists in Clojure, but is a pretty big enhancement
12:59 jteo: true.
12:59 aking: rhickey: where's the docs for gen-class? I've checked website "Java Interop", "news" and "API" - and svn
12:59 Chouser: are you going to rename "for" "doseq" and friends?
13:00 rhickey: aking: (doc clojure/gen-class)
13:00 aking: when I get some feedback I'll do a news item. The rest of the site documents the release, so it won't appear there until the next release.
13:00 aking: heh - didn't think of that :)
13:02 rhickey: Chouser: I thought only "for" to "from" was on the table, doseq stays the same and doseqs would be new
13:03 Chouser: I realize that's not an answer :)
13:04 aking: rhickey: hmm.. not in boot.clj - had do (load-file "src/genclass.clj") first
13:04 rhickey: aking: right, it's in incubation right now
13:05 bleeding edge svn stuff :)
13:06 aking: heh - I'll go play with gen-class for a bit. I see it will reduce the amount of enclojure java source required.
13:08 rhickey: aking: the idea is to eliminate the need for Java stubs, as well as provide a general class extension mechanism. Looking for feedback as to the comprehensibility of the docs...
13:31 leafw: is there any way to list all vars in the current namespace?
13:32 that would help in finding things like *out* and *command-line-args*
13:32 ns-amp
13:32 looks like it
13:33 rhickey: yup
13:34 leafw: I still lack an intuitive knowledge on clojure ... (apply ns-map (all-ns)) doesn't work, and was the first thing that came to lind
13:34 s/lind/mind/
13:34 aha, so (map ns-map (all-ns)
13:34 that works.
13:45 aking: rhickey: after doing a 'gen-and-load-class' it looks like you have to then import it into namespace you were in?
13:46 also, maybe a comment about it being a one time only operation in the docs?
13:48 leafw: thanks for help and hints. Out
13:50 rhickey: aking: good point, yes, one-time only is the tricky part
13:54 aking: Does clojure use a classloader per namespace?
13:54 Or just a root classloader?
13:57 If it was a classloader per namespace, couldn't you do a gen-class in that namespace's classloader - and if you wanted to recreate a gen-class, jsut delete the namespace, recreate it then call gen-class again?
13:58 It's been a few years since I played with java classloaders, so my memory might be a bit fuzzy on it..
14:02 rhickey: I'm not going to take on same-named class reloading, there are all kinds of issues, esp. since you might want to use the class from multiple namespaces. Right now there is a root namespace and a bunch of tear-offs which are per compilation (load/eval), not per namespace
14:03 the idea behind gen-class is that, since it is implementation-free, the gen-class declaration should be fairly stable
14:03 the Clojure side of gen-class is completely dynamic and supports iterative development
14:04 aking: rhickey: ok - just thought I'd check - forgot about the cross namespace usage - that would be ugly to handle.
14:21 jtra: Hello
14:21 rhickey: hi
14:22 jtra: I'm new to clojure, I know both Java and Common Lisp well, and after reading documentation I think I like the clojure :-)
14:23 rhickey: great!
14:23 jtra: I have also bit of Haskell experience, so paradigm suits me well
14:31 baggles: the world is crying out for clojure.
14:31 or if it isn't, it should be.
14:31 please save us all
14:32 rhickey: :) blogging about Clojure is welcome...
14:32 baggles: yeah... if only i had enough energy for this stuff. i've been running around outside in the hazy sun today :)
14:33 getting a real job recently, i now have lot of admiration of wthose who manage to keep up on the FLOSS stuff and work aswell....
14:35 jtra: I played with repl and simple JPanel in JFrame, it works as expected but when I run it as script, it exits despite AWT thread is running (which would not exit when such code would be written in Java itself). What is proper way to prevent exiting main thread in Clojure when GUI is active?
14:38 rhickey: jtra, I'm going to take the System.exit call out of Script.java - seems to trip a lot of people up...
14:40 jtra: that's up if you're on SVN
14:41 jtra: ok, I will remove it from Script.java and recompile - I have 20080329 release
14:44 it works as expected now
15:44 rhickey: Servlets in Clojure - no Java required:
15:44 (clojure/gen-and-save-class "/Users/rich/dev/clojure/gen/"
15:44 'org.clojure.ClojureServlet
15:44 :extends javax.servlet.http.HttpServlet)
15:44 ClojureServlet.clj:
15:44 (in-ns 'org.clojure.ClojureServlet)
15:44 (clojure/refer 'clojure)
15:44 (defn doGet [this req resp]
15:44 (let [out (. resp (getOutputStream))]
15:44 (. out (println (str "Hello World at " (new java.util.Date))))))
15:45 drop into Tomcat/Glassfish
22:53 Chouser: bpattison: welcome!
22:56 bpattison: thanks
22:58 making a concerted effort to learn clojure
23:21 Chouser: anyone here have gen-and-load-class working?
23:22 bpattison: why does (println "hello world") produce "hello world"\n nil -- what's the extra nil for?
23:22 Chouser: bpattison: that's the return value from println
23:22 the REPL prints return values for you.
23:23 bpattison: oh! thanks
23:38 Chouser: Ah! It helps to have rebuilt clojure instead of just updating the sources.