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

Olivier FAURE couteaubleu at gmail.com
Fri Feb 1 23:24:44 UTC 2019


On Friday, 1 February 2019 at 09:10:15 UTC, 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:

The thing is, D doesn't really differentiate between a getter and 
any other method.

So with DIP-1016, when given

     doubleMyValue(pt.x);

The compiler would assume the programmer means
- Call pt.x()
- Store the result in a temporary
- Pass that temporary as a ref parameter to doubleMyValue

At no point is the compiler aware that the user intends for x to 
be interpreted as a getter.


More information about the Digitalmars-d-announce mailing list