[Dlang-internal] DIP1000 discussion and testing: borrowing a range
Dicebot via Dlang-internal
dlang-internal at puremagic.com
Thu Oct 20 09:44:07 PDT 2016
On 10/16/2016 10:30 PM, Walter Bright wrote:
> It works because 'scope' is inferred as a storage class when an
> expression that needs scope is used to initialize a local. y gets a
> subset of the life of instance. Doing such inference makes using
> -transition=safe far more palatable.
>
> BTW, reducing the examples to their minimums helps a lot.
This compiles too:
```
int* x;
@safe unittest
{
@safe static struct S
{
int data;
int* borrow () return scope @trusted {
return &this.data;
}
}
S instance;
x = instance.borrow();
}
```
Now, _this_ must be wrong, right?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puremagic.com/pipermail/dlang-internal/attachments/20161020/75a207d6/attachment.sig>
More information about the Dlang-internal
mailing list