multiple `alias this` suggestion

Carl Sturtivant via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 26 07:38:49 PDT 2017


On Monday, 24 April 2017 at 16:52:49 UTC, Carl Sturtivant wrote:
> On Friday, 21 April 2017 at 14:55:31 UTC, Steven Schveighoffer 
> wrote:
>> I agree, I like how this solves the ambiguity problem nicely. 
>> However, this disallows using introspection to declare 
>> multiple alias this piecemeal. e.g.:
>>
>> struct S(bool foo)
>> {
>>   int x;
>>   alias x this;
>>   static if(foo)
>>   {
>>      string y;
>>      alias y this;
>>   }
>> }
>>
>> One thing we can do also is just use declaration order to 
>> prioritize which alias this to use.
>
> Not necessary in this case:
>
> struct S(bool foo)
> {
>   int x;
>   static if(!foo)
>   {
>      alias x this;
>   }
>   else
>   {
>      string y;
>      alias x, y this;
>   }
> }
>
> It's easier to analyze if  isn't distributed, i.e. if only one 
> location applies.

It's easier to analyze if AliasThis isn't distributed, i.e. if 
only one location appears in a given instantiation.





More information about the Digitalmars-d mailing list