DIP1000: Scoped Pointers

Rory McGuire via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Mon Aug 15 06:54:28 PDT 2016


On Mon, Aug 15, 2016 at 2:49 PM, Dicebot via Digitalmars-d-announce <
digitalmars-d-announce at puremagic.com> wrote:

> On 08/15/2016 03:41 PM, Rory McGuire via Digitalmars-d-announce wrote:
> > scope rnd  = new Rnd; // reference semantic and stack allocated
> > auto rnd2 = rnd;
> >
> > rnd.i = 2;
> > assert(rnd2.i == 2);
> > return rnd2;
>
> Point is that that would become illegal if DIP1000 is implemented thus
> giving scope class concept more justification. It would still have @safe
> holes though because proposed `scope` does not work through many
> indirection levels - but better than existing situation when nothing is
> checked.
>
>
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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-announce/attachments/20160815/4845bec5/attachment-0001.html>


More information about the Digitalmars-d-announce mailing list