[Joke] C++ and D namings
Dukc
ajieskola at gmail.com
Wed Jan 20 09:25:51 UTC 2021
>
> How is this different from D? How does this lead to different
> code gen?
Consider a function with a `const int[]` argument. In D, when
generating code for the caller, it is allowed to assume that the
callee won't change the contents of the array, unless it is in
global space or passed via another argument.
The difference to C++ is that the above applies even if the array
contains mutable values from the caller perspective:
```
long sum (const int[] arg);
void foo
{ auto arr = [1,2,3];
auto sum = arr.sum; //codegen can assume that `arr` won't
change
}
```
More information about the Digitalmars-d
mailing list