On Thursday, 6 June 2013 at 17:56:05 UTC, Steven Schveighoffer wrote:
How do you finalize a method with the possibility that a dynamic library will come along and extend that type? Not a rhetorical question, I really want to know if there is a way. Java and C# clearly have more flexibility there, since they are run on a VM.


We are turning around here. You can't.

But it doesn't really matter as the call is already opaque and so it is slow. The impact isn't that big relatively (consider in the code above it was 5% on a statically compiled code).

It is also possible to automatically generate code like :
if (virtualMethod == givenMethod) {
    givenMethod();
} else {
    virtualMethod();
}

It sound like it is completely stupid, but in fact, as the compiler know the call you'll do, it can run optimizations.

But I want to repeat myself once again : trying to fix virtual call to shared object isn't gone change much in regard of performances.

Reply via email to