On Friday, 5 May 2017 13:26:33 UTC+8, Ronald wrote: > > Wouldn't it better to just keep the nil channels out of the cases in the > select > statement at the very beginning like epoll_wait does? > (I think the select statement in golang is very similar to the epoll_wait > at sys/epoll.h.) > > Or this is a compromise to let the programmer do anything they want? > > And protect them :-)
> > > On Friday, 5 May 2017 12:54:18 UTC+8, Jesse McNelis wrote: >> >> On Fri, May 5, 2017 at 1:35 PM, Ronald <yunth...@gmail.com> wrote: >> > >> > So the question: >> > >> > Isn't it better just to throw a panic when user send/recv on a nil >> > channel instead of forever blocking it? If not, what is the benefits? >> >> There is value in the ability to have a select case be a nil channel. >> In a select a nil channel is never ready to receive and thus isn't a >> case that will proceed. >> This is useful for allowing you to conditionally prevent certain cases >> from proceeding by swapping out the channel for a nil. >> >> While outside a select this behaviour isn't really useful, but for >> consistency it works exactly the same. >> > -- 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.