On Thursday, 20 April 2017 at 20:35:04 UTC, Carl Sturtivant wrote:
On Wednesday, 19 April 2017 at 18:32:43 UTC, Carl Sturtivant
wrote:
Imagine the existing single `alias this` is extended to
provide such a heierarchy of lookups. For example,
struct top
{
mem3 m3;
mem2 m2;
mem1 m1;
alias m3, m2, m1 this;
// ...
}
could be interpreted to mean search for a name in m3 if not
found in top, and in m2 if not found in m3 and in m1 if not
found in m2. I don't back the syntax, just the notion.
Maybe that's not all that's expected from "multiple alias
this" but it would be a clean step forward. Issues?
No issues then!
Time for a D I P perhaps.
Comment?
auto x = top(1,2,3);
void takesMember1(member1) {}
void takesMember2(member2) {}
void takesMember3(member3) {}
static assert(__traits(compiles, { takesMember1(x); })); //Passes
static assert(__traits(compiles, { takesMember2(x); })); //Passes
static assert(__traits(compiles, { takesMember3(x); })); //Passes
This is a little bit surprising until you think about it a bit.
It's also how we would want multiple alias this to behave were it
implemented, which is a plus.