digitalmars.D - another properties thread
- Moth (22/22) Apr 21 2021 hello all. it's been a little while.
- Adam D. Ruppe (8/12) Apr 21 2021 The @property annotation does almost nothing, so you can still do
- drug (7/24) Apr 22 2021 I use @property in my gui, it is really handy to be able to draw all
- Luhrel (6/29) Apr 26 2021 Some basic functionalities like `prop += 3` / `++prop` are not
- 12345swordy (3/33) Apr 29 2021 I am still here. It just that I don't have any time for it.
- Kagamin (2/5) Apr 28 2021 Why public members are not enough for you?
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](https://dlang.org/spec/function.html#property-functions) 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](https://dlang.org/spec/struct.html) - also [uses property](https://github.com/dlang/phobos/blob/master/std/bitmanip.d#L114) 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.
Apr 21 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...)
Apr 21 2021
22.04.2021 05:41, Adam D. Ruppe пишет:On Thursday, 22 April 2021 at 02:25:29 UTC, Moth 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. 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?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...)
Apr 22 2021
On Thursday, 22 April 2021 at 07:44:42 UTC, drug wrote:22.04.2021 05:41, Adam D. Ruppe пишет:Some basic functionalities like `prop += 3` / `++prop` are not working. 12345swordy tried to fix that in PR https://github.com/dlang/dmd/pull/12097), but there's no activity since 3 months so idk.On Thursday, 22 April 2021 at 02:25:29 UTC, Moth 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. 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?[...]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...)
Apr 26 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:I am still here. It just that I don't have any time for it. -Alex22.04.2021 05:41, Adam D. Ruppe пишет:Some basic functionalities like `prop += 3` / `++prop` are not working. 12345swordy tried to fix that in PR https://github.com/dlang/dmd/pull/12097), but there's no activity since 3 months so idk.On Thursday, 22 April 2021 at 02:25:29 UTC, Moth 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. 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?[...]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...)
Apr 29 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?
Apr 28 2021
28.04.2021 19:39, Kagamin пишет:On Thursday, 22 April 2021 at 07:44:42 UTC, drug wrote: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.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?
Apr 28 2021
On Wednesday, 28 April 2021 at 17:00:34 UTC, drug wrote:28.04.2021 19:39, Kagamin пишет: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)))) {...}On Thursday, 22 April 2021 at 07:44:42 UTC, drug wrote: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.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?
Apr 29 2021