More Intuitive Syntax for Manifest (enum) Constants

monkyyy crazymonkyyy at gmail.com
Sun Nov 23 21:19:05 UTC 2025


On Saturday, 22 November 2025 at 09:39:03 UTC, Kapendev wrote:
> I think this isn't very clear and can confuse people. For 
> better readability,
> you should actually use something more in line with modern 
> language design, like:
>
> ```c#
> public static class FOO
> {
>     public const int Value = 42;
> }
> ```
>
> This gives the constant a proper semantic boundary and lets you 
> extend it later
thats still bad style
```d#
public static class FOO
{
     private const int Value = 42;
     ///gets the value
     public const ref int getValue() @property
     {
         assert(&Value is not null);
         return Value;
     }
}
```


More information about the Digitalmars-d mailing list