Why can't we derive struct's?

Walter Bright newshound2 at digitalmars.com
Fri Dec 21 04:09:02 UTC 2018


On 12/20/2018 7:21 PM, Timon Gehr wrote:
> But it's a solved problem. Just make `alias this` exactly like `import`.

Imports don't have adjuster thunks, implicit cast issues, slicing, or empty base 
optimizations. Import lookup in a class is different because of the two-phase 
nature of it (people complained bitterly about the earlier single phase lookup).

Import lookup doesn't have to conform to the relevant undocumented C++ ABI, 
either. (It was about a year of bug reports until I was finally able to match 
Microsoft C++'s MFC behavior for MI struct layout.)

   class C : B {
     B b;
     alias b this;
   }

Now what? (This is not specified in the dlang spec.)


More information about the Digitalmars-d mailing list