>> That is an experiment. We don't seem to need the type keyword for 
>> generic functions. But we do need it for generic types, 

I'm used for years to look at code with generics in Java. The additional 
type keyword as proposed for generics in Go in IMHO make reading the 
declaration containing generics much easier and much less effortful for the 
eye. You see the type keyword in some declaration and in one short look you 
have understood what it says without having to stare at it for a while.

Carla Pfaff schrieb am Dienstag, 4. August 2020 um 06:08:19 UTC+2:

> On Tuesday, 4 August 2020 at 00:34:12 UTC+2 ben...@gmail.com wrote:
>
>> Which at first seems like a good idea, but then unless "any" is built in 
>> or this becomes a well-known idiom, it won't be as self-documenting. Other 
>> people will have to look up the definition to see "oh, I see, this is just 
>> short-hand for an empty constraint".
>
>
> I'm sure it would quickly become a well-known idiom, just like people know 
> that "error" is "interface{Error() string}" or "fmt.Stringer" is 
> "interface{String() string}".
>
> Actually the current use of "interface{}" is a bit odd because it is the 
> only case where an interface is commonly used as an anonymous type rather 
> than by an identifier.
>
> I assume that in current Go the empty interface is supposed to be an ugly 
> duckling to discourage its overuse, but in a world with type parameters it 
> will play an important role as the unbounded constraint and it should 
> deserve its own identifier.
>
> And I don't think that giving it a short name would encourage more use of 
> the empty interface as a type for regular function parameters, because my 
> estimate is that people are happy to use "generics" rather than the empty 
> interface in function parameters when they can. Most Go programmers want to 
> be type safe and avoid casting.
>
>

-- 
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/c8093cd4-97fe-4ffe-a93e-9bdbccf92152n%40googlegroups.com.

Reply via email to