From ef54d5cff0ef4747632c007886fd59b8ad0f287f Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Sat, 22 Sep 2012 05:53:48 +1000 Subject: [PATCH] [release-branch.go1] spec: clarify receive operator MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ««« backport c72ac7873261 spec: clarify receive operator - 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 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/doc/go_spec.html b/doc/go_spec.html index 90acc1704e..53089160f1 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -3184,6 +3184,9 @@ the value of the receive operation <-ch is the value received from the channel ch. The type of the value is the element type of the channel. The expression blocks until a value is available. Receiving from a nil channel blocks forever. +Receiving from a closed channel always succeeds, +immediately returning the element type's zero +value.

@@ -3204,11 +3207,11 @@ var x, ok = <-ch
 

-yields an additional result. -The boolean variable ok indicates whether -the received value was sent on the channel (true) -or is a zero value returned -because the channel is closed and empty (false). +yields an additional result of type bool reporting whether the +communication succeeded. The value of ok is true +if the value received was delivered by a successful send operation to the +channel, or false if it is a zero value generated because the +channel is closed and empty.