Glad to hear that generics are very likely on the way from someone on the Go team.
The impression I got was that generics were not likely to be added without a lot of community push in terms of “Experience Reports”, as mentioned in that article.
Wouldn’t generic types change Go’s error handling too? I mean that when you can build a function that returns a Result<Something, Error> type, won’t you use that instead of returning Go1 “tuples” ?
For Result type, you either need boxing, or sum type (or union, with which you can emulate sum type), or paying memory cost of both value and error. It’s not automatic with generics.
As I understand it Go has multiple return values and does not have a tuple type, so not sure how your example would work. There are some tickets open looking at improving the error handling though.
I am glad to see they are considering generics for Go2.
Russ has more background on this from his Gophercon talk: https://blog.golang.org/toward-go2
The TL;DR for generics is that Go 2 is either going to have generics or is going to make a strong case for why it doesn’t.
As it should be…
Glad to hear that generics are very likely on the way from someone on the Go team.
The impression I got was that generics were not likely to be added without a lot of community push in terms of “Experience Reports”, as mentioned in that article.
They got those :)
Wouldn’t generic types change Go’s error handling too? I mean that when you can build a function that returns a
Result<Something, Error>type, won’t you use that instead of returning Go1 “tuples” ?For Result type, you either need boxing, or sum type (or union, with which you can emulate sum type), or paying memory cost of both value and error. It’s not automatic with generics.
I see, thanks for clarifying! :)
As I understand it Go has multiple return values and does not have a tuple type, so not sure how your example would work. There are some tickets open looking at improving the error handling though.
For me versioned std lib is the most powerful change in Go. Will be happy to see this in a few years.