Skip to content

Commit ccc42b0

Browse files
ianlancetaylorgopherbot
authored andcommitted
doc/go1.21: document clear builtin and init order changes
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 <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Keith Randall <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]>
1 parent 3824d3d commit ccc42b0

File tree

1 file changed

+46
-22
lines changed

1 file changed

+46
-22
lines changed

doc/go1.21.html

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,53 @@ <h2 id="introduction">DRAFT RELEASE NOTES — Introduction to Go 1.21</h2>
2525

2626
<h2 id="language">Changes to the language</h2>
2727

28-
<!-- https://go.dev/issue/59488 -->
2928
<p>
30-
Go 1.21 adds two new built-ins to the language:
31-
the new functions <code>min</code> and <code>max</code> compute the
32-
smallest (or largest, for <code>max</code>) value of a fixed number
33-
of given arguments.
34-
See the language spec for <a href="https://tip.golang.org/ref/spec#Min_and_max">details</a>.
29+
Go 1.21 adds three new built-ins to the language.
30+
31+
<ul>
32+
<li><!-- https://go.dev/issue/59488 -->
33+
The new functions <code>min</code> and <code>max</code> compute the
34+
smallest (or largest, for <code>max</code>) value of a fixed number
35+
of given arguments.
36+
See the language spec for
37+
<a href="https://tip.golang.org/ref/spec#Min_and_max">details</a>.
38+
</li>
39+
<li><!-- https://go.dev/issue/56351 -->
40+
The new function <code>clear</code> deletes all elements from a
41+
map or zeroes all elements of a slice.
42+
See the language spec for
43+
<a href="https://tip.golang.org/ref/spec#Clear">details</a>.
44+
</li>
45+
</ul>
46+
</p>
47+
48+
<p><!-- https://go.dev/issue/57411 -->
49+
Package initialization order is now specified more precisely. The
50+
new algorithm is:
51+
<ul>
52+
<li>
53+
Sort all packages by import path.
54+
</li>
55+
<li>Repeat until the list of packages is empty:
56+
<ul>
57+
<li>
58+
Find the first package in the list for which all imports are
59+
already initialized.
60+
</li>
61+
<li>
62+
Initialize that package and remove it from the list.
63+
</li>
64+
</ul>
65+
</li>
66+
</ul>
67+
This may change the behavior of some programs that rely on a
68+
specific initialization ordering that was not expressed by explicit
69+
imports. The behavior of such programs was not well defined by the
70+
spec in past releases. The new rule provides an unambiguous definition.
71+
</p>
72+
73+
<p><!-- https://go.dev/issue/59338 -->
74+
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)
3575
</p>
3676

3777
<p><!-- https://go.dev/issue/56986 -->
@@ -745,22 +785,6 @@ <h3 id="minor_library_changes">Minor changes to the library</h3>
745785
</dd>
746786
</dl><!-- runtime/metrics -->
747787

748-
<dl id="spec"><dt><a href="/pkg/spec/">spec</a></dt>
749-
<dd>
750-
<p><!-- https://go.dev/issue/56351 -->
751-
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
752-
</p>
753-
754-
<p><!-- https://go.dev/issue/57411 -->
755-
TODO: <a href="https://go.dev/issue/57411">https://go.dev/issue/57411</a>: define initialization order more precisely
756-
</p>
757-
758-
<p><!-- https://go.dev/issue/59338 -->
759-
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)
760-
</p>
761-
</dd>
762-
</dl><!-- spec -->
763-
764788
<dl id="sync"><dt><a href="/pkg/sync/">sync</a></dt>
765789
<dd>
766790
<p><!-- https://go.dev/issue/56102, CL 451356 -->

0 commit comments

Comments
 (0)