On Wednesday, 14 May 2014 at 23:50:34 UTC, Meta wrote:
On the topic of lazy, why *is* it so slow, exactly? I thought
it was just shorthand for taking a function that evaluates the
expression, and wrapping said expression in that function at
the call site. That is, I thought that:
int doSomething(lazy int n)
{
return n();
}
Was more or less equivalent to:
int doSomething(int function(int) n)
{
return n();
}
It's more equivalent to:
int doSomething(int delegate(int) n)
{
return n();
}
And (I could be very likely wrong here), I believe that it's
expensive because it's not scope and possibly requires a closure.
Again, very likely may be wrong.