On Wednesday, 21 December 2016 at 15:40:42 UTC, Andrei
Alexandrescu wrote:
On 12/20/2016 05:49 PM, Andrei Alexandrescu wrote:
https://github.com/dlang/dlang.org/pull/1528 -- Andrei
Dropped the void functions. On to the next scandal:
A function that accepts only parameters without mutable
indirections and
returns a result that has mutable indirections is called a $(I
pure factory
function). An implementation may assume that all mutable memory
returned by
the call is not referenced by any other part of the program,
i.e. it is
newly allocated by the function.
Andrei
There are 3 levels:
1) no idea what's going on: e.g. the function returns a mutable
reference and also reads from global mutable memory.
2) memory must be new: e.g. returns 2 mutable references, no
accessing external mutable memory.
3) memory must be new and uniquely referenced: function returns 1
mutable reference, does not access external mutable memory.
If I'm not mistaken only 3 enables anything useful like implicit
casts to immutable.
Also, "returned references" should be extended to include "out"
parameters, because there's no difference as far as memory
uniqueness is concerned.