More Intuitive Syntax for Manifest (enum) Constants
Paul Backus
snarwin at gmail.com
Sat Nov 22 05:05:31 UTC 2025
On Saturday, 22 November 2025 at 02:30:12 UTC, Peter C wrote:
> On Saturday, 22 November 2025 at 01:48:43 UTC, Walter Bright
> wrote:
>> ```d
>> enum N = 42;
>> ```
>
> I've never ever liked this misuse of enum in D to basically
> reflect a lightweight constant.
This is actually mostly inherited from C.
In C, you can write code like this to define a compile-time
constant:
enum { N = 42 };
The only difference in D is that you are allowed to leave out the
curly braces.
More information about the Digitalmars-d
mailing list