structure inheritance and polymorphism
sighoya
sighoya at gmail.com
Thu Jan 7 11:24:14 UTC 2021
On Monday, 4 January 2021 at 01:06:20 UTC, zjh wrote:
>But I want d to have c++ structure
> inheritance and polymorphism. In this way, I think the
> competition with c++, the odds are better.
Structs as polymorphic structures are bad because structs
shouldn't be polymorphic, otherwise they have to store a vtable
somewhere.
If you don't like classes, what about interfaces? The only
problem is that they don't support fields which I find myself a
bit pitty.
You can however simulate it with getters and setters, at least to
some kind.
With https://dlang.org/phobos/std_experimental_typecons.html you
can box a struct to an interface or a class.
I don't know how stable it is yet, but I find it pretty
interesting.
More information about the Digitalmars-d
mailing list