go-generics icon indicating copy to clipboard operation
go-generics copied to clipboard

New API for Go 1.23

Open bobg opened this issue 1 year ago • 0 comments

This PR revamps the go-generics API for Go 1.23, which notably adds the "range over func" language feature and the iter.Seq and iter.Seq2 types, plus some associated functions in the slices and maps stdlib packages.

As such there is no longer a need for this module's earlier iter.Of type. Nor can this module's iter package work as a drop-in replacement for the stdlib iter, because Go does not yet support generic type aliases. (The stdlib iter defines the generic Seq and Seq2 types, and a drop-in replacement could work only by creating aliases for those types. Duplicating those type definitions would create new, distinct types that wouldn't work with the rest of the standard library.)

Therefore the iter package is replaced with a new seqs package providing many of the same features, all reimplemented in terms of Go's new iterators.

After adapting to changes in Go 1.23, this module's maps package added even less than it did before, so it has been removed.

bobg avatar Jul 24 '24 17:07 bobg