Consider the following.

struct member
{
    int n;
}

struct outer
{
    member x;
    alias x this;
    alias n2 = n;
}

This does not compile: alias n2 = n;
Error: undefined identifier 'n'

On the other hand if change that into
    alias n2 = x.n;
then it does compile.

void main()
{
    outer o;
    o.n2 = 5;
}

Now this code doesn't compile: o.n2 = 5;
Error: need 'this' for 'n' of type 'int'

Given that one struct inside another is a static situation, this seems unnecessarily strict. It's getting in the way of some name management with `alias this`. What's the rationale here?



Reply via email to