Can we just have struct inheritence already?

KnightMare black80 at bk.ru
Sun Jun 9 15:02:29 UTC 2019


On Sunday, 9 June 2019 at 13:59:25 UTC, Jonathan M Davis wrote:
> I've never even seen code use such a pattern before, and 
> honestly, it seems really weird to me to even write code that 
> acts like one struct is derived from another, because without 
> polymorphism, I wouldn't really have thought that that would 
> make any sense.
>
> struct DerivedStruct
> {
>     mixin(aliasAsMember!BaseStruct);
> }
>
such construct says "like-a" for me.
its some difficult workaround of
> struct DerivedStruct : BaseStruct
> {
> }
>
clear and explicitly says "is-a" for me

Point3D is a Point2D plus z, not Point3D like a Point2D with z. 
maybe for u this is same mean.

The point(another mean) lays in human habits, all of us know C++, 
we expecting clear and obvious things. The point is not that 
which is more correct, but that it is more familiar, what is 
expected.
Same for double.init=NaN - maybe its right in some view, but all 
langs that I know initialize globals with zeroes. I expecting 
zeroes. I expecting "using noninitalized variable" when I do 
something d+=.. with such var not the NaN.
When u have a deal with known things u do less errors and typos 
than when u fight with unexpected "right way".


More information about the Digitalmars-d mailing list