On Wed, Jun 17, 2020 at 4:19 AM Hal <hwang....@gmail.com> wrote:
>
> "If a constraint is specified for any type parameter, every type parameter 
> must have a constraint. If some type parameters need a constraint and some do 
> not, those that do not should have a constraint of interface{}."
>
> "interface{}" equals to "Any Type" in the context of generics. So it seems 
> that we don't have to support optional constraint, for the following reasons:
>
> * the syntax defining generic function is verbose on purpose (type keyword), 
> not only for clarification, but also a remind of the cost and complexity 
> behind generics, so it is not a bad thing to be explicit about the the 
> default constraint interface{}
> * normal parameter list does not support default type, to be consistent, type 
> parameter list should not either
> * multiple generic types without constraints can be written as "type T1, T2, 
> T3 interface{}", not too much boilerplate anyway

Our limited experience suggests that by far the common case is that
type parameters have no constraints.  It seems annoying to force
everyone to write interface{} all the time when it is normally not
needed.

Ian

-- 
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/CAOyqgcXHPrzSAzfEqR%2BgoAdBAM%2Bi2%3Dg5oiJJ0BpxOFzv_b0_uA%40mail.gmail.com.

Reply via email to