www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Multiple Alias This

reply dsimcha <dsimcha yahoo.com> writes:
Is the limitation that one may only have one alias this per class/struct a
temporary limitation that will be removed once higher-priority stuff is
finished and some ambiguities are resolved, or are things likely to stay this
way?  On the one hand, allowing multiple alias this would cause ambiguities
similar to multiple inheritance.  On the other hand, only being able to define
one implicit cast per class/struct is pretty limiting and allowing only one
alias this seems like a huge cop-out.
Apr 02 2009
parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
dsimcha wrote:
 Is the limitation that one may only have one alias this per class/struct a
 temporary limitation that will be removed once higher-priority stuff is
 finished and some ambiguities are resolved, or are things likely to stay this
 way?  On the one hand, allowing multiple alias this would cause ambiguities
 similar to multiple inheritance.  On the other hand, only being able to define
 one implicit cast per class/struct is pretty limiting and allowing only one
 alias this seems like a huge cop-out.

Yah, it's a temporary limitation. However, removing it is nontrivial. D tries to avoid first-fit rules and best-fit is difficult. Note that if you have control over the types you can implement a sort of a first-fit by distributing the "alias this" declaration to each type. (This is very clumsy.) Andrei
Apr 02 2009