[Issue 3581] "private" attribute breaks "override"

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 1 00:11:24 PST 2011


http://d.puremagic.com/issues/show_bug.cgi?id=3581


Jonathan M Davis <jmdavisProg at gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg at gmx.com


--- Comment #4 from Jonathan M Davis <jmdavisProg at gmx.com> 2011-03-01 00:08:33 PST ---
See bug# 4542. This issue is a highly debated one. TDPL says that you should be
able to override private (primarily with the idea of using NVI). dmd is not
currently implemented that way - private functions are _never_ virtual. NVI is
highly useful, but it can be essentially done with protected instead of
private, and if you make it so that you can override private methods, then you
can't inline them anymore unless you declare them final. So, you can currently
do NVI - you just have to use protected instead of private - and you get the
higher efficiency of private functions being inlineable, but dmd is not in line
with TDPL. On the other hand, if you make dmd in line with TDPL, then you can
use private for NVI (which is of some benefit conceptually at least - though
not really pratically-speaking), but then private functions are no longer
inlineable, which could be a definite performance hit. I'm not sure that it has
been definitely decided that dmd will be made to match TDPL in this case or if
TDPL will have to be changed. Walter has never said anything on the matter as
far as I recall, and I don't remember what Andrei said (if anything) the last
time it was discussed.

At this point, I'm inclined to say that TDPL should be changed, since I don't
like the idea of losing out on inlineable private functions without having to
mark them all as final, but I don't know what the plan is at this point (if
there even is one). I think that Andrei assumed that private was overridable,
because it is because it is in C++ (though C++ doesn't force everything to be
virtual like D does, so the cost there isn't the same) as oppose to having
discussed it with Walter, but I don't know.

So, it's clear that per TDPL, private should be overridable, but I don't think
that it's clear that TDPL is going to win out on this one. Walter (and possibly
Andrei) need(s) to make a decision here, and I don't know if they've even
discussed it.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list