From 25dd00295c54fa23a545bfdd27824ac403ceba84 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Thu, 29 Nov 2012 11:46:25 -0800 Subject: [PATCH] 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 --- doc/go_spec.html | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/doc/go_spec.html b/doc/go_spec.html index 458584e000e..5f640fb4b8c 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