6 ms·
I think interface{} is a horrible, horrible hack. For me, the answer is an emphatic yes.
by yuushi 13y ago
I think interface{} is a horrible, horrible hack. For me, the answer is an emphatic yes.
- alok-g 13y agoCould you please explain more? :-)
- yuushi 13y agoSure. Think of void * in C. interface{} in Go isn't really that different, there's just a bit more language support for testing if it satisfies a specific type or not. Add in type assertions, and it's basically as though you had a dynamic_cast in C++ that worked from void * to an interface type. To me, it just seems ugly. I like a type system where I know what a type is at each point, and there isn't some ugly "catch all" type that you can use when you run out of other options, which effectively just throws away all type information (and this is what interface{} does, as everything implements it).
- Roboprog 13y ago"Object" is much better :-) (or perhaps you prefer "void *")