static class vs. static struct
Daniel Kozak via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jan 27 01:36:47 PST 2015
On Tuesday, 27 January 2015 at 09:01:39 UTC, ref2401 wrote:
> For several times I've met struct(or static struct) usage in
> Phobos for singleton pattern implementation. Unfortunately now
> i can remember only core.runtime.Runtime.
> So I've got a question. Why do Phobos guys use struct or static
> struct for or singleton pattern implementation? Why don't use
> static final class for this purpose?
I do not think this is a singleton pattern (no instance). I see
it much more like namespace in case of core.runtime.Runtime. And
yes static final class could do that too but struct looks better
than final class and you can disable this on structs
More information about the Digitalmars-d-learn
mailing list