--- Comment #10 from 2012-06-03 06:28:09 PDT ---
(In reply to comment #7)

> argument value is all the data reachable via the parameters.  Argument result
> is all the data reachable via the result.
> the optimizer.  My gut feeling is the compiler/optimizer should trust the code
> "knows what it's doing." and so should expect that the code implicitly knows
> how much data it can access after the pointer.

Having "pure" as an user provided attribute, the compiler completely trusting
the programmer and only checking/enforcing certain assumptions when it is easy
to do, is a reasonable solution. Anybody that understands the purity concept
will have no problem determining if some function is "pure" or not, this is how
it is in C, in dialects supporting pure.

Unfortunately, D has purity inference.

   uint f()(immutable ubyte* p) {
      uint r;
      foreach (i; 0..size_t.max)
         r += p[i];
      return r;

Can this still be considered pure?
What about "uint f2()(Struct* p) {/*same body*/}"?

   uint f3()(ubyte* p) {
      uint r;
      foreach (i; 0..size_t.max)
         r += p[i]++;
      return r;


All three functions are tagged as pure by the compiler...

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to