lazy variables

Chris Katko ckatko at gmail.com
Wed Oct 17 08:27:47 UTC 2018


On Wednesday, 17 October 2018 at 07:32:37 UTC, 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
> }();
>
> if (condition) {
>   func(x.y); // heavy stuff evaluated here
> }
>
> Cheers,
> - Ali

This might be helpful:

https://dlang.org/articles/lazy-evaluation.html


More information about the Digitalmars-d-learn mailing list