News for hackers. Stuff that matters.
Re:Iterators are (maybe) coming to Go by Groxx on Saturday August 12, 2023 @03:34AM (#37097945)
I suspect getting a single item out will be that you just make a

  func next[T](i iterfunc[T]) T {
    var item T
    i(func(it T) bool){
      item = it
      return true // likely
    })
    return item
  }
and use it. Semantics should be the same as ranging would desugar to (since that's all this is), though the variable arity will be slightly annoying of course.
Re:Iterators are (maybe) coming to Go by anonymoushn on Saturday August 12, 2023 @05:08AM (#37098377)
Sure, and that should be somewhere in the very long posts about this or in the very long github issue.
Re:Iterators are (maybe) coming to Go by assbuttbuttass on Saturday August 12, 2023 @10:14AM (#37100412)
I don't think it's so easy. An iterfunc doesn't store any state explicitly, so each time you call i it restarts from the beginning
Re:Iterators are (maybe) coming to Go by Groxx on Saturday August 12, 2023 @02:54PM (#37103126)
Aah, yes, that's an excellent point. Thanks! That does complicate things a lot more.

Quite a lot more, as it essentially means you can only consume from iterators you create... which sorta defeats the purpose of iterators as a value, and degrades them almost completely to just a `range` helper.