On Wed, Oct 28, 2009 at 7:34 PM, Wilson MacGyver <wmacgy...@gmail.com> wrote:
>
> Is there a reason you don't want to use doto?
>
> http://clojure.org/java_interop#toc15
>
> ie (doto Bla (.setProperty "x" 1))

I really want to do something different:

(def x (new StringBuffer "aaaa"))
(doto x (.setLength 2))

But my point is to be able to construct the method name in runtime.
Using doto, I still have the same problem:

(defmacro setProperty [field obj value]
  `(let [cct# (symbol (.concat ".set" ~field))]
    (doto ~obj (cct# ~value))
  )
)

If I do:
(def sb (new StringBuffer "aaaa"))
(setProperty "Length" sb 2)
sb

I get
"aaaa" (It should be "aa").

Again, the point here is to be able to construct method names (full
call signatures, really) on runtime.

I am lost. As in newbie clueless :(

Thanks a lot,
T

--~--~---------~--~----~------------~-------~--~----~
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