diff options
author | Matthew Dempsky <mdempsky@google.com> | 2021-06-07 14:28:14 -0700 |
---|---|---|
committer | Matthew Dempsky <mdempsky@google.com> | 2021-06-07 23:44:22 +0000 |
commit | 39c39ae52f0f35085be8ca1e004dee509abc21de (patch) | |
tree | bec4485b03065857ea492d6b935c684673d0fdf3 | |
parent | dc8b55895166c808b02e93ef4a778c6648c10bf3 (diff) | |
download | go-39c39ae52f0f35085be8ca1e004dee509abc21de.tar.gz go-39c39ae52f0f35085be8ca1e004dee509abc21de.zip |
doc: document Go 1.17 language changes
Fixes #46020.
Change-Id: Iadf9a0ac4a8863e17155d6ba1af2cc497634a634
Reviewed-on: https://go-review.googlesource.com/c/go/+/325870
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
-rw-r--r-- | doc/go1.17.html | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/doc/go1.17.html b/doc/go1.17.html index 7438d894fe..c1978ff1c1 100644 --- a/doc/go1.17.html +++ b/doc/go1.17.html @@ -25,12 +25,46 @@ Do not send CLs removing the interior tags from such phrases. <h2 id="language">Changes to the language</h2> -<p><!-- CL 216424 --> - TODO: <a href="https://golang.org/cl/216424">https://golang.org/cl/216424</a>: allow conversion from slice to array ptr -</p> +<p> + Go 1.17 includes three small enhancements to the language. +</p> + +<ul> + <li><!-- CL 216424; issue 395 --> + <a href="/ref/spec#Conversions_from_slice_to_array_pointer">Conversions + from slice to array pointer</a>: An expression <code>s</code> of + type <code>[]T</code> may now be converted to array pointer type + <code>*[N]T</code>. If <code>a</code> is the result of such a + conversion, then corresponding indices that are in range refer to + the same underlying elements: <code>&a[i] == &s[i]</code> + for <code>0 <= i < N</code>. The conversion panics if + <code>len(s)</code> is less than <code>N</code>. + </li> + + <li><!-- CL 312212; issue 40481 --> + <a href="/pkg/unsafe#Add"><code>unsafe.Add</code></a>: + <code>unsafe.Add(ptr, len)</code> adds <code>len</code> + to <code>ptr</code> and returns the updated pointer + <code>unsafe.Pointer(uintptr(ptr) + uintptr(len))</code>. + </li> + + <li><!-- CL 312212; issue 19367 --> + <a href="/pkg/unsafe#Slice"><code>unsafe.Slice</code></a>: + For expression <code>ptr</code> of type <code>*T</code>, + <code>unsafe.Slice(ptr, len)</code> returns a slice of + type <code>[]T</code> whose underlying array starts + at <code>ptr</code> and whose length and capacity + are <code>len</code>. + </li> +</ul> -<p><!-- CL 312212 --> - TODO: <a href="https://golang.org/cl/312212">https://golang.org/cl/312212</a>: add unsafe.Add and unsafe.Slice +<p> + These enhancements were added to simplify writing code that conforms + to <code>unsafe.Pointer</code>'s <a href="/pkg/unsafe/#Pointer">safety + rules</a>, but the rules remain unchanged. In particular, existing + programs that correctly use <code>unsafe.Pointer</code> remain + valid, and new programs must still follow the rules when + using <code>unsafe.Add</code> or <code>unsafe.Slice</code>. </p> <h2 id="ports">Ports</h2> |