On Sat, Mar 19, 2016 at 5:44 PM, Dan Mullineux <
dan...@gmail.com> wrote:
>
> I certainly don't doubt Ian and Dmitrys pedigree. Dmitry's article was more
> about C++, and Ian's comment was kind of in passing. I wasn't sure it was a
> definitive statement.
To be honest I'm not sure it's a definitive statement either. I do
think it's clearly best to write your programs to never have a race
condition. And I think there is a strong argument to be made that
race conditions should be treated as undefined behavior. But when it
comes to considering what the constraints on a Go implementation are,
it's possible that a Go implementation should not just give up in the
face of a race condition. It's possible that Go should require that a
read of a single memory word should always return some value written
to that word, though which value will be unpredictable, and no
necessary relationship is implied between that word and any other
word. If that idea is adopted, then I think in your `a = a + 1`
example the resulting a will always be at least one more than the
initial a, assuming correct happens-before relationships on both sides
(though I note that the example is not a great one, since have
sync/atomic/AddXX). This is an area that has not, I think, been fully
settled.
Ian