In c# we can do something like this:

 static Lazy<T> lazy =
       new Lazy<T>
           (() => heavyLoadOperation());
 static T value { get { return lazy.Value; } }

and heavyLoadOperation() is only called when variable "value" is actually used. How can I do something like this in D?

I've tried something like this I still can't make it compile:

T delegate() lazy lazy = { return heavyOperation(); }
T X(lazy T delegate() dg) { return dg(); }
T value = X;


Reply via email to