In the sample you have provided, a send syntax is used. And considering 
that, (IMHO) f1() must be evaluated first.

On Tuesday, January 23, 2018 at 6:13:08 PM UTC+3:30, Ian Lance Taylor wrote:
>
> On Tue, Jan 23, 2018 at 5:44 AM, dc0d <kaveh.sh...@gmail.com <javascript:>> 
> 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...@googlegroups.com <javascript:>. 
> > 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.

Reply via email to