Ghosting a language feature

Paul Backus snarwin at
Mon Sep 21 14:08:38 UTC 2020

On Monday, 21 September 2020 at 13:32:16 UTC, 12345swordy wrote:
> If I were you I would mark alias this as a legacy feature, and 
> introduce an dip that introduce implicit conversions in a very 
> restrictive matter so that it could be replace properly.(Or we 
> could think outside the box and introduce extended 
> constructors, to replace the need for implicit conversions)

My guess is that allowing a struct to inherit from another struct 
would cover around 80% of the use-cases for `alias this`. So 
instead of writing

     struct Wrapper(T) {
         T payload;
         alias payload this;
         // etc.
     } could just write:

     struct Wrapper(T) : T {
         // etc.

For other cases where people want implicit conversions, we can 
either add something like implicit constructors/opCast overloads, 
or just tell them to use explicit conversions instead.

More information about the Digitalmars-d mailing list