Non-ugly ways to implement a 'static' class or namespace?

thebluepandabear therealbluepandabear at protonmail.com
Sun Feb 5 10:51:51 UTC 2023


> {
>     @disable this();
>
>     static this()
>     {
>         Message =  "Hello!";
>     }
>
>     static:
>
>     string Message;
>
>     void drawLine() {};
> }

It's not a terrible workaround to be honest.

`static class` does have a use when it's nested, so it might 
create some conflicts if such a feature (like C# `static class`) 
were added.

Due to the mindset of the current maintainers of the language, I 
doubt we will see such a thing. Maybe in 10-20 years something 
will change and the language will add a static class or namespace 
feature, for now we'll have to deal with modules or using your 
way of creating a `static class`.




More information about the Digitalmars-d-learn mailing list