For constraints they also could be after type name:

func IndexOf(slice []type T comparable, find T) int
or maybe this is clearer:
func IndexOf(slice []type comparable T, find T) int

This generic type information could be added on leftmost first use of the 
type in the parameter list or return, and only the type name (i.e T) used 
if more than once as above.
Multiple type parameters should be just doing this for each parameter:

func IndexOf(slice []type T, find T, range type R) int

types used only in the function but not as a parameter could have an 
underscore _ as their parameter name, not great, but workable for an edgy 
case perhaps.


It might have too many problems, but funny how introducing the "type" 
keyword opens up new possibilities!


On Wednesday, 22 July 2020 00:59:18 UTC+2, Ian Lance Taylor wrote:
>
> A few quick notes. 
>
> As you mention, how do constraints work? 
>
> If there are multiple type parameters, I think it's not immediately 
> obvious how the type arguments should be passed. 
>
> What about functions that use a type parameter that is not used by any 
> of the non-type parameters?  That's uncommon but it seems like it 
> could happen. 
>
> 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/0d9fd0f4-6531-433b-afe9-744c260b83b6o%40googlegroups.com.

Reply via email to