<div class="gmail_quote">On 5 January 2012 01:40, Timon Gehr <span dir="ltr"><<a href="mailto:timon.gehr@gmx.ch">timon.gehr@gmx.ch</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 01/05/2012 12:26 AM, Manu wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
You just missed a big discussion on IRC about this, where I think I made<br>
some fair points that people actually agreed with.<br>
<br>
    On 1/4/2012 10:53 AM, Manu wrote:<br>
<br>
        Oh, and virtual-by-default... completely unacceptable for a<br>
        systems language.<br>
          most functions are NOT virtual, and finding the false-virtuals<br>
        while<br>
        optimising will be extremely tedious and time consuming.<br>
<br>
<br>
    The only reason to use classes in D is for polymorphic behavior -<br>
    and that means<br>
    virtual functions. Even so, a class member function will be called<br>
    directly if<br>
    it is private or marked as 'final'.<br>
<br>
<br>
Is this true? Surely the REAL reason to use classes is to allocate using<br>
the GC?<br>
</blockquote>
<br>
You can allocate any type using the GC.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Aren't struct's allocated on the stack, and passed to functions by<br>
value? Do I need to start using the ref keyword to use GC allocated structs?<br>
<br>
</blockquote>
<br>
No.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    An easy way to find functions that are not overridden (what you<br>
    called false virtuals) is to add:<br>
<br>
       final:<br>
<br>
    at the top of your class definition. The compiler will give you<br>
    errors for any functions that need to be virtual.<br>
<br>
    If you don't want polymorphic behavior, use structs instead. Struct<br>
    member<br>
    functions are never virtual.<br>
<br>
<br>
I have never written a class in any language where the ratio of virtual<br>
to non-virtual functions is more than 1:10 or so... requiring that one<br>
explicitly declared the vastly more common case seems crazy.<br>
</blockquote>
<br>
Are you sure that is the case?<br>
In my code, most class member functions are true virtual.<br></blockquote><div><br></div><div>Here's one I'm working on right now (C++).</div><div>Base class for a UI system, surely one of the most heavily polymorphic types of code one can imagine.
</div><div><br></div><div>Count the virtuals... <a href="http://pastebin.com/dLUVvFsL">http://pastebin.com/dLUVvFsL</a></div></div>