local class instance (at module-level)
H. S. Teoh
hsteoh at quickfur.ath.cx
Thu Mar 14 11:16:01 UTC 2019
On Thu, Mar 14, 2019 at 12:05:22PM +0100, spir via Digitalmars-d-learn wrote:
> I desperately try to declare/define/initialise a simple class instance
> at module-level. This is a special (conceptually static and immutable)
> instance used as a "marker", that just should exist and be accessible
> by methods of this class and/or other classes defined in the same
> module. (Thus I don't care if TLS.) I use it as a remplacement for
> null, to avoid semantic confusion and unhelpful segfaults in case of
> bug.
Does this work?
class C { ... }
immutable C c0;
static this() {
c0 = new C(...);
}
T
--
To err is human; to forgive is not our policy. -- Samuel Adler
More information about the Digitalmars-d-learn
mailing list