Module-level accessibility

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Oct 5 09:07:21 PDT 2010


On 10/5/10 7:40 CDT, Steven Schveighoffer wrote:
> On Tue, 05 Oct 2010 03:25:03 -0400, Jacob Carlborg <doob at me.com> wrote:
>
>> Who says we need to implement it as g++ does? DMD could implement it
>> to not allow that.
>
>
> The derived class controls everything. You cannot take control away from
> the derived class, it just can't be done:
>
> class A
> {
> private void cantCallMe();
> }
>
> class B : A
> {
> override private void cantCallMe() { butICanCallYou(); }
> private void butICanCallYou() { /* do impl */ }
> }
>
> so far, private virtual functions == annoyance. I haven't seen anything
> to prove otherwise yet.
>
> -Steve

Private overridable functions come with a guarantee that hooks can never 
be called from an unknown/uncontrolled context.

Andrei


More information about the Digitalmars-d mailing list