Improvement in pure functions specification
Stefan Koch via Digitalmars-d
digitalmars-d at puremagic.com
Wed Dec 21 07:49:35 PST 2016
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
Couldn't this be folded into :
"The implementation may not remove a call to a pure function if
does allocate memory ?"
Since there is the concept of weakly pure functions the compiler
cannot decide to remove functions on signature alone.
Meaning the body has to be available for it to even attempt to
elide the call.
Therefore specifying implementation behavior based on the
function signature is misleading IMO.
More information about the Digitalmars-d
mailing list