aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2010-01-27 09:35:39 -0800
committerRobert Griesemer <gri@golang.org>2010-01-27 09:35:39 -0800
commit1c369bd55fda993c2612452ec8e19dda2637106d (patch)
treee5a4de90dce64d4266a21e43c536f2d68fe2c6e5
parent2a01d7287851e988d1e093dbe5788d3631e770b5 (diff)
downloadgo-1c369bd55fda993c2612452ec8e19dda2637106d.tar.gz
go-1c369bd55fda993c2612452ec8e19dda2637106d.zip
Clarify parsing of channel types.
R=r, rsc CC=golang-dev https://golang.org/cl/194091
-rw-r--r--doc/go_spec.html14
1 files changed, 13 insertions, 1 deletions
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
@@ -1108,6 +1108,19 @@ RecvChannel = "&lt;-" "chan" ElementType .
</pre>
<p>
+To avoid a parsing ambiguity in cases such as <code>chan&lt;- chan int</code>,
+the Channel production's ElementType cannot be a RecvChannel.
+To construct such a type, parenthesize the RecvChannel first.
+</p>
+
+<pre>
+chan&lt;- chan int // same as chan&lt;- (chan int)
+chan&lt;- &lt;-chan int // same as chan&lt;- (&lt;-chan int)
+&lt;-chan &lt;-chan int // same as &lt;-chan (&lt;-chan int)
+chan (&lt;-chan int)
+</pre>
+
+<p>
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
to receive. This constraint is called a channel's <i>direction</i>; either
@@ -1126,7 +1139,6 @@ value can be made using the built-in function <code>make</code>,
which takes the channel type and an optional capacity as arguments:
</p>
-
<pre>
make(chan int, 100)
</pre>