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





------- Comment #5 from shro8...@vandals.uidaho.edu  2009-05-05 12:36 -------

I think this is working correctly:

take this example:

import std.stdio;
void fn(lazy int i)
{
    writef("%d\n", k);
    auto j = i();
    writef("%d\n", k);
    auto h = i();
    writef("%d\n", k);
}

int k = 0;

void main()
{
    writef("%d\n", k);
    fn(k++);
    writef("%d\n", k);

}

output:

0
0
1
2
2

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; } }

(it's got to play around a bit with context pointers and whatnot but that's 
side issue)


-- 

Reply via email to