www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: structs, classes, interfaces - Part III, Solution

-----Original Message-----
From: digitalmars-d-bounces puremagic.com 
[mailto:digitalmars-d-bounces puremagic.com] On Behalf Of Reiner Pope
Sent: 04 September 2007 23:34
To: digitalmars-d puremagic.com
Subject: Re: structs, classes, interfaces - Part III, Solution
I think it makes sense in the first place because one of alias's meanings is 
"give the first symbol another name." In the case of "alias B this", you are 
giving B the name, "this". Since all member accesses and member functions are 
of the form
(but the "this." may be omitted) it makes sense that if B gets the name "this", 
then it behaves like a member (as far as calling goes).

I definitely prefer the syntax

struct B : A

instead of

struct B
    A a;
    alias a this; // or any other variant such as A this

I would also like the following to work:

B b;
auto a = cast(A)(b); // syntactic sugar for auto a = b.a;
Sep 05 2007