]> Cypherpunks repositories - gostls13.git/commitdiff
spec: clarify receive operator
authorRobert Griesemer <gri@golang.org>
Mon, 25 Jun 2012 18:28:24 +0000 (11:28 -0700)
committerRobert Griesemer <gri@golang.org>
Mon, 25 Jun 2012 18:28:24 +0000 (11:28 -0700)
- receiving from a closed channel returns immediately
- in the ,ok form, the 2nd result is of type bool, not
  just boolean (gc and ggcgo agree).

Per dsymonds' suggestion.

R=r, rsc, ken, iant, dsymonds
CC=golang-dev
https://golang.org/cl/6333057

doc/go_spec.html

index 90acc1704e7d3bcdf48837dfaadd61c7a510ead0..53089160f10ce9618551efa8e9c2c56f8e97ce18 100644 (file)
@@ -1,6 +1,6 @@
 <!--{
        "Title": "The Go Programming Language Specification",
-       "Subtitle": "Version of June 4, 2012",
+       "Subtitle": "Version of June 22, 2012",
        "Path": "/ref/spec"
 }-->
 
@@ -3184,6 +3184,9 @@ the value of the receive operation <code>&lt;-ch</code> is the value received
 from the channel <code>ch</code>. The type of the value is the element type of
 the channel. The expression blocks until a value is available.
 Receiving from a <code>nil</code> channel blocks forever.
+Receiving from a <a href="#Close">closed</a> channel always succeeds,
+immediately returning the element type's <a href="#The_zero_value">zero
+value</a>.
 </p>
 
 <pre>
@@ -3204,11 +3207,11 @@ var x, ok = &lt;-ch
 </pre>
 
 <p>
-yields an additional result.
-The boolean variable <code>ok</code> indicates whether
-the received value was sent on the channel (<code>true</code>)
-or is a <a href="#The_zero_value">zero value</a> returned
-because the channel is closed and empty (<code>false</code>).
+yields an additional result of type <code>bool</code> reporting whether the
+communication succeeded. The value of <code>ok</code> is <code>true</code>
+if the value received was delivered by a successful send operation to the
+channel, or <code>false</code> if it is a zero value generated because the
+channel is closed and empty.
 </p>
 
 <!--