On Sat, Jul 30, 2011 at 12:10 AM, Julien Chastang <[email protected]> wrote: > By the way, I still think you need a lock in the count function in the > case where the caller tries to invoke the count function on a > partially constructed object.
I don't think that's possible in this case. As far as code running on the JVM is concerned, either the array does not exist or it does and already has its length field set correctly; you can't be holding a reference to a Java array that is "partially constructed" in such a manner as to allow data races with the length field. And I don't think Clojure allows holding a reference to a partially constructed type/record either, as you can't put custom code into the constructor that (MyRecord. x y z) calls, just call it and get back a reference to a fully constructed MyRecord. The code above uses reify and actually creates the array *before* calling reify, so I don't think we need to worry about calling count with a somehow still being null, either. -- Protege: What is this seething mass of parentheses?! Master: Your father's Lisp REPL. This is the language of a true hacker. Not as clumsy or random as C++; a language for a more civilized age. -- 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
