4 ms·
That blew my mind for a bit too. It's not lazy in the sense of postponing evaluation, it just blocks until something reads or writes from the channel. This coul
by vito 17y ago
That blew my mind for a bit too. It's not lazy in the sense of postponing evaluation, it just blocks until something reads or writes from the channel. This could go on forever assuming you have something that reads from the channel in an infinite loop (as it looks like it's doing in main(), actually...), but the generators themselves only loop when the channel is interacted with.
- lt 17y agoIt does make more sense after understanding that. There's still the ever-increasing number of concurrent goroutines, but what just helped me accept that a bit is the fact is that each goroutine does not necessarily map to one thread (it actually does in one of their compilers - there's two - but that's an implementation detail).