4 ms·
If you're referring to map[K]V, that's not true. Go doesn't have generics, it uses some compiler magic under the hood specifically for the map type [0]. The gen
by ibraheemdev 5y ago
If you're referring to map[K]V, that's not true. Go doesn't have generics, it uses some compiler magic under the hood specifically for the map type [0]. The generics proposal is being implemented from the ground up.
[0]: https://dave.cheney.net/2018/05/29/how-the-go-runtime-implements-maps-efficiently-without-generics https://dave.cheney.net/2018/05/29/how-the-go-runtime-implem...
- masklinn 5y ago> If you're referring to map[K]V, that's not true. Go doesn't have generics, it uses some compiler magic under the hood specifically for the map type [0]. They're not generic (aka userland) generics, but they're still generics: parametric types, and functions able to work on them generically (you don't have a separate `append` function for every type you might put in a slice). > The generics proposal is being implemented from the ground up. Of course it is, the builtins are ad-hoc and half-assed. That doesn't mean they ain't a thing.
- sagichmal 5y ago> the builtins are ad-hoc and half-assed In what way are slices and maps half-assed?
- amw-zero 5y agoI’m sure they mean that because they are not applicable to the rest of the language. It’s like, the Go creators recognized the situation where generics were necessary, but only used it for slices and maps. I really don’t think they were saying that slices and maps themselves are bad. They function perfectly. I’m sure they meant that it’s just silly to confine quasi-generics to those 2 places.
- sagichmal 5y ago> it’s just silly to confine quasi-generics to those 2 places Why is it silly?