3 ms·
According to this usage, C has generic functions because you can, e.g., index into an array of ints. The whole point of generics is that the language makes avai
by foldr 7y ago
According to this usage, C has generic functions because you can, e.g., index into an array of ints. The whole point of generics is that the language makes available some form of abstraction over types. Go does not have this feature. It has some built-in operators that can operate on multiple types. Most languages have this. The arithmetic operators in C, for example, can take operands of many different types. This is not "generics".
>Because the core Go team assumes and asserts users of Go should not and can not be trusted with anything more complex than a wooden cube with rounded edges large enough that it can't fit in their mouths.
This can't really be the right explanation given that generics are now being added to the language. In any case, this kind of mean-spirited speculation about people's motives is borderline trolling, IMO. The Go team have publicly stated their reasons for not (initially) putting generics in the language. Unless you have some inside info suggesting that they're lying, I'd refrain from saying this kind of thing.
- masklinn 7y ago> The whole point of generics is that the language makes available some form of abstraction over types. Go does not have this feature. Go absolutely has this feature. Just not for you as a user of the language. > It has some built-in operators that can operate on multiple types. Go has multiple builtin functions which abstract over type parameters e.g. close() can operate on any chan, append() or copy() can operate on any slice. They are not operators (symbolic or keyword). > Most languages have this. The arithmetic operators in C, for example, can take operands of many different types. This is not "generics". It's overloading, +(int, int) and +(double, double) are separate functions under the same symbol. It's an orthogonal feature, so much so that there are plenty of languages which do have userland generics and don't have overloading. > This can't really be the right explanation given that generics are now being added to the language. The core team has been saying they're considering the feature / issue pretty much since the language was first released. You'll have to excuse me if I don't hold my breath.
- foldr 7y ago>Go absolutely has this feature. Just not for you as a user of the language. That seems like a roundabout way of saying that it doesn't have the feature. >It's overloading You could just as well regard Go's close, append, copy etc. as overloaded. > The core team has been saying they're considering the feature / issue pretty much since the language was first released. You'll have to excuse me if I don't hold my breath. They've come out with a specific generics proposal. I'm not sure why you would think that they're not serious about implementing it.