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

Timon Gehr timon.gehr at gmx.ch
Fri Feb 1 11:48:51 UTC 2019


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.


More information about the Digitalmars-d-announce mailing list