On Thu, Oct 29, 2009 at 2:15 AM, Alex Osborne <a...@meshy.org> wrote:
>
> Using eval (which will also work for dynamically calling Clojure functions):
>
>   (let [obj "some string"
>         fname ".substring"]
>     (eval (list (symbol fname) obj 2)))

Thanks a lot. I was trying to avoid reflection (ie, looking for a
clojure idiom), especially to get an understanding on what are clojure
limitations.

The eval form still shows some problems, if I do this preparation:

(import javax.swing.JFileChooser)
(def jfc (new JFileChooser))

And then do:

user=> (.setFileSelectionMode jfc 1)
nil

All good here, but, if I do the eval variation,
user=> (eval (list (symbol ".setFileSelectionMode") jfc 1))
I get:
#<CompilerException java.lang.RuntimeException: Can't embed object in
code, maybe print-dup not defined


In theory it should work? What basic mistake am I doing here? BTW:

user=> (println (list (symbol ".setFileSelectionMode") jfc 1))
(.setFileSelectionMode #<JFileChooser
javax.swing.JFileChooser[,0,0,0x0,invalid,layout=ja...]> 1)

So the list for the eval looks good...

Many thanks,
Tiago

-- 
"The hottest places in hell are reserved for those who, in times of
moral crisis, maintain a neutrality." - Dante

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to