DIP1000 and immutable

jmh530 john.michael.hall at gmail.com
Tue Apr 27 15:05:28 UTC 2021


On Tuesday, 27 April 2021 at 14:44:48 UTC, Adam D. Ruppe wrote:
> On Tuesday, 27 April 2021 at 14:28:12 UTC, jmh530 wrote:
>> However, should it ever matter if you escape an immutable?
>
> Your example is a pretty clear case of use-after-free if gloin 
> actually did escape the reference and kept it after main 
> returned.
>
>> I tried basically the same thing in Rust and it doesn't 
>> generate errors (their borrow checker should be assuming scope 
>> by default).
>
> That means it treats gloin as if it is scope, so it isn't the 
> same as your D code since the gloin there is NOT borrowing.

Hmmm, good points. Thanks.


More information about the Digitalmars-d-learn mailing list