On Wednesday, 17 October 2018 at 07:32:37 UTC, aliak wrote:
lazy S x = () { // do some heavy stuff }();if (condition) { func(x.y); // heavy stuff evaluated here }
auto x = () {
// do some heavy stuff
};
if (condition) {
func(x().y); // heavy stuff evaluated here
}
If you want to make it a little prettier, you could define a
couple helper functions:
T delegate() delay(lazy T expr)
{
return () => expr;
}
T force(T delegate() thunk)
{
return thunk();
}
