System programming in D (Was: The God Language)

Manu turkeyman at gmail.com
Thu Jan 5 01:13:47 PST 2012


>
> The thing I'm most worried about is people forgetting to declare 'final:'
>> on a
>> class, or junior programmers who DON'T declare final, perhaps because
>> they don't
>> understand it, or perhaps because they have 1-2 true-virtuals, and the
>> rest are
>> just defined in the same place... This is DANGEROUS.
>>
>
> It isn't dangerous, it is just less optimal. What is dangerous is (in C++)
> the ability to override a non-virtual function, and the use of non-virtual
> destructors.
>

In 15 years I have never once overridden a non-virtual function, assuming
it was virtual, and wondering why it didn't work... have you?
I've never even heard a story of a colleague, or even on the net of that
ever happening (yes, I'm sure if I google specifically for it, I could find
it, but it's never appeared is an article or such)... but I can point you
at almost daily examples of junior programmers making silly mistakes that
go un-noticed by their seniors. Especially common are mistakes in
declaration where declaration attributes don't change whether the program
builds and works or not.

It seems to me the decision is that of sacrificing a real and common
problem case with frequent and tangible evidence, for the feeling that the
language is defined to do the 'right' thing?


> It's also true that D's design makes it possible for a compiler to make
> direct calls if it is doing whole-program analysis and determines that
> there are no overrides of it.
>

This is only possible with whole program optimisation, and some very crafty
code that may or may not ever be implemented, and certainly isn't
dependable from compiler vendor 'x'.. There would simply be no problem in
the first place if the default was declared the other way around, and the
compiler would need none of that extra code, and there are no problems of
compiler maturity.
Surely this sort of consideration is even more important for an open source
project with a relatively small team like D than it is even for C++?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120105/ad8aec5f/attachment.html>


More information about the Digitalmars-d mailing list