The Why of Iterator Design
summary
Go 1.23 adds user-defined iteration that integrates with range by accepting functions not interfaces, not by adding a new iterator method. The standard iter package exposes seek/seek2 (push-style generators) and helper pull/pull2, with generator functions receiving a yield(value) bool callback; the optional bool was dropped and compiler rewrites yield in place. Compatibility and stop/cleanup concerns drive the choice, and the design is implemented in the compiler and standard library.
AI-written summary · about
chapters (8)
- 0:00Introduction and context
- 2:50Why this talk exists
- 4:34History of iteration in Go
- 9:51Original iterator proposal
- 17:12Problems with the proposal
- 21:06Revised design and changes
- 25:21Final language changes
- 28:00Conclusion and summary
related talks
53mIterators in Go 1.23: how to use them and how fast are they?
53mIterators in Go 1.23: how to use them and how fast are they?
21mThe Loop War: Iterators vs. Traditional Loop
01h 00mBuilding and Extending the Iterator Hierarchy in a Modern, Multicore World
01h 03mIteration Revisited: A Safer Iteration Model for C++
58mYield at Me, 'Cause I'm Awaiting: Asynchronous Iterators in C# 8
46mMeandering Through C++ Creating ranges::to
01h 14mReintroduction to Generic Programming for C++ Engineers
