]> Cypherpunks.ru repositories - gostls13.git/commitdiff
doc/go_mem: explain arrays, structs, and complex numbers
authorRuss Cox <rsc@golang.org>
Mon, 31 Jul 2023 18:01:00 +0000 (14:01 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 31 Jul 2023 19:10:40 +0000 (19:10 +0000)
Arrays, structs, and complex numbers are collections of values that
are handled separately by the memory model.

An earlier version may have said this, but the current version does not.
Say it.

Change-Id: If3928bed6659e58e688f88aa0dde05423cbb3820
Reviewed-on: https://go-review.googlesource.com/c/go/+/514476
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
doc/go_mem.html

index 661e1e781cff60ac90138ad0bf5671ffa7a120f2..e0a7539472e650e0aa1a45178a493152c149b8f9 100644 (file)
@@ -221,7 +221,7 @@ for programs that do contain races.
 </p>
 
 <p>
-First, any implementation can, upon detecting a data race,
+Any implementation can, upon detecting a data race,
 report the race and halt execution of the program.
 Implementations using ThreadSanitizer
 (accessed with “<code>go</code> <code>build</code> <code>-race</code>”)
@@ -229,7 +229,18 @@ do exactly this.
 </p>
 
 <p>
-Otherwise, a read <i>r</i> of a memory location <i>x</i>
+A read of an array, struct, or complex number
+may by implemented as a read of each individual sub-value
+(array element, struct field, or real/imaginary component),
+in any order.
+Similarly, a write of an array, struct, or complex number
+may be implemented as a write of each individual sub-value,
+in any order.
+</p>
+
+<p>
+A read <i>r</i> of a memory location <i>x</i>
+holding a value
 that is not larger than a machine word must observe
 some write <i>w</i> such that <i>r</i> does not happen before <i>w</i>
 and there is no write <i>w'</i> such that <i>w</i> happens before <i>w'</i>