System programming in D (Was: The God Language)
Walter Bright
newshound2 at digitalmars.com
Thu Jan 5 15:45:33 PST 2012
On 1/5/2012 1:58 PM, Manu wrote:
> On 5 January 2012 23:34, Walter Bright <newshound2 at digitalmars.com
> <mailto:newshound2 at digitalmars.com>> wrote:
>
> On 1/5/2012 3:58 AM, Manu wrote:
>
> How is this possible, when all functions are virtual, without whole program
> optimisation?
>
>
> 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).
>
>
> Can you define 'sometimes'?
In C++, it does it if it's a.foo() rather than pa->foo(). In D, it can be done
if flow analysis proves that whatever is calling foo() is really an a, and not
something derived from a. Also, if you qualify the member call with the class
name, it gets called directly, as in a.C.foo().
More information about the Digitalmars-d
mailing list