-dip1000 and non-scope variables
Walter Bright
newshound2 at digitalmars.com
Fri Feb 19 10:52:23 UTC 2021
On 2/19/2021 1:49 AM, Dukc wrote:
> Wouldn't the pointer rewrite be
> ```
> void update(int** p, int* price) @safe
> { *p = price;
> }
> ```
> ?
ref and * are handled differently.
> The compiler should infer that `p` can be `scope`, but `price` can't.
>
>> which shouldn't compile
>
> Why?
Because the address of price escapes the function, and that's not allowed for
ref variables.
More information about the Digitalmars-d
mailing list