Alexandru Nedelcu <a...@bionicspirit.com> writes: > On Wed, May 7, 2014 at 5:57 PM, Phillip Lord > <phillip.l...@newcastle.ac.uk>wrote: > >> In general, though, if I write some code like >> >> (if (instance? Cons x) >> (pass-to-another-thread-without-synchronisation x)) >> >> I cannot guarantee the result of this because although I know that >> the head of x is fixed, I cannot guarantee that for the tail. If I know >> how x is constructed, of course, then I can make this guarantee. >> > > On the other hand, that's not the concern of the piece of code you > outlined. Because if "x" wasn't constructed properly and the "latest" data > in it is not visible, there's absolutely nothing you can do about it ;-) > Visibility is (or should be) the concern of the producer, not of the > consumer.
Perhaps I didn't word this well. The problem is with my code is that I only know about the implementation of the head of x. When I talk about "construction", I mean, "if I know what else is in x". Not clear, sorry! > > >> You get the a related problem in Java. >> >> List l = Collections.unmodifiedableList(l); >> >> Is l now unmodifiable? Well maybe, depending on what happened to it >> before. >> > > What happened to it "before" is not relevant, because again, there's > nothing you can do about it at this point and actually from this consumer's > perspective "before" doesn't exist ... there's only "now" with the only > question being if there are or there will be pending changes that may or > may not be published in the future (where "future" is kind of thread-local). Again, not great wording. l is unmodifiable if it's not be let out anywhere. That's the problem. The reason it's related to the issue in Clojure is that, List is an interface, while Cons is build in terms of an interface. You cannot define immutability (or unmodifiability) in terms of an abstract interface. Java String are immutable. Concrete and final implementation. > Concurrency is hard, but it's greatly simplified if you keep the concerns > for atomicity and visibility on the producer's side. Not going to disagree with this. I just answered the original question is all:-) Phil -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.