On Tuesday, 9 April 2013 at 16:49:04 UTC, Manu wrote:final class Foo
final class Foo{ //no inheritance
final: //no virtuals
...
}
2 extra words and you are done. The only problem I see is that there is no
way to "undo" final on a few methods later...
{
final //no virtuals
{
...
}
// final ends, virtual methods below?
....
}
I suppose, OTOH forgetting to make methods virtual can lead to another problem.And any junior/tired/forgetful programmer will
accidentally write slow code all over the place, and nobody will ever have
any idea that they've done it. It's very dangerous.
In general, perhaps we're still talking about the same problem as with how to ensure that portions of code do not contain unwanted features of the language. If you want to ban the use of virtual functions, there ought to be a way to do it easily, same for writing code that does not contain features of the language that require a GC, etc.