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/a4d6050c-5e44-4849-a682-80a808d12417n%40googlegroups.com.