[Issue 5420] Cannot override function error
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jan 6 18:57:28 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5420
Jonathan M Davis <jmdavisProg at gmx.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jmdavisProg at gmx.com
--- Comment #2 from Jonathan M Davis <jmdavisProg at gmx.com> 2011-01-06 18:55:12 PST ---
As it stands, I don't believe that this is actually an error. All private
functions are non-virtual, and package functions probably are as well.
protected and and public functions _are_ virtual and so can be overridden. It
_is_ true that in C++ you can override private functions, but there is some
debate as to whether you should be allowed to in D. TDPL claims that you can,
which would imply that dmd will have to be changed to make it possible to make
private and package functions virtual (which could actually harm efficiency a
fair bit due to the inability to inline), but there have been definite
arguments against it, since you can essentially use protected in any case where
you'd use private. See bug# 4542.
This is one of those cases where it's not clear whether dmd is going to end up
matching TDPL or whether TDPL will have to be changed in future editions. I
don't believe that Walter has said anything about what he intends to do on the
matter. There have been discussions about this on the newsgroup before.
Personally, I'm rather divided. NVI is definitely useful, but you can pretty
much do it with protected, and it's not clear that private actually buys you
much over using protected. And given that making private virtual would
seriously harm inlining, that would tend to indicate that perhaps TDPL should
be changed rather than dmd. I don't know though, and until Walter decides and
tells us what he decided, we won't know. You might wan to go search the
archives for discussions on the issue though.
--
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