Re:Go generics are not bad
by hgomersall on Saturday July 09, 2022 @02:07AM
(#32032315)
They're not viral in rust - you can always replace the generic with a concrete type in super types.
[ Parent
| on HN ]
Well that's rather the point of being generic with any language, isn't it?
You can stop being generic when you have sufficient information to stop being generic. If you're writing a library, that can easily bubble up all the way to the top, because you may never have enough information.
ETA: I think I was using a definition of viral that wasn't entirely correct. I thought it was a casual term rather than a precise one. But it seems like you're saying something is viral if you _must_ pass it on. In which case I apologize, generics are "semiviral" (I'm trying to introduce this term - if it already exists & isn't this, I apologize) - you don't need to pass them on, there's just a tendency to. The result looks very similar.
Re:Go generics are not bad
by orthoxerox on Saturday July 09, 2022 @06:06AM
(#32033537)
Rust also has associated types, which are exposed to the implementer, but not to the consumer.