DIP69 - Implement scope for escape proof references

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Mon Dec 8 14:49:05 PST 2014


On Saturday, 6 December 2014 at 21:57:03 UTC, Walter Bright wrote:
> On 12/5/2014 3:59 PM, deadalnix wrote:
>> The DIP say nothing about scoped rvalue having different 
>> behavior
>> than non scoped ones.
>
> Can you propose some new wording?
>

I did:


An infinite lifetime is a lifetime greater or equal than any
other lifetime. Expression of infinite lifetime are:
   - literals
   - GC heap allocated objects
   - statics and enums.
   - rvalues of type that do not contain indirections.
   - non scope rvalues.


Dereference share the lifetime of the dereferenced expression (ie
infinite lifetime unless the expression is scope). Address of
expression shared the lifetime of the base expression, and in
addition gain the scope flag.

>>> Are you suggesting transitive scope?
>>
>> For rvalues, yes. Not for lvalues.
>
> I don't think that is workable.

That is the only way. For rvalue, you got to take the lower
possible lifetime, but for lvalue, you want to consider the
highest possible lifetime.


More information about the Digitalmars-d mailing list