[Joke] C++ and D namings

Dukc ajieskola at gmail.com
Wed Jan 20 10:00:01 UTC 2021


On Wednesday, 20 January 2021 at 09:53:34 UTC, Ola Fosheim 
Grostad wrote:
> On Wednesday, 20 January 2021 at 09:25:51 UTC, Dukc wrote:
>> long sum (const int[] arg);
>> void foo
>> {  auto arr = [1,2,3];
>>    auto sum = arr.sum; //codegen can assume that `arr` won't 
>> change
>> }
>
> The called function has to be @pure, as the slice could 
> reference a global...

Not in this case, as the caller knows `arr` is a only referenced 
locally. Had `foo` received `arr` as argument, then `sum` would 
have to be `pure` for the optimization.


More information about the Digitalmars-d mailing list