On Tue, Jul 21, 2020 at 3:37 PM Tor Langballe <torlangba...@gmail.com> wrote:
>
> This might have been discussed, but can't find anything about so easy, joined 
> late...
>
> Could generic function definitions be done all in one paramter list using the 
> type keyword?
>
> func IndexOf(slice []type T, find type T) int
>
> or
> func IndexOf(slice []type T, find T) int
>
>
>
> instead of
>
> func IndexOf[type T](slice []T, find T) int
>
>
>
> Function calling / instatiating would probably still have a type declaration 
> part in [ ] or whatever ends up being used.
>
> It could get messy with contracts / required interfaces, and might not be 
> parsable, but might be nice not to repeat types if they are longer names.

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/CAOyqgcXz1shvDQ93nhbR2v0SVnv04SXrB_skTHx7Z_e3dr_aDg%40mail.gmail.com.

Reply via email to