Multiple alias this, what's the hold up?
Mike Franklin
slavo5150 at yahoo.com
Sun Jun 16 09:26:21 UTC 2019
On Saturday, 15 June 2019 at 10:12:46 UTC, Amex wrote:
> How many years has it been in limbo? 1? 2? 3? 5? 10?
>
> What is the hold up?
>
DIP66 is in need of champion. Do you wish to adopt
https://github.com/dlang/dmd/pull/8378 and see it across the
finish line?
But I'm curious. Is there anything that `alias this` can do that
can't be replicated with a mataprogramming library?
Contrived, naive, very incomplete illustration:
```
import std.stdio;
import std.traits;
template AliasThis(alias f)
{
static foreach(m; __traits(allMembers, typeof(f)))
{
mixin(
ReturnType!(__traits(getMember, typeof(f),
m)).stringof
~ " " ~ m ~ "()"
~ "{" ~ __traits(identifier, f) ~ "." ~ m ~ "(); }"
);
}
}
struct Base
{
void print()
{
writeln("Base.print");
}
void print2()
{
writeln("Base.print2");
}
}
struct Base2
{
void print3()
{
writeln("Base2.print3");
}
void print4()
{
writeln("Base2.print4");
}
}
struct Derived
{
Base base;
Base2 base2;
mixin AliasThis!(base);
mixin AliasThis!(base2);
}
void main()
{
Derived d;
d.print();
d.print2();
d.print3();
d.print4();
}
```
Mike
More information about the Digitalmars-d
mailing list