On Friday, 1 February 2019 at 23:24:44 UTC, Olivier FAURE wrote:
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.

Languages like c# solve this problem by disallowing passing property to ref parameter arguments.
              • ... Olivier FAURE via Digitalmars-d-announce
              • ... Steven Schveighoffer via Digitalmars-d-announce
              • ... aliak via Digitalmars-d-announce
              • ... Timon Gehr via Digitalmars-d-announce
              • ... aliak via Digitalmars-d-announce
              • ... 12345swordy via Digitalmars-d-announce
              • ... Aliak via Digitalmars-d-announce
              • ... 12345swordy via Digitalmars-d-announce
              • ... Olivier FAURE via Digitalmars-d-announce
              • ... Paul Backus via Digitalmars-d-announce
              • ... 12345swordy via Digitalmars-d-announce
              • ... Andrei Alexandrescu via Digitalmars-d-announce
              • ... Olivier FAURE via Digitalmars-d-announce
              • ... Nicholas Wilson via Digitalmars-d-announce
              • ... Manu via Digitalmars-d-announce
              • ... Steven Schveighoffer via Digitalmars-d-announce
              • ... Manu via Digitalmars-d-announce
              • ... Andrei Alexandrescu via Digitalmars-d-announce
          • Re: DIP 1... Manu via Digitalmars-d-announce
    • Re: DIP 1016--ref T a... Olivier FAURE via Digitalmars-d-announce
  • Re: DIP 1016--ref T accept... Don via Digitalmars-d-announce

Reply via email to