diff --git a/doc/go_spec.html b/doc/go_spec.html index 8707591f66b..718a724e33e 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,5 +1,5 @@ - +

-Except in a communications clause of a select statement, -sending or receiving from a nil channel causes a +Receiving from a nil channel causes a run-time panic.

@@ -3087,6 +3053,7 @@ need to be presented regarding send, receive, select, and goroutines.

---> +

Method expressions

@@ -3508,7 +3475,7 @@ Statement = FallthroughStmt | Block | IfStmt | SwitchStmt | SelectStmt | ForStmt | DeferStmt . -SimpleStmt = EmptyStmt | ExpressionStmt | IncDecStmt | Assignment | ShortVarDecl . +SimpleStmt = EmptyStmt | ExpressionStmt | SendStmt | IncDecStmt | Assignment | ShortVarDecl . @@ -3543,7 +3510,7 @@ Error: log.Crash("error encountered")

Expression statements

-Function calls, method calls, and channel operations +Function calls, method calls, and receive operations can appear in statement context.

@@ -3553,11 +3520,44 @@ ExpressionStmt = Expression .
-f(x+y)
+h(x+y)
+f.Close()
 <-ch
 
+

Send statements

+ +

+A send statement sends a value on a channel. +The channel expression must be of channel type +and the type of the value must be assignable +to the channel's element type. +

+ +
+SendStmt = Channel "<-" Expression .
+Channel  = Expression .
+
+ +

+Both the channel and the value expression are evaluated before communication +begins. Communication blocks until the send can proceed, at which point the +value is transmitted on the channel. +A send on an unbuffered channel can proceed if a receiver is ready. +A send on a buffered channel can proceed if there is room in the buffer. +

+ +
+ch <- 3
+
+ +

+Sending to a nil channel causes a +run-time panic. +

+ +

IncDec statements

@@ -4076,18 +4076,19 @@ cases all referring to communication operations.

 SelectStmt = "select" "{" { CommClause } "}" .
 CommClause = CommCase ":" { Statement ";" } .
-CommCase = "case" ( SendExpr | RecvExpr) | "default" .
-SendExpr =  Expression "<-" Expression .
-RecvExpr =  [ Expression ( "=" | ":=" ) ] "<-" Expression .
+CommCase   = "case" ( SendStmt | RecvStmt ) | "default" .
+RecvStmt   = [ Expression ( "=" | ":=" ) ] RecvExpr .
+RecvExpr   = Expression .
 

-For all the send and receive expressions in the "select" +RecvExpr must be a receive operation. +For all the cases in the "select" statement, the channel expressions are evaluated in top-to-bottom order, along with -any expressions that appear on the right hand side of send expressions. +any expressions that appear on the right hand side of send statements. A channel may be nil, which is equivalent to that case not being present in the select statement @@ -4398,7 +4399,7 @@ sent values have been received, receive operations will return the zero value for the channel's type without blocking. After at least one such zero value has been