#clojure log - May 05 2008

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

1:14 jteo: Chouser: ;)

6:52 bubblegumtate: does anyone know why emacs would fail to run clojure as an inferior lisp? I set inferior-lisp-program to "java -cp ~/src/Clojure/clojure.jar clojure.lang.Repl" which runs clojure fine from the shell. It even works from the shell within emacs. When I try M-x run-lisp I get "NoClassDefFoundError"

6:57 oh good one... ignore that, I checked the groups and found the answer

9:56 aking: wow.. I just 'got' agents - cool :) now the ants demo makes sense. That's a topic that needs a tutorial..

9:59 Chouser: the ants demo isn't a tutorial?

9:59 rhickey: :)

9:59 aking: heh - it's almost - though some hand waving about agents in it - the *agent* kept throwing me off

9:59 now to get erlang's jinterface working so I can talk tot he server..

10:00 rhickey: aking: true, *agent* is not documented yet

10:00 aking: you've got an Erlang server?

10:01 aking: rhickey: yup - going to try writing a gui server monitor in clojure

10:01 Should be a good starter project

10:02 rhickey: cool! A generic Clojure-jinterface interface would be very welcome

10:02 e.g. the marshalling

10:02 aking: That's something I was planning on.. we'll see how far it goes.

10:03 As for agents, once I started thinking of them as similar to an erlang's 'process', then it made more sense (immutable state and all)

10:04 rhickey: aking: just be careful, the analogy only goes so far

10:04 aking: rhickey: agreed - though it help get over the hump in understanding.

10:05 rhickey: yes, they are most similar in the problem they solve, less so in how they work

10:07 aking: yup - erlang's functions in the process module working on it's state vs. clojure's functions *applied* independently and asynchronously to state

10:07 rhickey: you've got it

10:22 Chouser: rhickey: oh, fwiw, I used gen-and-load-class successfully last night.

10:23 rhickey: great - any issues?

10:23 Chouser: Actually, I had a lot of trouble getting it to work.

10:23 ...until I realized I had fetched the latest .clj's, but hadn't rebuilt the Java.

10:23 rhickey: what kind of trouble?

10:24 oh :)

10:24 Chouser: Right. So then it worked perfectly.

10:25 I did find it a bit tricky to set up the class's namespace correctly, to include the clojure functions I needed without getting conflicts.

10:26 rhickey: using :exclude/:only/:rename?

10:26 Chouser: right.

10:26 rhickey: what were you extending?

10:27 Chouser: It took me a while to figure out that where the conflict error was coming from. Once I did, adding the necessarly :excludes wasn't particularly hard.

10:28 javax.swing.text.Document -- I'm working on a patch for enclojure's REPL.

10:28 did you consider using a map instead of a namespace?

10:28 rhickey: so Document had function names conflicting with Clojure's?

10:28 Chouser: oh, you want it to be mutable, don't you..

10:29 Document has a "replace" method

10:29 rhickey: Chouser: yes, you end up with Java classes that you can incrementally develop/fix at runtime

10:29 I had considered some method- prefix

10:29 or suffix

10:30 e.g. would be replace-method

10:30 Chouser: yeah, can't say that feels right either.

10:31 rhickey: name injection is always tricky

10:31 Chouser: this is certainly sufficient. namespaces have all the tools you need for disambiguation.

10:31 rhickey: that's where I ended up, but need to see how tedious in practice...

10:32 Chouser: python handles cases like this by having more than one place where a name is looked up.

10:32 Something like where "def" only modifies the top-most namespace, but lookups fall back to other namespaces.

10:33 rhickey: wouldn't be a good fit with Clojure's compilation model

10:33 Clojure calls have no runtime lookup

10:33 Chouser: ok.

10:45 (defmacro super [methname instance & args] `(binding [~methname nil] (. ~instance ~methname ~@args)))

10:46 I guess that kind of thing would be trickier if the methods were in a map instead of a namespace.

10:59 oh, and here's a fun detail: I know I want to extend Document, but it's abstract and I'm not sure what concrete type is actually being used. so I did:

10:59 (gen-and-load-class "chouser.ReplDoc" :extends (class (.getDocument e)))

11:00 ...whwere e is the JEditorPane that someone else has set up.

11:23 cgrand: Minor trouble using gen-and-save-class: it doesn't create directories before writing the class to disk. I added (when-let dir (.getParentFile file) (.mkdirs dir)) to gen-and-save-class. BTW gen-and-save-class is refered to as "gen-and-store-class" in the docstring of gen-class.

11:30 rhickey: cgrand: I had added the 'directories must already exist' proviso to the docs, considering auto-create, will fix reference to store

11:31 cgrand: the servlets turn into practically nothing to do

11:33 cgrand: rhickey: sorry

11:34 rhickey: cgrand: ?

11:34 cgrand: for reporting something you documented

11:34 rhickey: np!

Logging service provided by n01se.net