2008-05-03
| 10:08 | cmiles74 | This may be kind of a dopey question, but I can't figure it out... If I have string that has the name of a function in it, is there a quick way to get at that function? I'm trying parse things the user types in. |
| 10:09 | rhickey | 'read' is one way to avoid strings altogether |
| 10:09 | rhickey | and preferred if the input is Clojure code |
| 10:10 | rhickey | else something like: |
| 10:10 | rhickey | user=> (resolve (symbol "list")) |
| 10:10 | rhickey | #'clojure/list |
| 10:12 | cmiles74 | Yep, that is what I was trying to do! Your other point is well taken, I have to think about if this is really the way I want to do it. |
| 10:12 | cmiles74 | Thank you. |
| 15:43 | rhickey_ | gen-class is up!, everything I talked about yesterday, plus auto-load .clj from classpath |
| 15:43 | rhickey_ | put the .clj next to the .class file |
| 16:04 | baggles | hum |
| 16:04 | baggles | w3ait |
| 16:04 | baggles | does this mean there's a clojure ... without needing createclassloader |
| 16:04 | baggles | or whatever it was that was preventing applets from working? |
| 16:05 | rhickey_ | no, Clojure compiles on the fly and needs its own classloader |
| 16:06 | rhickey_ | this let's you create statically-named Java classes that end up calling Clojure code, greatly easing integration into Java frameworks like servlets, Netbeans/Eclipse etc |
| 16:07 | rhickey_ | also mor epowere when deriving from Java classes - access to protected members, adding methods, setting up custom constructors and static factory methods, support for main etc |
| 16:08 | rhickey_ | plus final state, which can be a ref or agent, allowing for transactional or asynch Java objects |
| 17:26 | Chouser | well gen-class allow access to superclass methods? |
| 17:29 | rhickey_ | kind of - the recipe is, in some method foo in which you want to call super.foo, just bind foo to nil and call this.foo |
| 17:34 | Chouser | (gen-class ... :methods foo [void []] ...) ... (def foo nil) ? |
| 17:35 | Chouser | and then calls to foo will actually call super's foo? |
| 17:35 | rhickey_ | you never need to use methods unless you are adding new methods, not needed for overrides or implementing interface methods |
| 17:35 | rhickey_ | all of the superclass/interfaces methods will be public in your class |
| 17:36 | rhickey_ | so the only uncovered case is when you are overriding foo and need to call the superclass |
| 17:37 | rhickey_ | (defn foo [] (binding [foo nil] (.foo this)) ...) |
| 17:37 | Chouser | ok, makes sense. that's actually the case I have. |
| 17:37 | Chouser | oh! |
| 17:37 | Chouser | hehe, I see. |
| 17:37 | rhickey_ | temporarily unbinding foo causes the default behavior of calling the superclass version |
| 17:38 | Chouser | yep, ok, thanks. |
| 20:18 | blbrown | does anyone have a clojure test framework out there? |