More Intuitive Syntax for Manifest (enum) Constants

monkyyy crazymonkyyy at gmail.com
Sun Nov 23 22:29:13 UTC 2025


On Sunday, 23 November 2025 at 22:16:41 UTC, Kapendev wrote:
> On Sunday, 23 November 2025 at 21:19:05 UTC, monkyyy wrote:
>> On Saturday, 22 November 2025 at 09:39:03 UTC, Kapendev wrote:
>>> [...]
>> 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;
>>     }
>> }
>> ```
>
> Overall, better, but you forgot to put `@trusted` there. Return 
> `ref` is unsafe, but your code looks correct, so it's okay. It 
> would be nicer if you wrapped that getter in a safer 
> abstraction.

const ref is acceptable according to uncle bob during his 3 book 
tour stop 3 he said "const ref is good for c#" applying this to 
d# seems natural


More information about the Digitalmars-d mailing list