DIP69 - Implement scope for escape proof references

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Thu Dec 4 16:48:57 PST 2014


On Thu, Dec 04, 2014 at 04:31:18PM -0800, Walter Bright via Digitalmars-d wrote:
> On 12/4/2014 3:04 PM, deadalnix wrote:
> >So as mentioned, there are various problem with this DIP :
> >  - rvalue are defined as having a scope that goes to the end of the statement.
> >That mean they can never be assigned to anything as per spec.
> 
> I don't believe this is correct. Rvalues can be assigned, just like:
> 
>    __gshared int x;
>    { int i; x = i; }
> 
> i's scope ends at the } but it can still be assigned to x.
[...]

Well, the "Expressions" section defines certain lifetimes to be
infinity, however, it contradicts the definition of an rvalue's lifetime
given under "Definitions" - "Lifetime", which states that an rvalue's
lifetime lasts only to the end of the statement. This would imply that
the following ought to be rejected:

	int x = 1 + 2; // lifetime(1 + 2) = end of statement
			// but lifetime(x) = infinity

Sounds like the Definitions section is not precise enough. :-)


T

-- 
Curiosity kills the cat. Moral: don't be the cat.


More information about the Digitalmars-d mailing list