> I think "[type T]" is slightly clearer than "[T any]".
Code with `[T any]` is much easier to read at least for me. среда, 5 августа 2020 г. в 11:07:59 UTC+3, Jan Mercl: > On Tue, Aug 4, 2020 at 6:07 AM 'Carla Pfaff' via golang-nuts > <golan...@googlegroups.com> wrote: > > > On Tuesday, 4 August 2020 at 00:34:12 UTC+2 ben...@gmail.com wrote: > > > 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}". > > I'm sure some people will never write `any` instead of `interface{}` > and I can prove it ;-) > > > 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. > > It's not the only place. It does not happen often, but interface type > literals other than interface{} appear in real code and for good > reasons. It's an overkill to name a thing that will be referenced by > name only once. > > > 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. > > It's not supposed to be anything special whatsoever. Just like number > zero or an empty set is not some kind of an exception. It's just you > cannot have any reasonable set theory without it. > > BTW: I assume number 42 to be special, though not for math. Can I have > a nice Unicode point for it, so I can write it nicely all over my > example code? > > > Most Go programmers want to be type safe and avoid casting. > > Go programmers do avoid casting because Go has no casting. That word > or its stem doesn't even appear in the language specs. > -- 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/4d2f667c-41d8-4ea7-9817-d08026bc0aa6n%40googlegroups.com.