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

12345swordy alexanderheistermann at gmail.com
Fri Feb 1 14:41:52 UTC 2019


On Friday, 1 February 2019 at 11:48:51 UTC, Timon Gehr wrote:
> On 01.02.19 10:10, aliak wrote:
>>>
>> 
>> Shouldn't doubleMyValue(pt.x) be a compiler error if pt.x is a 
>> getter? For it not to be a compile error pt.x should also have 
>> a setter, in which case the code needs to be lowered to 
>> something else:
>> 
>> {
>>    auto __temp = pt.x;
>>    doubleMyValue(__temp);
>>    pt.x = __temp;
>> }
>> 
>> I believe this is something along the lines of what Swift and 
>> C# do as well.
>> 
>> Or something... a DIP to fix properties anyone? :)
>
> http://wilzbach.github.io/d-dip/DIP24
>
> I'm not sure your rewrite is good though, because it does not 
> preserve aliasing during the function call.
Not only that, but C# forbids you passing properties as an 
ref/out parameter.
(The properties should be redefined as accessor, such that you 
can't take the address of it)
-Alex


More information about the Digitalmars-d-announce mailing list