Re: Singletons importing each other?

2016-07-25 Thread Jack via Digitalmars-d-learn
On Sunday, 24 July 2016 at 15:38:13 UTC, lqjglkqjsg wrote: On Sunday, 24 July 2016 at 15:07:20 UTC, Jack wrote: [...] - You can use a 3rd module that imports the two that "cycle". - You can use another singleton implementation that doesn't rely on a static this. e.g a kind of "lazy factory"

Re: Singletons importing each other?

2016-07-24 Thread lqjglkqjsg via Digitalmars-d-learn
On Sunday, 24 July 2016 at 15:07:20 UTC, Jack wrote: Is there a way for singletons that import each other, use each other's functions? Like i.e: -- module sing1; import sing2; final class Singleton_1{ static this{ instance = new Singleton_1(); } static Singleton_1 getInstance(){ return

Singletons importing each other?

2016-07-24 Thread Jack via Digitalmars-d-learn
Is there a way for singletons that import each other, use each other's functions? Like i.e: -- module sing1; import sing2; final class Singleton_1{ static this{ instance = new Singleton_1(); } static Singleton_1 getInstance(){ return instance; } void foo(){ writeln("Sample"); } void