DIP66 - Multiple alias this

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Tue Oct 14 19:46:04 PDT 2014


On Tuesday, 14 October 2014 at 12:33:50 UTC, IgorStepanov wrote:
> This code tell that C is subtype of A and C is subtype of B.
> User can use this fact in his code:
> void foo(B);
>
> C c = new C;
> foo(c); //Ok.
> Of course, we shouldn't allow user to cast c to int:
> int i = c; //wrong
> However, user can explicitly cast c to his subtype, which is 
> convertable to int:
> int i = cast(B)c; //Ok
> Summarizing, I disagree with suggestion disallow this code at 
> type semantic stage.

I agree. It will also make possible to break already working 
disambugation of `foo(c)` kind but adding new `alias this` to one 
of subtypes independently. That sounds annoying.


More information about the Digitalmars-d mailing list