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

Nick Treleaven nick at geany.org
Mon Jan 30 19:45:59 UTC 2023


On Friday, 20 January 2023 at 11:28:23 UTC, thebluepandabear 
wrote:
> ```
> final abstract class Algo {
>     void drawLine(Canvas c, Pos from, Pos to) { ...... };
> }
> ```
>
> This solution seems like a bit of a hack, which is why I don't 
> like it.

Interesting solution if you put `static:` in there.

> Alternatively you could create a module, but then it would just 
> be a function without a clear type.

Why do you want a type?

> Is anyone aware of a non-ugly way to implement a 'static' class 
> or namespace?

Use a struct and put `static:` after the opening brace. That's 
what GC is in core.memory.



More information about the Digitalmars-d-learn mailing list