Discussion Thread: DIP 1035-- at system Variables--Final Review

Nick Treleaven nick at geany.org
Tue Feb 22 15:05:14 UTC 2022


On Sunday, 20 February 2022 at 15:16:30 UTC, Dukc wrote:
> Why we want to do that at all? DIP1000. Most of the potential 
> of DIP1000 is wasted if you cannot prevent destruction before 
> end of the scope:
>
> ```D
> @safe void abuse()
> { auto cont = SomeRaiiContainer([1,2,3]);
>   scope ptr = &cont.front;
>   destroy(cont);
>   int oops = *ptr;
> }
> ```

Doesn't the same problem occur just with reassignment?:

```d
   scope ptr = &cont.front;
   cont = cont.init;
   int oops = *ptr;
```


More information about the Digitalmars-d mailing list