enum and const or immutable ‘variable’ whose value is known at compile time

Cecil Ward cecil at cecilward.com
Thu Sep 17 00:32:40 UTC 2020

On Wednesday, 16 September 2020 at 17:19:13 UTC, Adam D. Ruppe 
> On Wednesday, 16 September 2020 at 17:12:47 UTC, Cecil Ward 
> wrote:
>> then is there any downside to just using enum all the time?
> For a non-string array, enum may give runtime allocations that 
> static immutable won't.
> Generally think of enum as being replaced with the literal 
> representation and array literals actually make a new array.
> This may or may not matter to you.

So can the result of declaring certain things with enum ever have 
an _address_ then? (According to legit D code that is, never mind 
the underlying implementation details, which may not be 

<rant>I actually really hate the way enum was bent out of shape 
and twisted from its original purpose so that finally we end up 
with a way of defining only one value, not the whole range of 
permissible values for a type as in the beginning.

I wish there were just a keyword ‘constant’ or something (yes, I 
know, you could just call that something ‘enum’, or 

More information about the Digitalmars-d-learn mailing list