https://issues.dlang.org/show_bug.cgi?id=15862

ag0ae...@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

--- Comment #3 from ag0ae...@gmail.com ---
(In reply to Walter Bright from comment #2)
> This is as designed and intended.
> 
> 1. Mutable indirections in the return type do not affect purity
> determination. Mutability of the parameters does.

Sorry, but this is ridiculous. Reopening. Please explain how on earth the shown
behavior is supposedly acceptable.

> 2. An early design decision was that calling new() inside a pure function is
> an acceptable special case. (Otherwise pure functions would be nearly
> useless.)

This is fine. It follows that the compiler must not consider the result
reusable when a function has a mutable indirection in the return type, even
when it's otherwise pure. A strongly pure function (with const parameters) can
only return an int* by newly allocating it. And then reusing it is disastrous.

--

Reply via email to