DIP1000: Scoped Pointers

Walter Bright via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Mon Aug 15 14:25:22 PDT 2016


On 8/15/2016 6:54 AM, Rory McGuire via Digitalmars-d-announce wrote:
> okay nice, so that code would not compile but code such as:
> void test() {
> scope rnd  = new Rnd; // reference semantic and stack allocated
> auto rnd2 = rnd;
>         some_sneaky_function_that_saves_global_state(rnd);
> }
> would still not be checked. And would crash inexplicably at the point the global
> was accessed?

A local variable initialized with a scoped value will have 'scope' inferred for it.


More information about the Digitalmars-d-announce mailing list