From: Russ Cox Date: Mon, 11 Feb 2013 12:48:14 +0000 (-0500) Subject: spec: only require parens around ambiguous conversions X-Git-Tag: go1.1rc2~1076 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=71c941b6f6c133dec3c632b373eaae458eb055e7;p=gostls13.git spec: only require parens around ambiguous conversions This is documenting the status quo. The previous cleanup added this language as an implementation restriction, but at least for now it is really part of the language proper. Fixes #4605. R=golang-dev, r CC=golang-dev https://golang.org/cl/7305071 --- diff --git a/doc/go_spec.html b/doc/go_spec.html index 246a3656ad..5f84a29645 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -3448,16 +3448,20 @@ Conversion = Type "(" Expression [ "," ] ")" .

If the type starts with the operator * or <-, -or the keyword func, it must be parenthesized: +or if the type starts with the keyword func +and has no result list, it must be parenthesized when +necessary to avoid ambiguity:

 *Point(p)        // same as *(Point(p))
-(*Point)(p)      // p is converted to (*Point)
+(*Point)(p)      // p is converted to *Point
 <-chan int(c)    // same as <-(chan int(c))
-(<-chan int)(c)  // c is converted to (<-chan int)
+(<-chan int)(c)  // c is converted to <-chan int
 func()(x)        // function signature func() x
-(func())(x)      // x is converted to (func())
+(func())(x)      // x is converted to func()
+(func() int)(x)  // x is converted to func() int
+func() int(x)    // x is converted to func() int (unambiguous)
 

@@ -3553,12 +3557,6 @@ implements this functionality under restricted circumstances.

-

-Implementation restriction: For backward-compatibility with the Go 1 language -specification, a compiler may accept non-parenthesized literal function types -in conversions where the syntax is unambiguous. -

-

Conversions between numeric types