Multiple alias this, what's the hold up?

Exil Exil at gmall.com
Tue Jun 18 00:58:58 UTC 2019


On Sunday, 16 June 2019 at 22:14:19 UTC, Walter Bright wrote:
> On 6/16/2019 7:39 AM, Timon Gehr wrote:
>> On 16.06.19 08:08, Walter Bright wrote:
>>> Multiple alias this is multiple inheritance.
>> 
>> No. It's multiple imports.
>
> D already has multiple imports with template mixins. If 
> multiple imports is what people want, it's already there.

Isn't there an entire thread arguing for the inclusion of 
*single* inheritance. Not sure how you can say we have multiple 
inheritance without even having inheritance (for structs).

>>> Generally, if you find yourself wanting multiple inheritance, 
>>> it's likely time to rethink the data structures.
>> 
>> Only if your programming language gets MI wrong. C++ gets MI 
>> wrong. This is how to do multiple inheritance: 
>> https://www.eiffel.org/doc/eiffel/ET-_Inheritance
>> 
>> (Ignore the section about covariance. Eiffel gets that part 
>> totally wrong.)
>
> Designing a decent object is hard enough, and most everybody 
> (including me) do a lousy job of it. When people start using 
> MI, the mess becomes incredible. Maybe in another 20 years ago 
> I'll get good enough to be able to write a sensible MI object.

I feel like without virtual functions it isn't really multiple 
inheritance. Alias this is just syntactic sugar so that you don't 
have to specify the variable to use it. Things like the diamond 
problem don't exist because you can't override functions in 
structs. If you have 2 structs and both of them have a struct A 
that is used with "alias this" and then you "alias this" on both 
those structs. Implicitly converting to A would be a compile time 
error. They are not related and the conversion is ambiguous 
between the two. I'd be fine with it simply being too complicated 
to implement, it can be. But saying it is the same thing as 
Multiple Inheritance, and that it shouldn't be implemented 
because it is multiple inheritance. That I don't agree with.




More information about the Digitalmars-d mailing list