9 ms·
> embedding [..] never feel quite right. funnily enough, I would argue that struct embedding is one of the things that Go actually got right. It's simple and e
by dist1ll 3y ago
> embedding [..] never feel quite right.
funnily enough, I would argue that struct embedding is one of the things that Go actually got right. It's simple and elegant, and I think it could've been a useful addition to Rust.
- klabb3 3y agoYeah to be fair I don’t think I even have a problem with embedding per se. It’s quite nice. It’s more the fact that embedding can be used to work around missing type system features. I can’t recall exactly, but I remember using embedding for things that it probably wasn’t designed for, because it would save me a ton of boilerplate.
- dontlaugh 3y agoAlmost every single case of embedding I've encountered was buggy in some way. Explicit composition is much more reliable.
- lamontcg 3y agoIf someone autogenerates one way or another all the delgation, then that's just as buggy as embedding. The presence of all the explicit composition in the codebase doesn't mean that anyone actually sat down and thought about it all.
- dontlaugh 3y agoAutogenerating delegation is bad for the same reason. Having to explicitly delegate in every single case forces you to think about it. Alternatively, it forces you to use the type system to make a better abstraction.
- lamontcg 3y ago> forces you to think about it forcing people to type something never forces them to think about it.