What is the state of @property?
Steven Schveighoffer
schveiguy at gmail.com
Thu Aug 25 03:49:07 UTC 2022
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
More information about the Digitalmars-d
mailing list