Why are multiple instances of the single enum created?

Q. Schroll qs.il.paperinik at gmail.com
Mon Feb 1 20:11:13 UTC 2021


On Monday, 1 February 2021 at 11:39:26 UTC, Per Nordlöw wrote:
> On Monday, 1 February 2021 at 11:37:49 UTC, Per Nordlöw wrote:
>> 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?
>
> Because such a shared AST node could be potentially mutated in 
> different ways in different contexts during its passes?

The spec says nothing about AST nodes. You can ask what DMD does 
(I don't know), but technically speaking, ASTs are an 
implementation detail of a compiler. A compiler need not have 
ASTs at all to follow the spec (unless the spec demands ASTs to 
exist, which I think it does not do). A compiler can change its 
AST nodes to a different yet equivalent representation without 
issue (unless the spec demands ASTs to exist and be of a certain 
form, which I think it does not do).


More information about the Digitalmars-d-learn mailing list