For one, Go did not have generic types or functions, which really limits the usefulness (and abilities to write) custom iterators in Go. Now we do have iterators, but it turns out there still are a lot of subtle Go-specific issues with how to support custom iterator types, which to be honest are too complicated to explain in an E-Mail. You can skim these discussions, to get an impression: https://github.com/golang/go/discussions/54245 (discussion, probably the first serious attempt) https://github.com/golang/go/discussions/56413 (discussion, follows from the previous one with a significantly simpler approach) https://github.com/golang/go/issues/61405 (proposal, from 3 weeks ago, currently actively discussed) If you decide to participate, I strongly recommend reading both the top-post (with the actual proposal) and the first comment (with an extensive summary of the discussion and FAQ).
It's complicated. On Sun, Aug 6, 2023 at 10:05 AM Serge Hulne <serge.hu...@gmail.com> wrote: > Why does Go (so far) not have support for generators/ iterators for custom > types ? > > I wrote this workaround: > https://github.com/serge-hulne/go_iter > > But I was wondering what lead to the idea of leaving iterators out in the > early days of the design of Go. What simplification of the language was > expected from leaving out iterators for custom types. > > > -- > 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. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/1fd9e5e8-8196-4bfb-910c-89ed461c42c5n%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/1fd9e5e8-8196-4bfb-910c-89ed461c42c5n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAEkBMfFsjtfqeu9oJ8gUANvn%2BE-Hb2vyMmnQNV7fY6Sv800-cg%40mail.gmail.com.