2013/11/1 Timon Gehr <timon.g...@gmx.ch> > On 11/01/2013 02:36 PM, Kenji Hara wrote: > >> I think this is a good discovery. Currently a pure function can have >> lazy parameters and it is treated as a weakly pure function. >> >> pure int foo(lazy int x) { return x; } // OK >> >> We can think the lazy parameter is a limited case of scope delegate >> parameter. >> ... >> > > They are. I think it would be quite strange to treat them differently.
I've also felt same thing about it. The proposal will generalize the language rule. > And more, I discovered that the purity may be stronger depends on the >> given delegate purity. >> >> void func(scope void delegate(int) dg) pure; >> >> void main() { >> int num; >> >> // the function call has weak purity >> func((x){ num = x;}); >> >> // the function call has strong purity >> func((x){ ; }); >> } >> >> Kenji Hara >> >> > Yes. Furthermore, the first delegate should have inferred type 'void > delegate(int x)pure nothrow @safe' and the second delegate should have > inferred type 'void delegate(int x)pure immutable nothrow @safe'. > The first delegate should not become pure. So it would become 'void delegate(int)nothrow @safe'. I agree with the second inference result. Kenji Hara