www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Just curious: who do know current purity rules?

reply Denis Shelomovskij <verylonglogin.reg gmail.com> writes:
As Kenji Hara just created purity fixing pull [1] we will probably soon 
have more intuitive rules so it's interesting who do understand current 
purity rules. The following code is proposed to check your understanding:
---
alias F = bool function(int) pure;
alias D = bool delegate(int) pure;

D foo1(immutable F  f) pure { return x => (*f)(x); } // ok or error?
D foo2(    const F  f) pure { return x => (*f)(x); } // ok or error?
D foo1(immutable F* f) pure { return x => (*f)(x); } // ok or error?
D foo2(    const F* f) pure { return x => (*f)(x); } // ok or error?
---

Who passes this test? By "pass" I mean completely understand what the 
compiler do and why.

By the way, personally I would fail the test. )


[1] [spoiler!] https://github.com/D-Programming-Language/dmd/pull/3626

-- 
Денис В. Шеломовский
Denis V. Shelomovskij
Jun 06 2014
next sibling parent reply "Kagamin" <spam here.lot> writes:
Do you mean true purity rules or whatever is implemented in the 
compiler?
Jun 06 2014
parent Denis Shelomovskij <verylonglogin.reg gmail.com> writes:
06.06.2014 13:05, Kagamin пишет:
 Do you mean true purity rules or whatever is implemented in the compiler?

"whatever is implemented". ) -- Денис В. Шеломовский Denis V. Shelomovskij
Jun 06 2014
prev sibling parent "deadalnix" <deadalnix gmail.com> writes:
On Friday, 6 June 2014 at 19:32:17 UTC, Denis Shelomovskij wrote:
 06.06.2014 13:05, Kagamin пишет:
 Do you mean true purity rules or whatever is implemented in 
 the compiler?

"whatever is implemented". )

Do someone know whatever is implemented ? I certainly don't.
Jun 06 2014