mirror of
https://github.com/golang/go.git
synced 2025-05-20 14:53:23 +00:00
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 <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>
This commit is contained in:
parent
3824d3d71e
commit
ccc42b0f91
@ -25,13 +25,53 @@ Do not send CLs removing the interior tags from such phrases.
|
|||||||
|
|
||||||
<h2 id="language">Changes to the language</h2>
|
<h2 id="language">Changes to the language</h2>
|
||||||
|
|
||||||
<!-- https://go.dev/issue/59488 -->
|
|
||||||
<p>
|
<p>
|
||||||
Go 1.21 adds two new built-ins to the language:
|
Go 1.21 adds three 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
|
<ul>
|
||||||
of given arguments.
|
<li><!-- https://go.dev/issue/59488 -->
|
||||||
See the language spec for <a href="https://tip.golang.org/ref/spec#Min_and_max">details</a>.
|
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>
|
||||||
|
|
||||||
<p><!-- https://go.dev/issue/56986 -->
|
<p><!-- https://go.dev/issue/56986 -->
|
||||||
@ -745,22 +785,6 @@ Do not send CLs removing the interior tags from such phrases.
|
|||||||
</dd>
|
</dd>
|
||||||
</dl><!-- runtime/metrics -->
|
</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>
|
<dl id="sync"><dt><a href="/pkg/sync/">sync</a></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<p><!-- https://go.dev/issue/56102, CL 451356 -->
|
<p><!-- https://go.dev/issue/56102, CL 451356 -->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user