]> Cypherpunks repositories - gostls13.git/commitdiff
spec: clarify use of built-ins in go/defer statements
authorRobert Griesemer <gri@golang.org>
Thu, 29 Nov 2012 19:46:25 +0000 (11:46 -0800)
committerRobert Griesemer <gri@golang.org>
Thu, 29 Nov 2012 19:46:25 +0000 (11:46 -0800)
1) Built-ins are restricted like for expression statements.
   This documents the status quo.

2) Calls cannot be parenthesized. The spec is not clear. gccgo
   permits it already, gc doesn't. Be explicit in the spec.

 Fixes #4462.

R=rsc, iant, r, ken, lvd
CC=golang-dev
https://golang.org/cl/6861043

doc/go_spec.html

index 458584e000eb814b53723c1e44f40c18095a8dfe..5f640fb4b8c4008d342c719f6317afba3ca073b0 100644 (file)
@@ -1,6 +1,6 @@
 <!--{
        "Title": "The Go Programming Language Specification",
-       "Subtitle": "Version of November 26, 2012",
+       "Subtitle": "Version of November 29, 2012",
        "Path": "/ref/spec"
 }-->
 
@@ -4431,7 +4431,7 @@ for w := range ch {
 <h3 id="Go_statements">Go statements</h3>
 
 <p>
-A "go" statement starts the execution of a function or method call
+A "go" statement starts the execution of a function call
 as an independent concurrent thread of control, or <i>goroutine</i>,
 within the same address space.
 </p>
@@ -4441,7 +4441,12 @@ GoStmt = "go" Expression .
 </pre>
 
 <p>
-The expression must be a call.
+The expression must be a function or method call; it cannot be parenthesized.
+Calls of built-in functions are restricted as for
+<a href="#Expression_statements">expression statements</a>.
+</p>
+
+<p>
 The function value and parameters are
 <a href="#Calls">evaluated as usual</a>
 in the calling goroutine, but
@@ -4758,7 +4763,12 @@ DeferStmt = "defer" Expression .
 </pre>
 
 <p>
-The expression must be a function or method call.
+The expression must be a function or method call; it cannot be parenthesized.
+Calls of built-in functions are restricted as for
+<a href="#Expression_statements">expression statements</a>.
+</p>
+
+<p>
 Each time the "defer" statement
 executes, the function value and parameters to the call are
 <a href="#Calls">evaluated as usual</a>