View mode: basic / threaded / horizontal-split · Log in · Help
April 02, 2009
Multiple Alias This
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.
April 02, 2009
Re: Multiple Alias This
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
Top | Discussion index | About this forum | D home