On Mon, Oct 26, 2009 at 1:17 AM, Gorsal <[email protected]> wrote:

> So i've been trying to find two equivalents to keywords in java. The
> first one is synchronized. is there any syncrhonized keyword in
> clojure?
>

(locking obj
  (do-something-with obj foo bar))

is equivalent to Java

synchronized (obj) {
  obj.doSomething(foo, bar);
}

More importantly, however, ive been trying to do somethign like this
> (proxy [AbstractHandler] []
>     (execute [~var]
>       ~...@body))
> What is the equivalent of the this keyword? Or would i simply call
> other methods defined by the AbstractHandler interface by simply going
> (func1-name)?


It's not clear what you're trying to do here. (In particular we don't know
what AbstractHandler is. Also, what's with the unquoting?)

However, from (doc proxy):

"Each method fn takes an additional implicit first arg, which is bound to
'this."

So presumably you just use the symbol this, e.g.

(.method this arg1 arg2)

in your proxy to e.g. call another method of the same object.

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

Reply via email to