]> Cypherpunks.ru repositories - gostls13.git/commitdiff
doc/go1.21: document clear builtin and init order changes
authorIan Lance Taylor <iant@golang.org>
Fri, 26 May 2023 21:04:37 +0000 (14:04 -0700)
committerGopher Robot <gobot@golang.org>
Sat, 27 May 2023 02:02:49 +0000 (02:02 +0000)
Also move all the language changes to the same part of the release notes.

For #56351
For #57411

Change-Id: Id1c51b5eb8f7d85e61a2ae44ee7d73bb13036631
Reviewed-on: https://go-review.googlesource.com/c/go/+/498755
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

doc/go1.21.html

index 3758d282c3c83c113105a33de38b6a079cb1d18d..075cee592acbf131f31290d4177cfcc0bff24171 100644 (file)
@@ -25,13 +25,53 @@ Do not send CLs removing the interior tags from such phrases.
 
 <h2 id="language">Changes to the language</h2>
 
-<!-- https://go.dev/issue/59488 -->
 <p>
-  Go 1.21 adds two new built-ins to the language:
-  the new functions <code>min</code> and <code>max</code> compute the
-  smallest (or largest, for <code>max</code>) value of a fixed number
-  of given arguments.
-  See the language spec for <a href="https://tip.golang.org/ref/spec#Min_and_max">details</a>.
+  Go 1.21 adds three new built-ins to the language.
+
+  <ul>
+    <li><!-- https://go.dev/issue/59488 -->
+      The new functions <code>min</code> and <code>max</code> compute the
+      smallest (or largest, for <code>max</code>) value of a fixed number
+      of given arguments.
+      See the language spec for
+      <a href="https://tip.golang.org/ref/spec#Min_and_max">details</a>.
+    </li>
+    <li><!-- https://go.dev/issue/56351 -->
+      The new function <code>clear</code> deletes all elements from a
+      map or zeroes all elements of a slice.
+      See the language spec for
+      <a href="https://tip.golang.org/ref/spec#Clear">details</a>.
+    </li>
+  </ul>
+</p>
+
+<p><!-- https://go.dev/issue/57411 -->
+  Package initialization order is now specified more precisely. The
+  new algorithm is:
+  <ul>
+    <li>
+      Sort all packages by import path.
+    </li>
+    <li>Repeat until the list of packages is empty:
+      <ul>
+       <li>
+         Find the first package in the list for which all imports are
+         already initialized.
+       </li>
+       <li>
+         Initialize that package and remove it from the list.
+       </li>
+      </ul>
+    </li>
+  </ul>
+  This may change the behavior of some programs that rely on a
+  specific initialization ordering that was not expressed by explicit
+  imports. The behavior of such programs was not well defined by the
+  spec in past releases. The new rule provides an unambiguous definition.
+</p>
+
+<p><!-- https://go.dev/issue/59338 -->
+  TODO: <a href="https://go.dev/issue/59338">https://go.dev/issue/59338</a>: infer type arguments from assignments of generic functions (reverse type inference)
 </p>
 
 <p><!-- https://go.dev/issue/56986 -->
@@ -745,22 +785,6 @@ Do not send CLs removing the interior tags from such phrases.
   </dd>
 </dl><!-- runtime/metrics -->
 
-<dl id="spec"><dt><a href="/pkg/spec/">spec</a></dt>
-  <dd>
-    <p><!-- https://go.dev/issue/56351 -->
-      TODO: <a href="https://go.dev/issue/56351">https://go.dev/issue/56351</a>: add clear(x) builtin, to clear map, zero content of slice
-    </p>
-
-    <p><!-- https://go.dev/issue/57411 -->
-      TODO: <a href="https://go.dev/issue/57411">https://go.dev/issue/57411</a>: define initialization order more precisely
-    </p>
-
-    <p><!-- https://go.dev/issue/59338 -->
-      TODO: <a href="https://go.dev/issue/59338">https://go.dev/issue/59338</a>: infer type arguments from assignments of generic functions (reverse type inference)
-    </p>
-  </dd>
-</dl><!-- spec -->
-
 <dl id="sync"><dt><a href="/pkg/sync/">sync</a></dt>
   <dd>
     <p><!-- https://go.dev/issue/56102, CL 451356 -->