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?
Thread overview | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
August 25, 2022 What is the state of @property? | ||||
---|---|---|---|---|
| ||||
August 24, 2022 Re: What is the state of @property? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ki Rill | 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
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 As of today, I'd ignore @property. If someone is using it, just pretend it's a normal function. -Steve |
August 25, 2022 Re: What is the state of @property? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Thursday, 25 August 2022 at 03:49:07 UTC, Steven Schveighoffer wrote: >As of today, I'd ignore @property. If someone is using it, just pretend it's a normal function. -Steve Thank you, Steven, for the detailed reply. I will continue ignoring it. Anyways, we have |
August 25, 2022 Re: What is the state of @property? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | 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
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 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. |
August 25, 2022 Re: What is the state of @property? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ki Rill | On Thursday, 25 August 2022 at 03:26:32 UTC, 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? Why is it not recommended?
Or when you want to do some audit:
I have no objections to deprecate |
August 25, 2022 Re: What is the state of @property? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrey Zherikov | On Thursday, 25 August 2022 at 13:18:38 UTC, Andrey Zherikov wrote: >On Thursday, 25 August 2022 at 03:26:32 UTC, 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? Why is it not recommended?
Or when you want to do some audit:
I have no objections to deprecate I'm really not sure what you mean. Currently @property doesn't really do anything in this regard, so I imagine that the code would work the same without @property, no? |
August 25, 2022 Re: What is the state of @property? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrey Zherikov | On Thursday, 25 August 2022 at 13:18:38 UTC, Andrey Zherikov wrote: >I have no objections to deprecate That works by default without |
August 26, 2022 Re: What is the state of @property? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrey Zherikov |
On 26/08/2022 1:18 AM, Andrey Zherikov wrote:
> I have no objections to deprecate `@property` attribute but I believe D must support the use case when `obj.mem` expression calls `obj.mem()` function (this is usually called property functions).
It already does. That is the problem!
```d
import std;
void main()
{
S s;
s.new_member = "foo";
s.old_member.writeln;
}
struct S
{
string old_member() { return new_member; }
string new_member;
}
```
|
August 25, 2022 Re: What is the state of @property? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Thursday, 25 August 2022 at 13:25:58 UTC, Mike Parker wrote: >On Thursday, 25 August 2022 at 13:18:38 UTC, Andrey Zherikov wrote: >I have no objections to deprecate That works by default without I didn't know that! Shame on me 🤦 |
August 25, 2022 Re: What is the state of @property? | ||||
---|---|---|---|---|
| ||||
Posted in reply to bauss | On Thursday, 25 August 2022 at 13:23:25 UTC, bauss wrote: >Currently @property doesn't really do anything in this regard, so I imagine that the code would work the same without @property, no? One benefit of @property is that it allows the compiler to infer automatically. So it behaves like auto but superior! For example:
SDB@79 |