Thread overview
another properties thread
Apr 22, 2021
Moth
Apr 22, 2021
Adam D. Ruppe
Apr 22, 2021
drug
Apr 26, 2021
Luhrel
Apr 29, 2021
12345swordy
Apr 28, 2021
Kagamin
Apr 28, 2021
drug
Apr 29, 2021
Kagamin
April 22, 2021

hello all. it's been a little while.
last year i found that the D spec concerning @property is in limbo, with the official documentation recommending against its use for almost three years at this point.

this was an upset, but dealable - it was ugly and long-winded, but i could work around the limitation by using manual getter and setter methods.

however, recently i discovered that the implementation of the bitfields template - the use of which is stated to be a best practice by the documentation - also uses @property in the code it generates.

this concerns me greatly. surely the standard library should be stable, not using half-implemented features that may be removed in the future - should i stop using bitfields? i've read elsewhere on this forum that the maintainers don't see @property as important, but this seems rather critical to me - is there likely to be any change in their stance on the issue? i would much, much rather use @property than not.

i hope i have not caused any offense with this post, but this situation really is frustrating, and i wanted to get it off my chest.

April 22, 2021

On Thursday, 22 April 2021 at 02:25:29 UTC, Moth wrote:

>

this was an upset, but dealable - it was ugly and long-winded, but i could work around the limitation by using manual getter and setter methods.

The @property annotation does almost nothing, so you can still do properties without the annotation.

The only thing @property actually does is change typeof(obj.prop) afrom function over to the type it returns.

>

i would much, much rather use @property than not.

Why? What exactly do you need it to do?

(I myself want property to be fixed but I have a specific list of cases why, so curious what you are thinking of...)

April 22, 2021
22.04.2021 05:41, Adam D. Ruppe пишет:
> On Thursday, 22 April 2021 at 02:25:29 UTC, Moth wrote:
>> this was an upset, but dealable - it was ugly and long-winded, but i could work around the limitation by using manual getter and setter methods.
> 
> The @property annotation does almost nothing, so you can still do properties without the annotation.
> 
> The only thing @property actually does is change `typeof(obj.prop)` afrom function over to the type it returns.
> 
>> i would much, *much* rather use @property than not.
> 
> Why? What exactly do you need it to do?
> 
> (I myself want property to be fixed but I have a specific list of cases why, so curious what you are thinking of...)

I use @property in my gui, it is really handy to be able to draw all public members and properties of some data structure just passing it to widget using reflection. In other case I would be forced to use yet another attribute, but this attribute wouldn't be so handy because @property is a part of the language. I do not hesitate to use properties in my code and still have no any problem with them, so why not?
April 26, 2021

On Thursday, 22 April 2021 at 07:44:42 UTC, drug wrote:

>

22.04.2021 05:41, Adam D. Ruppe пишет:

>

On Thursday, 22 April 2021 at 02:25:29 UTC, Moth wrote:

>

[...]

The @property annotation does almost nothing, so you can still do properties without the annotation.

The only thing @property actually does is change typeof(obj.prop) afrom function over to the type it returns.

>

[...]

Why? What exactly do you need it to do?

(I myself want property to be fixed but I have a specific list of cases why, so curious what you are thinking of...)

I use @property in my gui, it is really handy to be able to draw all public members and properties of some data structure just passing it to widget using reflection. In other case I would be forced to use yet another attribute, but this attribute wouldn't be so handy because @property is a part of the language. I do not hesitate to use properties in my code and still have no any problem with them, so why not?

Some basic functionalities like prop += 3 / ++prop are not working.

12345swordy tried to fix that in PR #12097, but there's no activity since 3 months so idk.

April 28, 2021
On Thursday, 22 April 2021 at 07:44:42 UTC, drug wrote:
> I use @property in my gui, it is really handy to be able to draw all public members and properties of some data structure just passing it to widget using reflection.

Why public members are not enough for you?
April 28, 2021
28.04.2021 19:39, Kagamin пишет:
> On Thursday, 22 April 2021 at 07:44:42 UTC, drug wrote:
>> I use @property in my gui, it is really handy to be able to draw all public members and properties of some data structure just passing it to widget using reflection.
> 
> Why public members are not enough for you?

I need to visualize my data like debuggers do. I need only state (i.e. fields) and don't need methods. And @property let me mark methods that should be considered as fields.

But it turns out that in non trivial cases I need additional UDAs to control visualization anyway so I can use another UDA instead of @property.
April 29, 2021

On Monday, 26 April 2021 at 18:14:49 UTC, Luhrel wrote:

>

On Thursday, 22 April 2021 at 07:44:42 UTC, drug wrote:

>

22.04.2021 05:41, Adam D. Ruppe пишет:

>

On Thursday, 22 April 2021 at 02:25:29 UTC, Moth wrote:

>

[...]

The @property annotation does almost nothing, so you can still do properties without the annotation.

The only thing @property actually does is change typeof(obj.prop) afrom function over to the type it returns.

>

[...]

Why? What exactly do you need it to do?

(I myself want property to be fixed but I have a specific list of cases why, so curious what you are thinking of...)

I use @property in my gui, it is really handy to be able to draw all public members and properties of some data structure just passing it to widget using reflection. In other case I would be forced to use yet another attribute, but this attribute wouldn't be so handy because @property is a part of the language. I do not hesitate to use properties in my code and still have no any problem with them, so why not?

Some basic functionalities like prop += 3 / ++prop are not working.

12345swordy tried to fix that in PR #12097, but there's no activity since 3 months so idk.

I am still here. It just that I don't have any time for it.
-Alex

April 29, 2021
On Wednesday, 28 April 2021 at 17:00:34 UTC, drug wrote:
> 28.04.2021 19:39, Kagamin пишет:
>> On Thursday, 22 April 2021 at 07:44:42 UTC, drug wrote:
>>> I use @property in my gui, it is really handy to be able to draw all public members and properties of some data structure just passing it to widget using reflection.
>> 
>> Why public members are not enough for you?
>
> I need to visualize my data like debuggers do. I need only state (i.e. fields) and don't need methods. And @property let me mark methods that should be considered as fields.
>
> But it turns out that in non trivial cases I need additional UDAs to control visualization anyway so I can use another UDA instead of @property.

You can do it like this:

int property(T)(T); //for introspection
struct A
{
    int a(int);
    int b();
    int c;
}

A a;
static if(is(typeof(property(a.b)))) {...}