mirror of
https://github.com/golang/go
synced 2024-11-24 10:50:13 -07:00
spec: narrow syntax for expression and select statements
This is not a language change, it simply expresses the accepted cases explicitly in the respective productions. R=rsc, r, iant CC=golang-dev https://golang.org/cl/4428057
This commit is contained in:
parent
0add1c3ed8
commit
95f544a199
@ -1,5 +1,5 @@
|
|||||||
<!-- title The Go Programming Language Specification -->
|
<!-- title The Go Programming Language Specification -->
|
||||||
<!-- subtitle Version of Apr 22, 2011 -->
|
<!-- subtitle Version of Apr 29, 2011 -->
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
TODO
|
TODO
|
||||||
@ -3035,7 +3035,7 @@ f(<-ch)
|
|||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
A receive expression used in an assignment or initialization of the form
|
A receive operation used in an assignment or initialization of the form
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
@ -3521,13 +3521,14 @@ Error: log.Panic("error encountered")
|
|||||||
<h3 id="Expression_statements">Expression statements</h3>
|
<h3 id="Expression_statements">Expression statements</h3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Function calls, method calls, and receive operations
|
Function calls, method calls, and
|
||||||
|
<a href="#Receive_operator">receive operations</a>
|
||||||
can appear in statement context.
|
can appear in statement context.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<pre class="ebnf">
|
<pre class="ebnf">
|
||||||
ExpressionStmt = Expression .
|
ExpressionStmt = PrimaryExpr Call | RecvExpr .
|
||||||
|
RecvExpr = "<-" UnaryExpr .
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
@ -4087,11 +4088,9 @@ SelectStmt = "select" "{" { CommClause } "}" .
|
|||||||
CommClause = CommCase ":" { Statement ";" } .
|
CommClause = CommCase ":" { Statement ";" } .
|
||||||
CommCase = "case" ( SendStmt | RecvStmt ) | "default" .
|
CommCase = "case" ( SendStmt | RecvStmt ) | "default" .
|
||||||
RecvStmt = [ Expression [ "," Expression ] ( "=" | ":=" ) ] RecvExpr .
|
RecvStmt = [ Expression [ "," Expression ] ( "=" | ":=" ) ] RecvExpr .
|
||||||
RecvExpr = Expression .
|
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
RecvExpr must be a <a href="#Receive_operator">receive operation</a>.
|
|
||||||
For all the cases in the "select"
|
For all the cases in the "select"
|
||||||
statement, the channel expressions are evaluated in top-to-bottom order, along with
|
statement, the channel expressions are evaluated in top-to-bottom order, along with
|
||||||
any expressions that appear on the right hand side of send statements.
|
any expressions that appear on the right hand side of send statements.
|
||||||
|
Loading…
Reference in New Issue
Block a user