]> Cypherpunks repositories - gostls13.git/commitdiff
spec, unsafe: clarify unsafe.Slice docs
authorIan Lance Taylor <iant@golang.org>
Thu, 1 Jul 2021 23:52:59 +0000 (16:52 -0700)
committerIan Lance Taylor <iant@golang.org>
Fri, 2 Jul 2021 19:26:52 +0000 (19:26 +0000)
For #19367

Change-Id: If0ff8ddba3b6b48e2e198cf3653e73284c7572a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/332409
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
doc/go_spec.html
src/unsafe/unsafe.go

index e0602418e803f7637e1c82dfdebaf3d247a2d6a6..ad21ffb1b88515f2291a611d8051824e36efd363 100644 (file)
@@ -1,6 +1,6 @@
 <!--{
        "Title": "The Go Programming Language Specification",
-       "Subtitle": "Version of Jun 28, 2021",
+       "Subtitle": "Version of Jul 1, 2021",
        "Path": "/ref/spec"
 }-->
 
@@ -6782,7 +6782,8 @@ The rules for <a href="/pkg/unsafe#Pointer">valid uses</a> of <code>Pointer</cod
 
 <p>
 The function <code>Slice</code> returns a slice whose underlying array starts at <code>ptr</code>
-and whose length and capacity are <code>len</code>:
+and whose length and capacity are <code>len</code>.
+<code>Slice(ptr, len)</code> is equivalent to
 </p>
 
 <pre>
@@ -6790,7 +6791,8 @@ and whose length and capacity are <code>len</code>:
 </pre>
 
 <p>
-As a special case, if <code>ptr</code> is <code>nil</code> and <code>len</code> is zero,
+except that, as a special case, if <code>ptr</code>
+is <code>nil</code> and <code>len</code> is zero,
 <code>Slice</code> returns <code>nil</code>.
 </p>
 
index eaf72c96181fd5642eaf59a49896e215f94a9c00..16e3890d0bee3949e0d885a29a425e8af1b19776 100644 (file)
@@ -217,11 +217,13 @@ func Alignof(x ArbitraryType) uintptr
 func Add(ptr Pointer, len IntegerType) Pointer
 
 // The function Slice returns a slice whose underlying array starts at ptr
-// and whose length and capacity are len:
+// and whose length and capacity are len.
+// Slice(ptr, len) is equivalent to
 //
 //     (*[len]ArbitraryType)(unsafe.Pointer(ptr))[:]
 //
-// As a special case, if ptr is nil and len is zero, Slice returns nil.
+// except that, as a special case, if ptr is nil and len is zero,
+// Slice returns nil.
 //
 // The len argument must be of integer type or an untyped constant.
 // A constant len argument must be non-negative and representable by a value of type int;