DIP66 - Multiple alias this

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sat Oct 11 21:31:09 PDT 2014


On 10/11/2014 7:23 AM, IgorStepanov wrote:
> On Saturday, 11 October 2014 at 00:00:48 UTC, Walter Bright wrote:
>> On 10/10/2014 4:23 PM, IgorStepanov wrote:
>>> On Friday, 10 October 2014 at 22:50:25 UTC, Walter Bright wrote:
>>>> must be an error, even if one of C.a() or C.b() might be a "better" match.
>>>> This is how things work for template mixins and imports.
>>> So it is.
>>
>> Good!
>>
>> The same rule applies for overloading.
>
> I've implemented overloading:
> https://github.com/D-Programming-Language/dmd/pull/3998/files#diff-17b22eae29e74ce6ec29037438b5031cR2136
>
>
> Please, tell me, what changes should I make to the DIP as a result of
> yesterday's discussions.

At the very least, it should say it resolves ambiguities the same way that 
imports and template mixins do.


> And please, tell your opinion about "is" issue:
>
> class A
> {
>     int i;
>     alias i this;
> }
>
> class B
> {
>     int i;
>     alias i this;
> }
>
> class C
> {
>     A a;
>     B b;
>     alias a this;
>     alias b this;
> }
>
> void foo(T)(T arg) if(is(T : int))
> {
>     ...
> }
>
> foo(C()); //Should it pass or not?

There's a rule with imports that if the same symbol is reachable via multiple 
paths through the imports, that it is not an ambiguity error. Here, the same 
type is reachable through multiple alias this paths, so by analogy it shouldn't 
be an error.


More information about the Digitalmars-d mailing list