Why is D unpopular

mw mingwu at gmail.com
Mon Jun 13 14:15:25 UTC 2022


On Monday, 13 June 2022 at 14:10:48 UTC, mw wrote:
> On Monday, 13 June 2022 at 13:51:40 UTC, Paul Backus wrote:
>>
>
>> This is necessary because D allows you to define fields with 
>> the same name in a base class and its derived class; for 
>> example:
>>
>
> This is horrifying, one of the darkest corner of D.
>

Maybe it's no way to change the language now, but I need a 
warning message when this happens, in case I accidentally 
redefined such a field, at least with a compiler flag I can check 
it.


>
>> ```
>> class Base
>> {
>>     int x = 123;
>> }
>>
>> class Derived : Base
>> {
>>     int x = 456;
>> }
>>
>> void main()
>> {
>>     auto instance = new Derived;
>>     assert(instance.x == 456);
>>     assert(instance.Base.x == 123);
>> }
>> ```




More information about the Digitalmars-d mailing list