From: Robert Griesemer Date: Thu, 29 Nov 2012 19:46:25 +0000 (-0800) Subject: spec: clarify use of built-ins in go/defer statements X-Git-Tag: go1.1rc2~1753 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=25dd00295c54fa23a545bfdd27824ac403ceba84;p=gostls13.git spec: clarify use of built-ins in go/defer statements 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 --- diff --git a/doc/go_spec.html b/doc/go_spec.html index 458584e000..5f640fb4b8 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -4431,7 +4431,7 @@ for w := range ch {

Go statements

-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 goroutine, within the same address space.

@@ -4441,7 +4441,12 @@ GoStmt = "go" Expression .

-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 +expression statements. +

+ +

The function value and parameters are evaluated as usual in the calling goroutine, but @@ -4758,7 +4763,12 @@ DeferStmt = "defer" Expression .

-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 +expression statements. +

+ +

Each time the "defer" statement executes, the function value and parameters to the call are evaluated as usual