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

Reply via email to