Improvement in pure functions specification

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Tue Dec 20 18:27:02 PST 2016


On 12/20/16 8:54 PM, H. S. Teoh via Digitalmars-d wrote:
> On Tue, Dec 20, 2016 at 08:16:36PM -0500, Andrei Alexandrescu via Digitalmars-d wrote:
>> On 12/20/16 8:02 PM, H. S. Teoh via Digitalmars-d wrote:
>>> Isn't that impure by definition?!  How can tracing execution even be
>>> remotely considered pure?
>>
>> That's why the compiler is required compulsively to call it. -- Andrei
>
> I don't follow.
>
> The question was how can a function with side-effects (even given D's
> relaxed definition of pure, i.e., allowing mutation via arguments) can
> be considered pure.  What has that got to do with the compiler being
> required to call it?
>
> I'd say a pure void function should be equivalent to no-op and elidable.

If it's elidable, it's as good as a bug in the program. Must be either a 
compile-time error or a special case. -- Andrei




More information about the Digitalmars-d mailing list