The (list) comes from my dabblings with other lisps, using a vector
does make more sense and I quite like it

I was unaware that, unless I am mistaken from your above code that let
bindings are evaluated left to right, that is I was under the
impression (incorrectly) that you could not use say vm in the next
binding form.

I like the examples you guys have posted they look my nicer than my
code, I guess I still have a lot of playing with clojure to do before
I start using it more effectively

Many thanks

-- Greg

On Feb 11, 8:56 pm, CuppoJava <patrickli_2...@hotmail.com> wrote:
> Most of that java code is just pasting together library function
> calls. I'm not sure if there's any more elegant ways of doing that.
> Your clojure code looks fine for the most part I think. It's mostly
> just a question of style. The only thing that sticks out is the call
> to (list). That's generally never needed in Clojure. You just use a
> vector instead.
>
> Here's how I would write your code. Nothing much has changed. Just
> personal style:
>
> (defn str-interpose [sep strings]
>   (apply str (interpose sep strings)))
>
> (defn acquire-address [vm]
>   (.getProperty (.getAgentProperties vm)
>     "com.sun.management.jmxremote.localConnectorAddress"))
>
> (defn load-agent [vm]
>   (.loadAgent vm
>     (str-interpose File/separator
>       [(.. vm getSystemProperties (getProperty "java.home")) "lib"
> "management-agent.jar"])))
>
> (defn obtain-local-connection [vmid]
>   (let [vm (VirtualMachine/attach vmid)
>         address (or (acquire-address vm)
>                     (do (load-agent vm) (acquire-address vm)))]
>     (.detach vm)
>     address))

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