Just curious: who do know current purity rules?

2014-06-06 Thread Denis Shelomovskij via Digitalmars-d
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


Re: Just curious: who do know current purity rules?

2014-06-06 Thread Kagamin via Digitalmars-d
Do you mean true purity rules or whatever is implemented in the 
compiler?


Re: Just curious: who do know current purity rules?

2014-06-06 Thread Denis Shelomovskij via Digitalmars-d

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


Re: Just curious: who do know current purity rules?

2014-06-06 Thread deadalnix via Digitalmars-d

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.