digitalmars.D - an interesting way to do lazy object caching
- BCS (19/19) Sep 01 2007 interface C1{ C1 get();}
interface C1{ C1 get();} class Use : C1{C1 get(){return this;}} class D { private C1 mine; this(){mine = new C2;} C1 give(){return mine.get;} private class C2 : C1 { C1 get(){ return mine = new Use(); } } } void main() { D d = new D; // make C2 C1 c = d.give; // make a C1 c = d.give; // do not make a C1 } comments?
Sep 01 2007