3 ms·
with generics you wind up with two parameter lists, and type parameters have metatypes. All type parameters need to have a metatype, and the metatype `any` come
by zemo 5y ago
with generics you wind up with two parameter lists, and type parameters have metatypes. All type parameters need to have a metatype, and the metatype `any` comes up a lot. Once you start using generics you'll start to feel the pain of writing `interface{}` in those signatures, especially when you are dealing with functions like this one:
func doSomething[X interface{}, Y Fooer[interface{}]](v X, src Y) error {
}
versus:
func doSomething[X any, Y Fooer[any]](v X, src Y) error {
}
the signatures can get long pretty quickly when you have more than one type parameter.
- pishpash 5y agoDoes a personal (not language-wide) type any = interface{} not work, if you felt that strongly?
- pawelmurias 5y agoThat's an extra line of boilerplate. If someone for some reason wants uglier and longer code then can still use interface{}