More Intuitive Syntax for Manifest (enum) Constants
Walter Bright
newshound2 at digitalmars.com
Sat Nov 22 08:59:59 UTC 2025
Allow me to point out `static` in C and C++! and its many porpoises!! D takes
some of that, too. But at least D has `private` instead of `static`.
I agree `enum` for this seems a bit awkward at first, but it smooths out
naturally pretty quickly. After all, just think of it as an "enumerated
constant" with only one value, so why bother with the { }.
An enum manifest constant has some subtle differences with `const`:
1. it does not allocate storage
2. it cannot be a pointer
As for `final`, it seems the perfect keyword for it. What semantic integrity is
it losing? Currently, applying `final` to a variable declaration gives an error.
I have difficulty seeing `macro` being better.
More information about the Digitalmars-d
mailing list