From: Robert Griesemer Date: Mon, 25 Jun 2012 18:28:24 +0000 (-0700) Subject: spec: clarify receive operator X-Git-Tag: go1.1rc2~2888 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=689931c5b02f7509a125f06480d3673ac85f21d5;p=gostls13.git 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 --- 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.