5 ms·
> Go and Rust wisely leave out inheritance for code sharing in their object model Bad news buddy: https://gobyexample.com/struct-embedding https://gobyexample
by 38 3y ago
> Go and Rust wisely leave out inheritance for code sharing in their object model
Bad news buddy:
https://gobyexample.com/struct-embedding https://gobyexample.com/struct-embedding
At first I loved it, then quickly realized as you did that it makes code essentially unreadable.
- masklinn 3y agoThat is very much not inheritance. It’s literally just sugar for delegation: calls which delegate to embedded structs execute in the embedded struct’s context. And the embedded struct has to be part of the struct definition, it can’t be snuck in by reopening the class and include-ing new bits.