Can we just have struct inheritence already?

Manu turkeyman at gmail.com
Tue Jun 11 18:19:05 UTC 2019


On Tue, Jun 11, 2019 at 1:00 AM Walter Bright via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> On 6/11/2019 12:06 AM, Manu wrote:
> > On Mon, Jun 10, 2019 at 11:30 PM Walter Bright via Digitalmars-d
> > <digitalmars-d at puremagic.com> wrote:
> >>
> >> On 6/9/2019 10:52 PM, Manu wrote:
> >>> That is indeed the feature that necessitates my 'solution',
> >>
> >> Is it specifically for C++ interop,
> >
> > It occurs frequently in C++ interop, but that's only because most of
> > my code exists in C++.
> > I do, and will continue to use base structs in C++ and in D for
> > exactly the same reasons.
> > Every codebase I have ever worked in uses base struct's to DRY
> > liberally, thousands of engineers think this is fine, and I've never
> > heard anyone think it's unusual, or weird/problematic.
> >
> >> or you just want the zero size?
> >
> > A zero size solution removes the static if hack, but it doesn't remove
> > the alias this hack. I want to remove both hacks.
> > I can't stress enough that struct inheritance exists, it's extremely
> > common, and we will continue to do it as a completely normal practice
> > with no apology.
> > Please don't make our code ugly and unnecessarily difficult to
> > understand for no reason.
> >
> > If you fear misunderstanding with polymorphism, fear not; this is not
> > C++, struct is strictly a value type, there is no vtable, no virtual,
> > no override, etc... there would be compile errors at every turn if
> > anyone ever confused struct inheritance for polymorphism. We have a
> > HUGE advantage here...
>
> Can I ask again, in a different way, why do you need the 0 size?

To handle base structs with no members.


More information about the Digitalmars-d mailing list