Iterators in Go: A proposed extension

This article discusses a proposed extension to the Go language, called “range over func,” which introduces the concept of iterators. Iterators are functions that yield one result at a time, rather than computing and returning a whole set of results at once. The article explains the benefits of using iterators compared to returning a slice, such as avoiding the need to wait for the entire slice to be generated and allocating unnecessary memory. It also discusses different types of iterators, including two-result iterators and zero-result iterators. The article concludes by mentioning the ability to compose iterators by passing them to functions that return other iterators. Overall, the article highlights the usefulness and flexibility of iterators in Go programming.

https://bitfieldconsulting.com/golang/iterators

To top