DIP 1021--Argument Ownership and Function Calls--Community Review Round 1
Walter Bright
newshound2 at digitalmars.com
Fri Jul 19 08:01:50 UTC 2019
On 7/18/2019 7:59 PM, David Bennett wrote:
> For me it's unclear if the examples as given would become compile time errors
> because it states "The checks would only be enforced for @safe code." and the
> examples are not @safe.
Any container is going to wrap a call to free() in @trusted.
> Also, does it also check simple non-heap references, for example would this
> become compile time error?
>
> ---
> @safe void f(scope ref int a, scope ref int b)
> {
> a=1;
> assert(b==1);
> }
> @safe void main()
> {
> int i = 0;
> f(i, i);
> assert(i==1);
> }
> ---
Yes, because you are passing two mutable references to the same memory.
> If it's going to be an error, a simple example like this in the Breaking Changes
> and Deprecations section could help clear up whats changing from a practical sense.
Since the DIP disallows passing two mutable pointers to the same memory object,
any code that does will break.
More information about the Digitalmars-d
mailing list