On 5 January 2012 23:34, Walter Bright <span dir="ltr"><<a href="mailto:newshound2@digitalmars.com">newshound2@digitalmars.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 1/5/2012 3:58 AM, Manu wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
How is this possible, when all functions are virtual, without whole program<br>
optimisation?<br>
</blockquote>
<br></div>
Only public non-final class member functions are virtual. Furthermore, as in C++, the compiler can sometimes determine that a virtual function is being called directly, and will do so (or inline it).<br>
</blockquote></div><div><br></div>Can you define 'sometimes'? I have trouble believing that this will occur very often. The stars aligning to that level of precision seems totally unreliable.<div><br><div>Consider the UI code snippet I posted earlier (I've lost the link), most functions are public and not virtual (mostly accessors, or fairly simple mutators), and they could only be identified to be not-overridden with whole program optimisation...</div>
<div>The fact you mention potential for inline-ing actually heightens my criticism with another detail I hadn't considered ;) ... Now all my trivial methods won't only be virtual-called, they won't be inlined either!</div>
</div><div><br></div><div>I'm genuinely scared of people forgetting to type final (including myself)... And it's hard as an external coder to go and clean up too. Adding final blocks to someone elses existing code, you don't necessarily know what is truly virtual or not... *mumble mumble*</div>