DIP66 v1.1 (Multiple) alias this.

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Sun Dec 21 00:23:32 PST 2014


On Saturday, 20 December 2014 at 23:22:40 UTC, Joseph Rushton 
Wakeling via Digitalmars-d wrote:
> On 02/11/14 15:55, IgorStepanov via Digitalmars-d wrote:
>> http://wiki.dlang.org/DIP66
>>
>> I've applied some changes to it, however there are still some 
>> unresolved questions.
>
> The current DIP doesn't address protection attributes.  I 
> recognize this might be somewhat orthogonal, but it'd be nice 
> to build it into the DIP if possible, just to be explicit about 
> what is expected for how alias this should work.
>
> According to TDPL the following should work:
>
>     struct Foo
>     {
>         private T internal_;         // member variable is 
> private
>
>         public alias internal_ this; // .. but can be 
> interacted with
>                                      // via the public alias
>     }
>
> It seems to me an important factor, because it means that 
> classes and structs can use subtyping without revealing the 
> implementation details.  As things are, you wind up having to 
> do something like,
>
>     struct Integer
>     {
>         private int i_;
>
>         public ref int getInteger() @property
>         {
>             return i_;
>         }
>
>         alias getInteger this;
>     }
>
> ... which personally I find a bit of an unpleasant violation of 
> the idea of a private implementation.
>
> See also: https://issues.dlang.org/show_bug.cgi?id=10996

I have nothing against this, but this is, indeed, completely out 
of the scope (!) of the DIP.


More information about the Digitalmars-d mailing list