Optimisation possibilities: current, future and enhancements
Patrick Schluter via Digitalmars-d
digitalmars-d at puremagic.com
Fri Aug 26 12:57:28 PDT 2016
On Friday, 26 August 2016 at 17:52:36 UTC, Meta wrote:
> On Friday, 26 August 2016 at 14:12:24 UTC, Basile B. wrote:
>> That's another story. Of course the optimization pass for this
>> should check that **ALL** the calls to Test in a sub program
>> (or in this scope if you want) are const... Which is not the
>> case here.
>
> My point is that getN is strongly pure but is not referentially
> transparent. Purity is broken in a strange way that you
> wouldn't expect, and you don't even have to use an escape hatch
> like debug.
getN() is not pure at all, it refers to an object (in C term)
outside of its scope not depending on its parameter. It is
irrelevant if the outside object is a global variable or a
member. Access to a memory defined outside of its scope breaks
pureness.
More information about the Digitalmars-d
mailing list