5 ms·
>> "there's only one way to do it" What's the one way to do iterators now? I thought this proposal came about because there wasn't a default way and everybody
by cy_hauser 3y ago
>> "there's only one way to do it"
What's the one way to do iterators now? I thought this proposal came about because there wasn't a default way and everybody had to roll their own.
- ilyt 3y agoyou can just return channel. range works over channels. Close channel once you're done with iterator. Technically there is side effect of that (iterator done like that would always produce extra value before exiting) but you could probably work around it without much boilerplate
- masklinn 3y agoChannels introduce a ton of overhead (https://syslog.ravelin.com/so-just-how-fast-are-channels-anyway-4c156a407e45?gi=6bf63d1d1bfc https://syslog.ravelin.com/so-just-how-fast-are-channels-any...), plus concurrency issues, and termination concerns (they are essentially a resource leak). It's nice that you can iterate channels, but they're a terrible iteration protocol.