DIP 1021--Argument Ownership and Function Calls--Final Review
Dennis
dkorpel at gmail.com
Mon Sep 16 10:10:36 UTC 2019
On Monday, 16 September 2019 at 09:13:48 UTC, Mike Parker wrote:
> https://github.com/dlang/DIPs/blob/1d78cdf1613911439848a49e9053a7bbf5a9de46/DIPs/DIP1021.md
As Andrei said at DConf 2019, a DIP must be thorough enough such
that it should be able to be correctly implemented by a vengeful
ex. Currently, the description does not pass this test:
> Therefore, if more than one reference to the same data is
> passed to a function, they must all be const
```
void foo(scope int[] x, scope int[] y);
void main() {
int[2] a = [100, 200];
int[2] b = [100, 200];
foo(a[], b[]); // not allowed in vengeful implementation!
// The same data is passed, so parameters x and y must be
const
}
```
```
void foo(scope immutable int[] x, scope immutable int[] y);
void main() {
immutable int[4] a;
foo(a[], a[]); // not allowed in vengeful implementation!
// parameters are immutable, not const
}
```
You might say "it is obvious what I meant" but that reasoning
didn't prevent DIP1016 [1] (Manu's ref T accepts r-values) from
being rejected.
> This builds on the foundation established and tested by DIP 25
> and DIP 1000
This doesn't help defining "the same data" either, DIP 1000 is
superseded and there is little to no specification on how `scope`
currently works with the -dip1000 flag.
[1]
https://github.com/dlang/DIPs/blob/master/DIPs/rejected/DIP1016.md
More information about the Digitalmars-d
mailing list