More Intuitive Syntax for Manifest (enum) Constants

Jonathan M Davis newsgroup.d at jmdavisprog.com
Tue Nov 25 10:54:06 UTC 2025


On Sunday, November 23, 2025 12:15:27 AM Mountain Standard Time Walter Bright via Digitalmars-d wrote:
> The `enum E = 24;` syntax looked a bit odd at first, but seems perfectly natural
> to me now.

Also, the enumerated values in an enum type are effectively manifest
constants. So, while using enum for manifest constants might seem odd a
first, it's actually quite logically consistent.

IMHO, in practice, this is a total non-issue. It's confusing for some folks
who are new to the language, but they typically get over it pretty quickly.
That leaves the folks who dislike it based on the principle that enum is
short for enumeration, and there's only one value, not an enumerated set of
values, but I think that the folks who stay hung up on that are in the
minority. Some folks who don't complain about it probably would still pick a
different keyword if they had the choice, but it just isn't a big enough
deal for most folks to complain about it once they get used to it.

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.

- Jonathan M Davis






More information about the Digitalmars-d mailing list