More Intuitive Syntax for Manifest (enum) Constants

Peter C peterc at gmail.com
Sat Nov 22 10:03:39 UTC 2025


On Friday, 21 November 2025 at 11:20:08 UTC, Per Nordlöw wrote:
>
> ..

While not advocating for a change here, if I wanted to signal to 
the compiler that I wanted a compile-time constant expression, 
but I didn't like using enum to express that intent, then maybe:

@const int SIZE = 5; // effectively the same as C++ -> constexpr 
int N = 5;

This preserves 'const' for runtime use.

Again, I'm *not* advocating for a change, but if I could choose 
between using @const or enum, I'd almost certainly always choose 
@const, as it seems more semantically cleaner to me - assuming 
you know what the @ infers ;-)



More information about the Digitalmars-d mailing list