On Tue, Jan 23, 2018 at 5:44 AM, dc0d <kaveh.shahbaz...@gmail.com> wrote: > > Can anybody help me understand the reason? (It's in the spec. That's not the > reason)
It gives a precise order of evaluation of the select statement. Consider case f1() <- f2(): It's useful to specify the order in which f1 and f2 are evaluated. The spec says that f2 is evaluated first. If we don't evaluate f2 for nil cases, then we would have to evaluate f1 first. Either choice could work. The spec makes a specific choice. I happen to think it is the least confusing choice, but I can understand if others disagree. Ian > On Sunday, December 31, 2017 at 10:14:31 AM UTC+3:30, dc0d wrote: >> >> Assume there is this select statement: >> >> for { >> select { >> // ... >> // ... >> >> case rcvd <- first(): >> } >> } >> >> >> The rcvd channel will be set to nil or a chan value, by it's own case or >> other cases. >> >> If the rcvd channel is nil, that case should have no effect. But even when >> rcvd channel is nil, the first() function will be called. >> >> I did not expect that. Why is that so? > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.