[Prev]
[Next]
[Limbo Basics] [Limbo Programming] [Language Definition]
Channel Operator
After a channel is declared and initialized, it can send and receive data of the type specified in its declaration. Using the channel operator, <-
, a channel sends or receives data, depending on which side of the operator the channel identifier is on.
Send Operator
As a postfix operator (channel identifier on the left), the channel operator acts as a send operator. It transmits the result of the expression supplied as its right operand on the channel specified as its left operand. For example:
c <-= 4; # send int on 'c'
Receive Operator
As a prefix operator (channel identifier on the right), the channel operator acts as a receive operator. The channel receives the data supplied as the operand. The received value may then be manipulated by other operators. For example, it can be assigned to a variable or used as an operand in an expression:
i := <-c; # assign value received on c to i
func(<-c); # pass value received on c to func
[Prev]
[Next]
[Limbo Basics] [Limbo Programming] [Language Definition]
Copyright © 1998, Lucent Technologies, Inc. All rights
reserved.