What would break if class was merged with struct

Iain Buclaw via Digitalmars-d digitalmars-d at puremagic.com
Sun May 28 01:24:50 PDT 2017


On 27 May 2017 at 16:12, Ola Fosheim Grøstad via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> I wonder, what would break if all the features of class was merged into
> struct?
>
> Imagine that:
>
>     class Something ... { ... }
>
> is lowered into:
>
>     struct _class_Something ... { ... }
>     alias Something = MagicClassRef!_class_Something;
>
> Is it conceivable with some language changes, a bit of automated source
> updating and a little bit of breakage?
>

Strictly speaking, this already is the case.

    Something sth = new Something (...);

all that is really doing is just:

    struct Something* sth = new Something (...);

You just aren't exposed this in the language.



More information about the Digitalmars-d mailing list