another properties thread

Kagamin spam at here.lot
Thu Apr 29 15:35:31 UTC 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)))) {...}


More information about the Digitalmars-d mailing list