[Issue 2939] lazy evaluation not invoked for lambda function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 5 12:51:58 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=2939





------- Comment #6 from jarrett.billingsley at gmail.com  2009-05-05 14:52 -------
(In reply to comment #5)

> What is happening in the original cases is that the 'dg();' is evaluating *to
> the* lambda rather than *evaluating* the lambda. And this is correct as the
> expression that f was called with is the lambda. (If there is a problem here is
> it the old one of the skipping the perens on void functions thing)
> 
> To look at it another way, dg is (almost):
> 
> delegate void(){ return delegate void(){ ok = true; } }

Yes, I'm pretty sure that's what's happening.  But there are two issues:

(1) It's extremely counterintuitive, easy to forget, and when you invariably
get bitten by it, the compiler and runtime give no help diagnosing the problem.

(2) Why does passing a delegate reference work, but not a lambda?  They are
*the same type* and you'd expect the compiler to do *the same thing* with both.


-- 



More information about the Digitalmars-d-bugs mailing list