On Tue, Feb 24, 2009 at 4:44 AM, Anand Patil
<anand.prabhakar.pa...@gmail.com> wrote:
>
> Thanks Miʃel,
>
> On Feb 23, 10:15 pm, Michel Salim <michel.syl...@gmail.com> wrote:
>>
>> What's the object on which .countDown is called? You need to find
>> where it's first declared and give it a type annotation.
>>
>
> It's created here:
>
> let [
>          latch (java.util.concurrent.CountDownLatch. n)
>          ...
>
> Sorry if I'm being dense, but do you mean I should annotate it in the
> arguments list of the function where it's used, like so:
>
> (defn unlatching-watcher [#^java.util.concurrent.CountDownLatch latch
> cell cell-updated?]
>    "A watcher function that decrements a latch when a cell updates."
>    (if cell-updated?
>        (if (not (:updating @cell))
>            (.countDown latch))))
>
> or annotate in when it's actually created? If the latter, what's the
> syntax for that?
>
I was unclear in my hint, apologies. You need a type hint in the
function that takes a CountDownLatch, otherwise Clojure would not know
what it is until you try to call a method on it (and it has to do
reflection)

Annotating in the arguments list, as you showed in the example, is
fine. This way, you only annotate once for the entire function (I
didn't know you can do (.method #^classname foo) before, actually,
that was neat)

Regards,

-- 
miʃel salim  •  http://hircus.jaiku.com/
IUCS         •  msa...@cs.indiana.edu
Fedora       •  sali...@fedoraproject.org
MacPorts     •  hir...@macports.org

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