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

Cecil Ward cecil at cecilward.com
Wed Sep 16 17:12:47 UTC 2020

A really stupid question, I fear.

If I have some kind of declaration of some ‘variable’ whose value 
is strictly known at compile time and I do one of the following 
(rough syntax)

    enum foo = bar;
    const foo = bar;
    immutable foo = bar;

then is there any downside to just using enum all the time?

- I don’t need to take the address of foo, in fact want to 
discourage &foo, (as I said, given that I can do so)

Is there any upside either to using enum?

I’m a bit nervous about using immutable having had bad allergic 
reactions when passing immutable ‘variables’ to functions and so 
just tend to use const or enum.

More information about the Digitalmars-d-learn mailing list