Non-ugly ways to implement a 'static' class or namespace?
ProtectAndHide
ProtectAndHide at gmail.com
Sun Feb 5 22:43:55 UTC 2023
On Sunday, 5 February 2023 at 22:40:09 UTC, ProtectAndHide wrote:
>
> ..
module test;
import std;
static final class Algo
{
@disable this();
static this()
{
Message = "Hello!";
}
static:
string Message;
void drawLine() {};
}
void main()
{
Algo foo1 = null; // the compiler should not allow you to
declare a variable of static type
Algo[] foo2 = null; // the compiler should not allow you to
declare an array with elements of static type
List[Algo] foo3; // the compiler should not allow you to use
static types as type arguments
writeln(foo1);
writeln(foo2);
writeln(foo3);
}
void Method1(Algo x) {} // the compiler should not allow you to
use static types as parameters
Algo Method2() { return null; } // the compiler should not allow
you to use static types as return types
struct List {}
More information about the Digitalmars-d-learn
mailing list