System programming in D (Was: The God Language)

Walter Bright newshound2 at digitalmars.com
Wed Jan 4 15:08:21 PST 2012


On 1/4/2012 10:53 AM, Manu wrote:
> Oh, and virtual-by-default... completely unacceptable for a systems language.
>  most functions are NOT virtual, and finding the false-virtuals while
> optimising will be extremely tedious and time consuming.

The only reason to use classes in D is for polymorphic behavior - and that means
virtual functions. Even so, a class member function will be called directly if
it is private or marked as 'final'.

An easy way to find functions that are not overridden (what you called false 
virtuals) is to add:

    final:

at the top of your class definition. The compiler will give you errors for any 
functions that need to be virtual.

If you don't want polymorphic behavior, use structs instead. Struct member
functions are never virtual.


> Worse, if libraries contain false virtuals, there's good chance I may not be
> able to use said library on certain architectures (PPC, ARM in particular).

??


More information about the Digitalmars-d mailing list