What is the current stage of @property ?
12345swordy
alexanderheistermann at gmail.com
Wed Jun 10 22:15:25 UTC 2020
On Wednesday, 10 June 2020 at 21:40:44 UTC, Paul Backus wrote:
> On Wednesday, 10 June 2020 at 20:24:19 UTC, Vinod K Chandran
> wrote:
>> Hi all,
>> I read in an old thread that authors of D wants to eliminate
>> @property. I just roughly read the big thread bu couldn't find
>> a conclusion. After all that thread is a 48 page longer jumbo
>> thread. So out of curiosity, i am asking this. What is the
>> current state of @property ? Is it deprecated ?
>
> 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
> }
It can't do binary operations and unary operations.
More information about the Digitalmars-d-learn
mailing list