Multiple subtyping with alias this and nested classes

Yigal Chripun yigal100 at gmail.com
Mon Oct 5 22:45:01 PDT 2009


On 06/10/2009 02:15, Andrei Alexandrescu wrote:
> Yigal Chripun wrote:
>>> I think 'alias this' is a powerful feature.
>>>
>>> Given the constraints like "easy for the compiler writer to implement"
>>> and "we have many other things to do", I doubt traits or something
>>> like that will be or needs to be in the language.
>>
>> Alias this is powerful black magic. being powerful doesn't make it any
>> less dark.
>
> So how does this work? Alias this was meant very clearly for allowing
> subtyping. Conversely, using it for subtyping is precisely how it was
> meant to be used. How exactly did you decide it was a hack or black
> magic or whatever?
>
> Andrei

D already has syntax for sub-typing reference types and alias this 
introduces a completely different syntax doing the same for value types 
which is bad human interface IMO.

it also mixes two concepts - sub-typing and opImplicitCast (as i recall, 
this is done by alias this to a function)

we discussed this in the past already and IIRC you agreed with me about 
implementing compile time inheritance for structs which I feel is much 
cleaner and more consistent with the existing syntax of interfaces.



More information about the Digitalmars-d mailing list