-preview=in might break code
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Sat Oct 3 12:42:38 UTC 2020
On Saturday, 3 October 2020 at 08:51:26 UTC, Daniel N wrote:
> You can freely mix any number of 'in' and 'out' parameters and
> keep the optimized behavior.
>
> As soon as you add any 'ref' parameter 'in' will pass by value.
I don't know what would be the best mix. :-) But it is
interesting to think about various options that could work.
There are many ways to make it a little better, but very
difficult to come up with something that feels right.
For instance it is possible to use the type system to prove that
in some cases aliasing is not possible simply because the types
of objects that are reachable from parameter 1 are all different
from the types reachable from parameter 2. Then you know that
there can be no aliasing between the parameters. Unfortunately
that excludes way too many valid cases where this does not hold.
And well, you also need to consider aliasing with globals that
are accessed within the function.
More information about the Digitalmars-d
mailing list