On Wednesday, 10 June 2020 at 21:40:44 UTC, Paul Backus wrote:
The current state of @property is that it doesn't really do anything. D allows you to call functions without parentheses, and to use assignment syntax to call a single-argument function, so you can write getters and setters that work like properties even if you don't use the @property annotation:struct Example { private int x_; int x() { return x; } // getter void x(int n) { x = n; } // setter } void main() { Example e; e.x = 123; // calls setter int y = e.x; // calls getter }
@Paul Backus, Thanks for the explanation & code sample.
