From: Robert Griesemer Date: Wed, 27 Jan 2010 17:35:39 +0000 (-0800) Subject: Clarify parsing of channel types. X-Git-Tag: weekly.2010-01-27~14 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1c369bd55fda993c2612452ec8e19dda2637106d;p=gostls13.git Clarify parsing of channel types. R=r, rsc CC=golang-dev https://golang.org/cl/194091 --- diff --git a/doc/go_spec.html b/doc/go_spec.html index b5931c110e..3823876457 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1107,6 +1107,19 @@ SendChannel = "chan" "<-" ElementType . RecvChannel = "<-" "chan" ElementType . +

+To avoid a parsing ambiguity in cases such as chan<- chan int, +the Channel production's ElementType cannot be a RecvChannel. +To construct such a type, parenthesize the RecvChannel first. +

+ +
+chan<- chan int     // same as chan<- (chan int)
+chan<- <-chan int   // same as chan<- (<-chan int)
+<-chan <-chan int   // same as <-chan (<-chan int)
+chan (<-chan int)
+
+

Upon creation, a channel can be used both to send and to receive values. By conversion or assignment, a channel may be constrained only to send or @@ -1126,7 +1139,6 @@ value can be made using the built-in function make, which takes the channel type and an optional capacity as arguments:

-
 make(chan int, 100)