Multiple alias this, what's the hold up?

rikki cattermole rikki at cattermole.co.nz
Mon Jun 17 16:13:07 UTC 2019


On 18/06/2019 3:58 AM, user1234 wrote:
> On Monday, 17 June 2019 at 13:48:45 UTC, Mike Franklin wrote:
>> I think if we had an `opAssignRight` feature (with friends) we could 
>> move the entire implementation of `alias this` to the library. [...]
>> Mike
> 
> At first glance opAssignRight is a really **brilliant** idea 👍.
> Why do you think that variants would be required ? i += s would work 
> with the single op overload. Maybe it would more be something like
> 
> T opExtractRight(T){}, with T saying what type is involved in the operation
> 
> int i = s  rewritten as  int i = s.opExtractRight!int();
> i += s     rewritten as  i += s.opExtractRight!int();

Oh I like this.
This way it doesn't fight the other operator overloads and can be used 
(with them) only if they fail as-is.


More information about the Digitalmars-d mailing list