multiple alias this

Basile B. b2.temp at gmx.com
Fri Oct 26 02:54:04 UTC 2018


On Friday, 20 July 2018 at 00:26:43 UTC, Mr.Bingo wrote:
> An implementation method:
>
> Single `alias this` already works, this method leverages it to 
> create a multiple `alias this`. This method is presented for a 
> basic review
>
> 1.
>     alias a,b,... this;
>
> Is this proposed syntax used for assigning multiple sinks for 
> the dispatching of access '.' operator. It is also called an 
> `alias this` with multiple implicit for the case of one alias.
>
>     struct X
>     {
>        int a;
>        string s;
>        alias a,s this
>     }
>     X x;
>     void foo(T)(T x);
>
> 2.
>
> Here the compiler chooses which alias works by inference. 
> foo(x) fails because of ambiguity in that it accepts both 
> aliases. The proposed rule is that that an `alias this` must 
> resolve to one and only one alias. This rule allows the 
> original single `alias this` algorithm to work for multiple 
> `alias this` by effectively adding a loop in the testing 
> section of the code(we test for each alias and if only one is 
> successful then success, else failure)

That sounds extremely naive Mr Bingo. You think that because you 
add a comma separated list you can just write a loop on top of 
existing compiler code ? Semantic is much less tied to the syntax 
than you think.


More information about the Digitalmars-d mailing list