Good evening,
First of all, thank you for everything you do with Go!
I've had an idea for generic for Go for some time. If it makes no sense, please ignore my email.
The idea is to join the different types through a pipe. This means you do not have to introduce a 'type' in the interface. It is also much easier to convert ordinary types to a generic type.
Some examples:
type typeFloat float64
type typeInt int
type stringAble typeFloat|typeInt
func ConvertToString(input stringAble) string {
//
}
type stringAble float64|int
func ConvertToString[type T stringAble](input []T) string {
//
}
With interfaces:
type stringAble typeFloat|typeInt|error|stringer
func ConvertToString(input stringAble) string {
//
}
They may not be generics, but you could also allow the following:
func ConvertToString(input float64|int) string {
//
}
type typeFloat float64
type typeInt int
func ConvertToString(input typeFloat|typeInt) string {
//
}
What do you think of this idea?
Thanks in advance!