288 karma · joined Oct 20, 2019 (7y ago) · 30 submissions
comment 4y ago · link · parent
Well, you could if you either ensure, that the layout of the inherited part of a structure is the same for all structures, that inherit the same structure. Or you could return a tagged enum. However, with interfaces or traits, you just have to ensure that the table of interface/trait-methods of different types, that implement the same interface/trait. This table is constant and therefore a reference to it can be shared by every instance of the interface/trait.
Yes, it might be slower, because instead of direct method-calls, you have a layer of indirection, but you only need one copy of the method, not one for every type-combination. If all copies of this method have to fit in the L1-cache simultaneously but cannot, it might actually be faster.
comment 4y ago · link · parent
comment 4y ago · link · parent
comment 4y ago · link · parent
comment 4y ago · link · parent
comment 5y ago · link · parent
16.
Speed of Rust vs. C(kornel.ski ↗)
619 points · by sivizius · 5y ago · 525 comments
comment 5y ago · link · parent
18.
Humans Came from Asgard(en.wikipedia.org ↗)
2 points · by sivizius · 5y ago · 1 comment
comment 5y ago · link · parent
comment 5y ago · link · parent
comment 6y ago · link · parent