1 - The case clause clearly represents a send action.
2 - So there must be a channel to send to, and f1() must return a channel.
3 - If that channel (returned by f1()) is nil, then the clause must get 
ignored.
4 - If the returned channel (returned by f1()) is not nil, then f2() will 
be executed.
5 - The returned value of f2() will be sent to channel returned by f1()

Any unexpected side effects caused by either f1() or f2() are not relevant 
in the context of the above workflow.

And since Go has not any specific semantics regarding side effects (like 
Haskell or Elixir), the problem of side effects has no place inside the 
context of Go semantics. Go is an imperative programming language, like 
many other mainstream programming languages.

On Tuesday, January 23, 2018 at 7:21:24 PM UTC+3:30, Jan Mercl wrote:
>
> On Tue, Jan 23, 2018 at 4:45 PM dc0d <kaveh.sh...@gmail.com <javascript:>> 
> wrote:
>
> > In the sample you have provided, a send syntax is used. And considering 
> that, (IMHO) f1() must be evaluated first.
>
> Consider f1() is a dispatcher. If it is to be evaluated first then it may 
> create and return a new channel that will not be used. Or consider if f1() 
> has a side effect of incrementing some send counter.
>
> I don't think asking a function to return a channel to send a value to, 
> while possibly later figuring out there's nothing available to send, is a 
> good idea.
>
>
>
> -- 
>
> -j
>

-- 
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