D-Programming-Language/dmd — pull request #2305 by 9rnsr (2013-07-06 08:36:39+00:00)
Title: Implement core design of property enforcement

Points:

- The `-property` switch gets deprecated

After this change, it causes no semantic behavior change.

- Optional parenthesis stay in

Non-property function call with zero arguments can omit parenthesis.

- Property functions cannot be called with parenthesis anymore.

Enforce getter/setter syntax.

- Property name with parenthesis would call the returned value of property.

`obj.prop(...)` is automatically translated to `obj.prop()(...)`

Some specific design decisions
- opDispatch function template which is automatically provided method name, would bypass property check.

```d
struct S1 { void opDispatch(string name, A...)(A args) {} }
S1 s1;
s1.foo; // s1.opDispatch"foo"();
s1.foo(); // s1.opDispatch"foo"();
s1.foo(1); // s1.opDispatch"foo"(1);
s1.foo = 1; // s1.opDispatch"foo"(1); [bypass property check, OK]

struct S2 { template opDispatch(string name) { void opDispatch(A...)(A args) {} } }
S2 s2;
s2.foo; // s2.opDispatch"foo".opDispatch();
s2.foo(); // s2.opDispatch"foo".opDispatch();
s2.foo(1); // s2.opDispatch"foo".opDispatch(1);
//s2.foo = 1; // s2.opDispatch"foo".opDispatch(1); [cannot bypass property check, NG!]
```

- `typeof(prop)` returns the type of property result, but , `typeof(func)` returns function type

Inside `typeof`, applying optional parenthesis rule would break much existing code AFAICS.
Note that, there's no designed semantic change from current state.

See also: https://github.com/D-Programming-Language/dmd/pull/2123#issuecomment-18831828