<div dir="ltr">The title of this thread is lazy... statement but it seems to me that expressions are the natural unit. If I want to do lazy evaluation today, I would use something like<br><br> f(a, b, lambda: g(a,b))<br>
<br>where of course the g(a,b) is only evaluated when f wants to evaluate it. Of course f is responsible for explicitly evaluating that lambda. I think a lambda-like syntax like this:<br>
<br> f(a, b, lazy: g(a,b))<br><br>would be easy to understand. Note that this puts the responsibility on the caller's side to say that the expression is lazy. That is, we don't do<br><br> def f(a, b, lazy: d):<br>
or<br> lazy: def(a, b, d):<br><br>although this is allowed:<br>
<br> def f(a, b, d=lazy: g())<br><br>There are several reasons I put the responsibility on the caller's side:<br><br>(1) The caller is in the best position to know if evaluating a lazy expression is expensive enough that it's worth making lazy, and if making an expression lazy changes the order of evaluation in a bad way.<br>
<br>(2) When we see a function call, we don't know for sure which function will be called so we'd have to compile both the inline and the lazy evaluation for each parameter.<br><br>I'm not sure what this makes for the import case.<br>
<br>--- Bruce<br><br></div>