News for hackers. Stuff that matters.
Re:Iterators are (maybe) coming to Go by znkr on Saturday August 12, 2023 @03:11AM (#37097816)
Re:Iterators are (maybe) coming to Go by anonymoushn on Saturday August 12, 2023 @05:07AM (#37098368)
This does not contain anything about the proposed implementation of Pull, of course.
Re:Iterators are (maybe) coming to Go by Groxx on Saturday August 12, 2023 @04:32PM (#37103983)
Wouldn't this be the implementation?

    func Pull[V any](push func(yield func(V) bool)) (pull func() (V, bool), stop func()) {
        ... // snipped because it's big
    }
Re:Iterators are (maybe) coming to Go by anonymoushn on Saturday August 12, 2023 @11:43PM (#37106481)
That is an implementation in terms of primitives that are not in the proposal.
Re:Iterators are (maybe) coming to Go by Groxx on Sunday August 13, 2023 @11:57AM (#37111103)
I don't believe so - the post is pretty much all about how you can do this right now in normal Go code. And e.g. a bit after that is a link to the "full code" which is runnable: https://go.dev/play/p/hniFxnbXTgH

Possibly you're interpreting yield as a new keyword? It's just an argument to Pull.

The only not-(currently-)available-in-Go stuff that I can recall from the post is the performance optimization at the very end.

Re:Iterators are (maybe) coming to Go by anonymoushn on Sunday August 13, 2023 @12:44PM (#37111578)
You can read the proposal here: https://github.com/golang/go/issues/61405. It is linked in the first paragraph of TFA.

Yes, I know you can build a 100x-too-slow version of this on top of channels, but that's not the proposed extension to the language.