More Intuitive Syntax for Manifest (enum) Constants
Walter Bright
newshound2 at digitalmars.com
Sun Nov 23 07:15:27 UTC 2025
On 11/22/2025 1:32 AM, Peter C wrote:
> This is a bit off topic of course, but I can easily twist this same argument
> around for why there should have been a more intuitive syntax for mainfest
> constants, instead of overloading enum to also mean a non-type definition - i.e.
> the tool for defining a type should not be the tool for defining a value.
Long ago, I tried my hand at writing a user interface library. I was shocked to
discover that what was consistent for a computer was very inconsistent to a
user, and vice versa. (Did you know that the ancient Greek Parthenon does not
use straight lines, but they look straight? How did the Greeks figure that out?)
D isn't consistent with what would work best for a computer, either, which is
why it is converted to "intermediate code" by the front end. There are a lot of
inconsistencies, but they work for humans.
`final` is currently used for statements, classes, and derived functions. Adding
them for declarations is not confusing for a human, and keeping the number of
keywords low is good.
I understand you disagree, and that's ok. That's why designing a programming
language is more of an art than a science.
The `enum E = 24;` syntax looked a bit odd at first, but seems perfectly natural
to me now.
More information about the Digitalmars-d
mailing list