DIP 1016--ref T accepts r-values--Formal Assessment

Rubn where at is.this
Thu Jan 31 23:49:36 UTC 2019


On Thursday, 31 January 2019 at 22:00:10 UTC, Walter Bright wrote:
> On 1/31/2019 1:46 PM, Andrei Alexandrescu wrote:
>> The proposal could actually disallow rvalues that have lvalue 
>> syntax, such as "symbol", "symbol[expr]", "symbol.symbol", 
>> "symbol.symbol[expr]", etc. Ugh. Gets hairy quickly.
>
> That's why it's problematic to have a rule that rvalues can be 
> implicitly converted, but not lvalues. There's not a hard line 
> between lvalues and rvalues. For example,
>
>   foreach(i; 0..2)
>   {
>     int[] a = [1, 2];
>     assert(a[0] == 1]);
>     a[0] = 3;  // will this cause the assert to fail?
>   }

Why would it cause the assert to fail? A new array is constructed 
each loop.


More information about the Digitalmars-d-announce mailing list