On Friday, 21 August 2020 at 16:46:22 UTC+2 bbse...@gmail.com wrote: > All constraints except "any" specify a constraint for the type. A > Stringer constraint will ensure that the type has String() string > method. "any" is a lack of constraint.
The empty interface / any is a constraint that ensures that the type has at least 0 methods and all of these 0 methods must match the 0 methods of the interface. An empty purse is still a purse, an empty constraint is still a constraint. > My problem is the attractiveness of "any" as a return type. > I don't see why anybody would find it attractive as a return type. People don't use the empty interface because they like it so much, but because Go doesn't have parametric polymorphism / "generics" yet. There are many programming languages that have a named top type and it is rarely abused. Programmers want to write type safe code if they can. -- 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/8e5b46ba-7a3e-4d55-ac97-1e70d06e622dn%40googlegroups.com.