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

Reply via email to