What is the state of @property?

bauss jacobbauss at gmail.com
Thu Aug 25 07:18:12 UTC 2022


On Thursday, 25 August 2022 at 03:49:07 UTC, Steven Schveighoffer 
wrote:
> On 8/24/22 11:26 PM, Ki Rill wrote:
>> It's not recommended to use it, yet people do continue using 
>> it anyway... I see it in people's code. So, was it finalized, 
>> but docs weren't updated? Or is it still half-backed? And what 
>> is the issue?
>
> It's not even 1/10 baked.
>
> It does just about nothing. The only discernable difference is 
> `typeof`:
>
> ```d
> struct S
> {
>     int prop1() { return 1; }
>     @property int prop2() { return 2; }
> }
>
> pragma(msg, typeof(S.prop1)); // int()
> pragma(msg, typeof(S.prop2)); // int
> ```
>
> What is the issue? The attribute was added with the intention 
> that properties would require a @property attribute, and 
> functions would not. But there was pushback, so it never got 
> formalized. For a while we had a `-property` switch which would 
> enforce some rules, but it was also removed.
>
> As of today, I'd ignore @property. If someone is using it, just 
> pretend it's a normal function.
>
> -Steve

Personally I use it for documentation as it makes it clear what 
the intentions are of said functions.


More information about the Digitalmars-d mailing list