From 71c941b6f6c133dec3c632b373eaae458eb055e7 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 11 Feb 2013 07:48:14 -0500 Subject: [PATCH] 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 --- doc/go_spec.html | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) 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

-- 2.48.1