virtual, package, private

Robert jfanatiker at gmx.at
Tue Jun 18 00:14:57 PDT 2013


Hi guys!

Why are package/private methods non virtual? This just hit me in a
project, is there any good reason for this? (I know this came up before,
but I can't remember any good answer.)

With module-level-private access virtual private methods absolutely make
sense, for a package even more.

Secondly I followed the virtual by default thread quite in detail and
got convinced that non virtual by default would really be better and I
am tempted all the time to mark my methods virtual, but I can't :-(

It seems that Walter also got convinced and to some degree even Andrei,
so if we really want to do this, we should do it soon. Reasoning: The
related change with required override, just happened (user visible) and
for people fixing their code it would be easiest to fix both at the same
time. It is not necessarily less work, but at least less annoying if you
can do it in one run.

With an explicit virtual keyword, private and package methods could then
also be made virtual.

Just my two cents :-)

Best regards,

Robert




More information about the Digitalmars-d mailing list