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!

Reindert Vetter

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/AM8PR07MB74121F954468DEAFCFE6F594CBFF0%40AM8PR07MB7412.eurprd07.prod.outlook.com.

Reply via email to