mirror of
https://github.com/golang/go
synced 2024-11-21 20:34:40 -07:00
go spec: clarify rules for append, scope rules for :=
Fixes #1936. Fixes #1940. R=rsc, r, iant, ken, iant CC=golang-dev https://golang.org/cl/4585049
This commit is contained in:
parent
27cbf06d50
commit
95b8137a16
@ -1,5 +1,5 @@
|
|||||||
<!-- title The Go Programming Language Specification -->
|
<!-- title The Go Programming Language Specification -->
|
||||||
<!-- subtitle Version of June 7, 2011 -->
|
<!-- subtitle Version of June 10, 2011 -->
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
TODO
|
TODO
|
||||||
@ -10,7 +10,6 @@ TODO
|
|||||||
[ ] clarify what a field name is in struct declarations
|
[ ] clarify what a field name is in struct declarations
|
||||||
(struct{T} vs struct {T T} vs struct {t T})
|
(struct{T} vs struct {T T} vs struct {t T})
|
||||||
[ ] need explicit language about the result type of operations
|
[ ] need explicit language about the result type of operations
|
||||||
[ ] should string(1<<s) and float32(1<<s) be valid?
|
|
||||||
[ ] should probably write something about evaluation order of statements even
|
[ ] should probably write something about evaluation order of statements even
|
||||||
though obvious
|
though obvious
|
||||||
[ ] review language on implicit dereferencing
|
[ ] review language on implicit dereferencing
|
||||||
@ -1452,6 +1451,7 @@ Go is lexically scoped using blocks:
|
|||||||
|
|
||||||
<li>The scope of a constant or variable identifier declared
|
<li>The scope of a constant or variable identifier declared
|
||||||
inside a function begins at the end of the ConstSpec or VarSpec
|
inside a function begins at the end of the ConstSpec or VarSpec
|
||||||
|
(ShortVarDecl for short variable declarations)
|
||||||
and ends at the end of the innermost containing block.</li>
|
and ends at the end of the innermost containing block.</li>
|
||||||
|
|
||||||
<li>The scope of a type identifier declared inside a function
|
<li>The scope of a type identifier declared inside a function
|
||||||
@ -4590,11 +4590,14 @@ Two built-in functions assist in common slice operations.
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The function <code>append</code> appends zero or more values <code>x</code>
|
The <a href="#Function_types">variadic</a> function <code>append</code>
|
||||||
|
appends zero or more values <code>x</code>
|
||||||
to <code>s</code> of type <code>S</code>, which must be a slice type, and
|
to <code>s</code> of type <code>S</code>, which must be a slice type, and
|
||||||
returns the resulting slice, also of type <code>S</code>.
|
returns the resulting slice, also of type <code>S</code>.
|
||||||
Each value <code>x</code> must be <a href="#Assignability">assignable</a> to
|
The values <code>x</code> are passed to a parameter of type <code>...T</code>
|
||||||
the <a href="#Slice_types">element type</a> of <code>S</code>.
|
where <code>T</code> is the <a href="#Slice_types">element type</a> of
|
||||||
|
<code>S</code> and the respective
|
||||||
|
<a href="#Passing_arguments_to_..._parameters">parameter passing rules</a> apply.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre class="grammar">
|
<pre class="grammar">
|
||||||
|
Loading…
Reference in New Issue
Block a user