I like the idea of generics, and having played around with them it 
definitely feels worth bringing into Golang. But, I agree with the author 
of this post and I don't think constraints on generics is needed.

I do understand the arguments that:
1. There's no implicit conversion between a value type and an interface, 
and constraints would make this possible, but i feel that it's at the 
expense of making the language unnecessarily complicated. Can we not just 
think through our design of our applications to either prevent this need or 
ensure that we build a slice of interfaces?
2. Being able to constrain on comparable values (using <,>,==,!=). Couldn't 
we create an interface which declares what we need (LessThan, MoreThan, 
etc)? I feel that if the language goes down this path, why not do the whole 
shebang and have operator overloading in go?

I've yet to really feel the need for either of these (although i'm not a 
veteran golang dev -- only 1 year with golang in a professional 
environment), but I have come across scenarios where generics would 
otherwise be useful... (and function overloading, but that's a whole 
different kettle of fish)

It's great that we've been given the chance to give some feedback :)

On Wednesday, June 17, 2020 at 9:19:49 AM UTC+1 christoph...@gmail.com 
wrote:

> Reading the document "Type parameters - Draft desing" of June 16, 2020 (
> https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md),
>  
> I wonder if these two following function definitions are not equivalent and 
> thus interchangeable
>
> func Stringify(type T Stringer)(s []T) (ret []string)
>
> func Stringify(s []Stringer) (ret []string)
>
> If the constrain is an interface, wouldn’t it be the same as to use the 
> interface as type ? How would it be different ? 
>
>

-- 
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/7af5d81d-d306-44b1-841e-970e8f35f84an%40googlegroups.com.

Reply via email to