Deprecating this(this)
Timon Gehr
timon.gehr at gmx.ch
Mon Apr 2 11:09:53 UTC 2018
On 02.04.2018 10:04, Shachar Shemesh wrote:
> On 02/04/18 10:45, Jonathan M Davis wrote:
>> Honestly, I think at this point pure is easier to understand if you
>> think of
>> it as @noglobal and don't think about functional purity at all.
>
> That's fine. My point was that the only optimizations possible are
> possible on strictly pure functions (the immutable cast one included).
> Weakly pure functions add nothing.
> ...
That point is wrong. It would be wrong even if your next point was true.
> But merely having them around means that when I annotate a function with
> "pure", I do not promise any guarantees that the compiler can actually
> use to perform optimizations.
>
> Shachar
Yes, actually you do.
For example, if you have:
void foo(int[] x)pure;
void main(){
auto x = [1];
auto y = x.dup;
foo(x);
foo(y);
}
This can be transformed into:
void main(){
auto x = [1];
foo(x);
auto y = x.dup;
}
Pure functions have deterministic side-effects.
More information about the Digitalmars-d
mailing list