lazy variables

Steven Schveighoffer schveiguy at gmail.com
Thu Oct 18 14:07:13 UTC 2018


On 10/17/18 3:32 AM, aliak wrote:
> Hi,
> 
> Is there any notion of lazy vars in D (i see that there're parameters)?
> 
> i.e:
> 
> struct S {
>    //...
>    int y;
>    //...
> }

/*
> lazy S x = () {
>      // do some heavy stuff
> }();
*/

auto x() { // do some heavy stuff
}

> 
> if (condition) {
>    func(x.y); // heavy stuff evaluated here
> }
> 

-Steve


More information about the Digitalmars-d-learn mailing list