On Thursday, 27 April 2017 at 05:41:43 UTC, Daniel N wrote:
On Wednesday, 26 April 2017 at 18:34:48 UTC, Carl Sturtivant wrote:
On Wednesday, 26 April 2017 at 15:00:30 UTC, Steven Schveighoffer wrote:
I think you can appreciate that this doesn't scale. Imagine a case which has 2 or 3 optional alias this items.

-Steve

Agreed, not manually, as it is exponential in the number of conditions.

Image using frameworks which conveniently allow adding features to a struct...

struct Beholder
{
  mixin Entity!Movable;
  mixin Render!"Beholder.png";
}

... then you couldn't even solve it manually without rewriting the framework.

Here's a way to use single hierarchical AliasThis as per this thread without editing vendor code. No special mechanism for name collisions is needed.

// contain arbitrary names from vendors, & do some renaming if desired
struct EntityWrapper(T)
{
    //one hierarchical AliasThis in here (or none)
  mixin Entity!T;
}
struct RenderWrapper(string s)
{
    //one hierarchical AliasThis in here (or none)
  mixin Render!s;
  alias t2 = t; //e.g.
}

struct Beholder
{
  EntityWrapper!Movable entity;
  RenderWrapper!"Beholder.png" render;
    //one hierarchical AliasThis in here
alias entity, render this; //if render.t is shadowed, it gets out as t2
}


Reply via email to