Commit 6af887ec authored by Robert Griesemer's avatar Robert Griesemer

go spec: restricted expressions may still be parenthesized

No language change.

- added a few examples with parentheses
- added a corresponding sentence to assignments
  (this explicitly permits: (_) = 0, currently allowed by 6g,
  gofmt, but marked as an error by gccgo).

R=rsc, r, iant
CC=golang-dev
https://golang.org/cl/4446071
parent a46a311d
<!-- title The Go Programming Language Specification --> <!-- title The Go Programming Language Specification -->
<!-- subtitle Version of Apr 22, 2011 --> <!-- subtitle Version of May 2, 2011 -->
<!-- <!--
TODO TODO
...@@ -3522,10 +3522,9 @@ Error: log.Panic("error encountered") ...@@ -3522,10 +3522,9 @@ Error: log.Panic("error encountered")
<p> <p>
Function calls, method calls, and receive operations Function calls, method calls, and receive operations
can appear in statement context. can appear in statement context. Such statements may be parenthesized.
</p> </p>
<pre class="ebnf"> <pre class="ebnf">
ExpressionStmt = Expression . ExpressionStmt = Expression .
</pre> </pre>
...@@ -3534,6 +3533,7 @@ ExpressionStmt = Expression . ...@@ -3534,6 +3533,7 @@ ExpressionStmt = Expression .
h(x+y) h(x+y)
f.Close() f.Close()
&lt;-ch &lt;-ch
(&lt;-ch)
</pre> </pre>
...@@ -3604,15 +3604,15 @@ assign_op = [ add_op | mul_op ] "=" . ...@@ -3604,15 +3604,15 @@ assign_op = [ add_op | mul_op ] "=" .
<p> <p>
Each left-hand side operand must be <a href="#Address_operators">addressable</a>, Each left-hand side operand must be <a href="#Address_operators">addressable</a>,
a map index expression, a map index expression, or the <a href="#Blank_identifier">blank identifier</a>.
or the <a href="#Blank_identifier">blank identifier</a>. Operands may be parenthesized.
</p> </p>
<pre> <pre>
x = 1 x = 1
*p = f() *p = f()
a[i] = 23 a[i] = 23
k = &lt;-ch (k) = &lt;-ch // same as: k = &lt;-ch
</pre> </pre>
<p> <p>
...@@ -4131,7 +4131,7 @@ case i1 = &lt;-c1: ...@@ -4131,7 +4131,7 @@ case i1 = &lt;-c1:
print("received ", i1, " from c1\n") print("received ", i1, " from c1\n")
case c2 &lt;- i2: case c2 &lt;- i2:
print("sent ", i2, " to c2\n") print("sent ", i2, " to c2\n")
case i3, ok := &lt;-c3: case i3, ok := (&lt;-c3): // same as: i3, ok := &lt;-c3
if ok { if ok {
print("received ", i3, " from c3\n") print("received ", i3, " from c3\n")
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment