lazy variables

aliak something at something.com
Thu Oct 18 14:08:11 UTC 2018


On Wednesday, 17 October 2018 at 23:34:55 UTC, Paul Backus wrote:
> 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
> }

That would do heavy stuff everytime i wanted to get y though 
right?





More information about the Digitalmars-d-learn mailing list