Multiple alias this, what's the hold up?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Tue Jun 18 22:51:51 UTC 2019


On Tuesday, June 18, 2019 4:08:49 PM MDT Ali Çehreli via Digitalmars-d 
wrote:
> On 06/15/2019 11:08 PM, Walter Bright wrote:
> > On 6/15/2019 6:21 PM, Timon Gehr wrote:
> >> In terms of lookup, the issues with multiple alias this are the same
> >> as the issues with multiple import declarations. Implicit conversions
> >> could use the same lookup rules, but there would need to be a way to
> >> disambiguate. The code in the compiler that implements import
> >> declarations is unlikely to be easily reusable.
> >
> > Multiple alias this is multiple inheritance. Generally, if you find
> > yourself wanting multiple inheritance, it's likely time to rethink the
> > data structures.
>
> Does this mean multiple alias this will never happen?
>
> I would love to remove a section in my book that was added in the hopes
> of seeing this feature "any day now". :)
>
> I like the example I came up with though: A TeachingAssistant class that
> can appear in a Student context as well as in a Teacher context.

It definitely looks like a DIP would be required for multiple alias this-es
to become a thing, and whatever was in the DIP would have to convince Walter
that it doesn't have the problems that multiple inheritance has. Certainly,
it's not simply a matter of someone needing to implement it, which is often
how the issue is portrayed, though a solid implementation could help
convince Walter.

I expect that it's perfectly safe to remove mentioning multiple alias
this-es from your book and that it would give a far more accurate
representation of the state of D. Acting like it's just a matter of time
before multiple alias this-es get added to D would be giving folks the wrong
idea with how things stand. And if someone actually comes up with a proposal
that convinces Walter, it's not like it would be hard to grab what you had
and re-add it with any necessary changes (at least if you have your book in
source control like I would think you would).

Based on some of the discussions on the topic, it seems more likely to me
that alias this will be replaced with some other feature than we'll ever get
the ability to have multiple alias this-es on the same type.

- Jonathan M Davis






More information about the Digitalmars-d mailing list