DIP 1021--Argument Ownership and Function Calls--Community Review Round 1

Walter Bright newshound2 at digitalmars.com
Fri Jul 19 08:04:06 UTC 2019


On 7/18/2019 8:31 PM, David Bennett wrote:
> If that's so I'm guessing this would be the simplest thing that would stop 
> compiling?
> 
> ---
> @safe void f(scope ref int* a, scope ref int* b)
> {
>      *a=1;
>      a = null;
>      assert(*b==1);
> 
> }
> @safe void main()
> {
>      int i = 0;
>      scope int* a = &i;
>      scope int* b = &i;
>      f(a, b);
>      assert(i==1);
>      assert(a is null);
>      assert(*b==1);
> }
> ---

That will still compile, because as the DIP says, it only looks at the function 
call, it is not doing data flow analysis on preceding or succeeding statements.



More information about the Digitalmars-d mailing list