From 17083a2fdf4475c3f11a3e6a0ef8cb595a5fc4d6 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Wed, 22 Jun 2022 11:58:06 -0700 Subject: [PATCH] spec: retitle section on "Assignments" to "Assignment statements" This permits a clear distinction between an individual assignment and an assignment statement which may assign more than one value. It also makes this section title consistent with all other section titles about statements. Adjust internal links and prose where appropriate. (Note that the spec already referred to assignment statements in a couple of places, even before this change.) Add an introductory paragraph to the section on assignment statements. Preparation for adding a section on value vs reference types (issue #5083). Change-Id: Ie140ac296e653c67da2a5a203b63352b3dc4f9f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/413615 Reviewed-by: Robert Griesemer Reviewed-by: Ian Lance Taylor --- doc/go_spec.html | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/doc/go_spec.html b/doc/go_spec.html index 3e47ee7bad..29109b6b9e 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -263,7 +263,7 @@ continue for import return var

The following character sequences represent operators -(including assignment operators) and punctuation: +(including assignment operators) and punctuation:

 +    &     +=    &=     &&    ==    !=    (    )
@@ -676,7 +676,7 @@ containing only untyped constant operands are untyped.
 A constant may be given a type explicitly by a constant declaration
 or conversion, or implicitly when used in a
 variable declaration or an
-assignment or as an
+assignment statement or as an
 operand in an expression.
 It is an error if the constant value
 cannot be represented as a value of the respective type.
@@ -780,7 +780,7 @@ x = v              // x has value (*T)(nil) and dynamic type *T
 

A variable's value is retrieved by referring to the variable in an expression; it is the most recent value -assigned to the variable. +assigned to the variable. If a variable has not yet been assigned a value, its value is the zero value for its type.

@@ -1591,7 +1591,7 @@ The number of map elements is called its length. For a map m, it can be discovered using the built-in function len and may change during execution. Elements may be added during execution -using assignments and retrieved with +using assignments and retrieved with index expressions; they may be removed with the delete built-in function.

@@ -1634,7 +1634,7 @@ The optional <- operator specifies the channel direction, send or receive. If a direction is given, the channel is directional, otherwise it is bidirectional. A channel may be constrained only to send or only to receive by -assignment or +assignment or explicit conversion.

@@ -2241,7 +2241,7 @@ the body of any nested function. The blank identifier is represented by the underscore character _. It serves as an anonymous placeholder instead of a regular (non-blank) identifier and has special meaning in declarations, -as an operand, and in assignments. +as an operand, and in assignment statements.

@@ -2748,7 +2748,7 @@ var _, found = entries[name] // map lookup; only interested in "found"

If a list of expressions is given, the variables are initialized -with the expressions following the rules for assignments. +with the expressions following the rules for assignment statements. Otherwise, each variable is initialized to its zero value.

@@ -3011,7 +3011,7 @@ resulting operand is an instantiated function.

The blank identifier may appear as an -operand only on the left-hand side of an assignment. +operand only on the left-hand side of an assignment statement.

@@ -3821,7 +3821,7 @@ Otherwise a[x] is illegal.

An index expression on a map a of type map[K]V -used in an assignment or initialization of the special form +used in an assignment statement or initialization of the special form

@@ -4037,7 +4037,7 @@ func f(y I) {
 

-A type assertion used in an assignment or initialization of the special form +A type assertion used in an assignment statement or initialization of the special form

@@ -5194,7 +5194,7 @@ f(<-ch)
 

-A receive expression used in an assignment or initialization of the special form +A receive expression used in an assignment statement or initialization of the special form

@@ -5942,7 +5942,7 @@ IncDecStmt = Expression ( "++" | "--" ) .
 

-The following assignment statements are semantically +The following assignment statements are semantically equivalent:

@@ -5953,7 +5953,14 @@ x-- x -= 1
-

Assignments

+

Assignment statements

+ +

+An assignment replaces the current value stored in a variable +with a new value specified by an expression. +An assignment statement may assign a single value to a single variable, or multiple values to a +matching number of variables. +

 Assignment = ExpressionList assign_op ExpressionList .
@@ -6522,7 +6529,7 @@ is nil, the range expression blocks forever.
 
 

The iteration values are assigned to the respective -iteration variables as in an assignment statement. +iteration variables as in an assignment statement.

-- 2.48.1