Is it fair to say that this question is a little bit like the fate of Schrödinger's cat? You can't tell when any variable has been set (or perhaps messed up) until you access the variable and that is just that act that causes its multiple possible "messed-up" states to collapse to the right value.
On Thu, Sep 7, 2017 at 2:43 PM, Ian Lance Taylor <i...@golang.org> wrote: > On Thu, Sep 7, 2017 at 3:17 AM, Arpit Aggarwal <arpit94.i...@gmail.com> > wrote: > > > > I was going through the Go memory model at https://golang.org/ref/mem > > > > In the second line,first paragraph of Happens Before Description it is > > written that > > > > * compilers and processors may reorder the reads and writes executed > within > > a single goroutine only when the reordering does not change the behavior > > within that goroutine as defined by the language specification. > > > > I wanted to ask about what are the rules for read and writes reordering > > within a goroutine defined by the language specification. > > > > Happens before relation define rules on reads and writes on the same > > variable only, are there any rules in language specification for reads > and > > writes on different variables that may be reordered by processor or > compiler > > See https://golang.org/ref/spec#Order_of_evaluation . > > Also, as a general rule, reads and writes to local variables that do > not escape to the heap may be reordered arbitrarily. However, the > language does not define whether a variable escapes to the heap or > not, that is purely an issue of implementation. > > Ian > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Michael T. Jones michael.jo...@gmail.com -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.