More Intuitive Syntax for Manifest (enum) Constants
Dejan Lekic
dejan.lekic at gmail.com
Tue Nov 25 12:20:13 UTC 2025
On Tuesday, 25 November 2025 at 10:54:06 UTC, Jonathan M Davis
wrote:
> And honestly, if I were to create a new version of D with all
> of the various changes that I think would ideally be changed if
> we didn't care about backwards compatibility, I'd probably just
> leave manifest constants the way that they are. It simply isn't
> worth adding a keyword for this concept, and it has the benefit
> that both enum values and manifest constants which are
> designated via enum behave the same way. So, arguably, using a
> different keyword would just fix one perceieved inconsistency
> by adding a new name for what is practically speaking the same
> thing but in a slightly different form.
I thought I would skip this discussion, but I could not resist to
write my suggestion here. We discussed `final int E = 42`,
`manifest E = 42`, and few other options on but I do not remember
that we discussed this:
```d
named E = 42;
named APP_VERSION = "1.0.0";
```
This comes from the fact that manifest constants are "named",
"literal", "symbolic" constants. A good alternative in my opinion
would be `symbol E = 42;`
More information about the Digitalmars-d
mailing list