DIP66 v1.1 (Multiple) alias this.
Daniel N via Digitalmars-d
digitalmars-d at puremagic.com
Fri Dec 26 10:53:45 PST 2014
On Wednesday, 24 December 2014 at 22:09:49 UTC, Andrei
Alexandrescu wrote:
> Is there a need for explicit overriding, i.e. any inadvertent
> error people may make without it? -- Andrei
I failed to find any dangerous refactoring sequences, so it might
be superfluous, however I found another minor issue, see below.
Anyway considering the new ways of working, when using the -dip
switch for the initial few releases, there is ample time to
perfect all details.
// Example 1
struct A {int i;alias i this;}
struct Z
{
A a;
alias a this;
}
// A is preferred since it requires only one implicit conversion.
void process(A) {}
void process(int) {}
// Example 2
struct A {int i;alias i this;}
struct B {int i;alias i this;}
struct Z
{
A a;
B b;
alias a this;
alias b this;
alias a.i this;
}
// The below is now ambiguous because Z is directly convertible
to 'int' although we only intended to disambiguate between
Z->A->int and Z->B->int
void process(A) {}
void process(int) {}
More information about the Digitalmars-d
mailing list