From: Robert Griesemer Date: Wed, 3 Oct 2012 20:46:37 +0000 (-0700) Subject: go spec: conversion types starting with "func" must be parenthesized X-Git-Tag: go1.1rc2~2265 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3188ffc93138ca18857575052f74100d64e31df5;p=gostls13.git go spec: conversion types starting with "func" must be parenthesized Also: Be explicit what operator means with respect to conversion types. The parenthesis requirement is a language change. At the moment, literal function types in conversions that cannot possibly be followed by a '(' don't need parentheses. For instance: func(int)int(x) -> same as (func(int)int)(x) func()()(x) -> same as (func())(x) but: func(int)(x) -> could be func(int)x {...} Fixes #4109. R=rsc, r, iant, ken, iant CC=golang-dev https://golang.org/cl/6584065 --- diff --git a/doc/go_spec.html b/doc/go_spec.html index de35425b3b..165e9bebf2 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -3394,7 +3394,8 @@ Conversion = Type "(" Expression [ "," ] ")" .

-If the type starts with an operator it must be parenthesized: +If the type starts with the operator * or <-, +or the keyword func, it must be parenthesized:

@@ -3402,6 +3403,8 @@ If the type starts with an operator it must be parenthesized:
 (*Point)(p)      // p is converted to (*Point)
 <-chan int(c)    // same as <-(chan int(c))
 (<-chan int)(c)  // c is converted to (<-chan int)
+func()(x)        // function signature func() x
+(func())(x)      // x is converted to (func())
 

@@ -3488,6 +3491,12 @@ 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