Why are multiple instances of the single enum created?

Per Nordlöw per.nordlow at gmail.com
Mon Feb 1 11:37:49 UTC 2021


On Monday, 1 February 2021 at 10:24:59 UTC, Mike Parker wrote:
> There is no "extra" instance because there's no single instance 
> of an enum value. They have no address. When you use one, it's 
> just as if you were writing the literal instead of the enum 
> name. In other words:
>
> enum ea = [1, 2, 3];
> auto a0 = ea;
> auto a1 = ea;
>
> is identical to this:
>
> auto a0 = [1, 2, 3];
> auto a1 = [1, 2, 3];

Ok, so then my follow-up question becomes, does the right hand 
sides of these two assignment share the same AST node? If not, 
why?


More information about the Digitalmars-d-learn mailing list