More Intuitive Syntax for Manifest (enum) Constants
Paul Backus
snarwin at gmail.com
Fri Nov 21 21:07:02 UTC 2025
On Friday, 21 November 2025 at 11:20:08 UTC, Per Nordlöw wrote:
> As D already has the keyword `macro` reserved, it just struck
> me that I personally think
>
> ```d
> macro N = 42;
> ```
>
> is more intuitive and recognizable than
>
> ```d
> enum N = 42;
> ```
By the way, we do not necessarily have to use a keyword for this.
The D grammar allows declarations with only a UDA to the left of
the variable name, rather than a type or storage class:
```d
@UDA N = 42;
```
So if we created a new `core.attribute` UDA, we could potentially
write code like this:
```d
@manifestConstant N = 42;
```
More information about the Digitalmars-d
mailing list