<div>I'd like public alias x this to reset protection attribute on a (private) member x:</div><div><br></div><div><div>b.d:</div><div>struct B(T){</div><div>    private T x;// would normally prevent alias this from doing anything useful</div>
<div>    public alias x this; </div><div>}</div><div><br></div><div>a.d:</div><div>void main(){</div><div>    auto a=B!int();</div><div>    a++;//should do a.x++; semantic change: even though x is private, public alias x this should behave as if x were public.</div>
<div>    //a.x++ should still be compile error of course.</div><div>    static assert(!__traits(compiles,a.x)); //fails but seems like a bug; I just reported it: 10170</div><div><br></div><div>}</div></div><div><font face="Menlo" style="font-size:small"><font color="#444444"><br>
</font></font></div><div><font face="Menlo"><font color="#444444"><br></font></font></div><div><font face="Menlo"><font color="#444444">(likewise with protected alias this, etc).</font></font></div><div><font face="Menlo"><font color="#444444"><br>
</font></font></div><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">I think this makes sense: </div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
* this allows protection (x is an implementation detail) so that 'this' behaves exactly as 'x'</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
* also, without this change of behavior, "alias x this" would not make much sense in terms of behavior outside the class (inside behavior should just access x directly)</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">Then, when multiple alias this statements will become allowed in D (will it?), we would have implemented something similar to go "embeddings" in GO (see <a href="http://golang.org/doc/effective_go.html">http://golang.org/doc/effective_go.html</a>)</div>
</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
(note, I posted an earlier form of this in <a href="http://forum.dlang.org/post/mailman.97.1369373126.13711.digitalmars-d-learn@puremagic.com">http://forum.dlang.org/post/mailman.97.1369373126.13711.digitalmars-d-learn@puremagic.com</a>)</div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div><br></div>