]> Cypherpunks repositories - gostls13.git/commitdiff
spec: clarify struct field and array element comparison order
authorRobert Griesemer <gri@golang.org>
Thu, 10 Nov 2022 21:50:33 +0000 (13:50 -0800)
committerGopher Robot <gobot@golang.org>
Mon, 14 Nov 2022 01:28:11 +0000 (01:28 +0000)
Fixes #8606.

Change-Id: I64b13b2ed61ecae4641264deb47c9f7653a80356
Reviewed-on: https://go-review.googlesource.com/c/go/+/449536
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

doc/go_spec.html

index c188cd4c1f205a863d531b7758a52a9ac73e1fad..e55f34aa6383019530846849198b8fdac7fa8a8d 100644 (file)
@@ -1,6 +1,6 @@
 <!--{
        "Title": "The Go Programming Language Specification",
-       "Subtitle": "Version of September 21, 2022",
+       "Subtitle": "Version of November 10, 2022",
        "Path": "/ref/spec"
 }-->
 
@@ -5083,12 +5083,16 @@ These terms and the result of the comparisons are defined as follows:
        <li>
        Struct values are comparable if all their fields are comparable.
        Two struct values are equal if their corresponding
-       non-<a href="#Blank_identifier">blank</a> fields are equal.
+       non-<a href="#Blank_identifier">blank</a> field values are equal.
+       The fields are compared in source order, and comparison stops as
+       soon as two field values differ (or all fields have been compared).
        </li>
 
        <li>
        Array values are comparable if values of the array element type are comparable.
-       Two array values are equal if their corresponding elements are equal.
+       Two array values are equal if their corresponding element values are equal.
+       The elements are compared in ascending index order, and comparison stops
+       as soon as two element values differ (or all elements have been compared).
        </li>
 </ul>