On 2013-05-09 15:07, Leandro Motta Barros wrote:
Thanks for the comment! I noticed this wouldn't compile, though I haven't really wondered why so. My email was more about the compiler bug than about using alias this with singletons.Anyway, while trying to circumvent the compiler bug, I did this: import std.stdio; class SImpl { void foo() { writeln("foo!"); } private this() { } } class S { static @property SImpl instance() { if (_i is null) _i = new SImpl(); return _i; } static SImpl _i; alias instance this; } void main() { S.foo(); } This works and compiles with DMD 2.062. (I don't like to have to write this additional code manually, but I'll try to make something about it :-) )
Aha, you added an additional class. -- /Jacob Carlborg
