On Saturday, 3 September 2016 at 16:52:50 UTC, Martin Nowak wrote:
On Tuesday, 30 August 2016 at 22:24:12 UTC, Ali Çehreli wrote:
I don't agree with the current solution:

Well let's come up with a better solution then.
Let's start by finding some proper use-cases that require introspection on private members w/o having access to them.

In my user library, the serialization is based on the @Set and @Get UDAs. Typically there would be a setter (a public method) and no getter (i.e the data is read directly either from a protected or private variable).

The introspection is used to create a property descriptor. But because of the protection attributes I have to mix the introspection features (== a template) in each aggregate that declares properties and in each descendant class that declare new properties.



Class Foo
{
    mixin features f; // so that the private stuff are visible

private:
    @Get int _field;
public
    @Set void field(int value){}

    this()
    {f.analyze!Foo;}
}

class Bar: Foo
{
    mixin features f; // so that the private stuff are visible

private:
    @Get int _otherfield;
public
    @Set void otherfield(int value){}

    this()
    {f.analyze!Bar;}
}



while I could do, with the omniscient traits:



Class Foo
{
private:
    @Get int _field;
public
    @Set void field(int value){}

    this(this T)()
    {
        features.analyze!T;
    }
}

Class Bar: Foo
{
private:
    @Get int _otherfield;
public
    @Set void otherfield(int value){}
}

no need to re-mix the features for each derived class...



Reply via email to