On Sunday, 8 December 2013 at 21:32:35 UTC, Joseph Rushton
Wakeling wrote:
On 08/12/13 21:12, Ali Çehreli wrote:
In any case, I think class static this is the solution:
I think I may have misled you by talking about properties,
because I _don't_ mean a property of a class. I mean a public
standalone function that is marked as a @property, which
returns a persistent instance of some class.
The actual motivation is reimplementing std.random.rndGen but
with class-based RNGs instead of structs :-)
A consequence of this is that I don't think a static class
instance can work, because the returned class has to be
non-const -- it's an RNG that will be updated!
I understand you are talking about the "Singleton" design pattern.
You might want to look how std.parallelism does it with the
default global thread pool.
https://github.com/D-Programming-Language/phobos/blob/master/std/parallelism.d#L3261