DIP 36: Rvalue References

Manu turkeyman at gmail.com
Tue Apr 9 23:24:34 PDT 2013


On 10 April 2013 16:11, Zach the Mystic <reachzach at gggggmail.com> wrote:

> On Wednesday, 10 April 2013 at 05:21:40 UTC, Manu wrote:
>
>> Why are you suggesting changing scope to imply ref? This seems wrong.
>> scope
>> and ref are separate, should remain that way.
>>
>
> To be clear, I suggested it, not Kenji. The reason scope could imply ref
> is that no value type is ever unsafe.


It is though, in the case I demonstrated. A value type can aggregate a
reference type, and by-val scope would prohibit any part of the copy from
escaping in turn.
This is tricky, but I think it would be an important enhancement for
non-ref scope variables and @safe-ty.
It might be impractical, but it's something to think about anyway...

If you copy the value you're passing, there's no way the reference could
> escape the scope, because there's no reference! A delegate has an implicit
> pointer and is inherently a reference type, which is why it can work with
> 'scope'. In all likelihood 'scope' implying 'ref' would needlessly
> complicate the type system, in exchange for the convenience of only having
> to type either 'scope' or 'ref' depending on what you wanted. But I
> suggested it because I at least wanted it to be discussed.
>

Fair enough.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130410/4d34b797/attachment.html>


More information about the Digitalmars-d mailing list