Can we just have struct inheritence already?

Manu turkeyman at gmail.com
Mon Jun 10 22:56:50 UTC 2019


On Mon, Jun 10, 2019 at 2:55 AM Walter Bright via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
>
> On 6/9/2019 3:03 PM, Manu wrote:
> > I can form a misuse fail for practically any language feature.
> > It's possible we identify some common-sense restrictions here to
> > inhibit the worst of them, but the current restriction is
> > anti-productive, the line in the sand is drawn incorrectly.
>
> Everyone, and I mean everyone, who misuses a feature is thoroughly convinced
> their use is productive. For an ancient example:
>
>      #define BEGIN {
>      #define END }
>
> Yep. That. :-) And it's not remotely the worst abuse of the preprocessor I've
> seen, all of which are stoutly defended.

That's absolutely nothing like using struct inheritance to *do struct
inheritance*.
Using `alias this` to do struct inheritance is a much closer analogy
to your example above; ie, using a feature to do something that people
may not expect and/or could be expressed a whole lot more cleanly or
directly.

> > For contrast, I've been arguing on bug reports recently that people
> > think interactions with uninitialised unions (or =void initialised
> > code) is @safe... 🤯🤯🤯
> > which just shows how astonishingly arbitrary this shit is.
>
> Uninitialized non-pointers are @safe, because @safe refers to memory safety, not
> "no bugs". Perhaps I was wrong to define it that way, but it is deliberate, and
> not arbitrary.

Uninitialised data, which is guaranteed to have no valid state, and
has absolutely no chance of proper program execution under any
circumstance, and may even be leaking internal/private state(!), is
not safe. You can't convince me otherwise.

It is arbitrary. Almost everything comes down to "I like this", or "I
don't like this", and the noise in the middle is mostly a waste of our
time.
Occasionally argument improves outcomes, but for the most part, we're
all just wasting time here.

I'm 100% certain that it's crazy to allow accessing uninitialised
memory freely without any compiler intervention in allegedly @safe
code. Program error is practically guaranteed, and you have absolutely
no idea how that error may manifest (it might even violate memory
safety). But there's nothing I can do to convince you of that.
Meanwhile, you'll suggest I'm crazy for wanting to use struct
inheritance to do struct inheritance rather than ugly hacks to emulate
it...

If this isn't all just completely arbitrary, I don't know what is.
...but let's not get off topic ;)



More information about the Digitalmars-d mailing list