D needs first-class lifetimes before it can get ownership and borrowing

Dennis dkorpel at gmail.com
Sat Aug 10 16:48:26 UTC 2019


On Saturday, 10 August 2019 at 13:30:17 UTC, Olivier FAURE wrote:
> The problem above is that, under DIP-1000, the compiler assumes 
> `borrow()` doesn't escape any data, because it takes `this` by 
> ref; and yet it escapes this.ptr, because there's no way to 
> mark this.ptr as scope.

If I change it to:
```
void borrow() scope { gptr = this.ptr; }
```

I get:
```
Error: scope variable this assigned to non-scope gptr
```

I don't know why it compiles without scope though.


More information about the Digitalmars-d mailing list