Non-ugly ways to implement a 'static' class or namespace?
Ruby The Roobster
rubytheroobster at yandex.com
Fri Jan 20 13:44:37 UTC 2023
On Friday, 20 January 2023 at 13:38:47 UTC, evilrat wrote:
> On Friday, 20 January 2023 at 13:17:05 UTC, Ruby The Roobster
> ...
> [snip]
>
> Also there is various import options such as renamed import or
> static import(doesn't add module to a scope thus requiring to
> fully qualify it)
>
> static import, can be used to somewhat mimic namespaces, more
> complex scenario would be making a module consisting of public
> imports to group things together, but I don't think it is
> common in D.
> https://dlang.org/spec/module.html#static_imports
>
> ```d
> static import std.stdio;
>
> void main()
> {
> // nope, this function will not be resolved, compilation error
> // wrtiteln("hello");
>
> // ok
> std.stdio.writeln("hello");
> }
> ```
I never knew that there even WAS a `static import` option. Good
to know.
More information about the Digitalmars-d-learn
mailing list