Why is D unpopular

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Mon Jun 13 09:11:42 UTC 2022


On Monday, 13 June 2022 at 09:05:43 UTC, Mike Parker wrote:
> On Monday, 13 June 2022 at 08:49:18 UTC, bauss wrote:
>
>> My argument for why it should work is that if you place the 
>> subclass within the same module then it works, so clearly it's 
>> just a matter of where the function was called, not where it 
>> resides.
>
> I don't get why you expect it to work. If you declare `Bar` 
> outside of the module, then how could you access the private 
> members of `Foo` through a `Bar`? It works in the same module 
> because... private to the module.

It follows from the principles of inheritance. A Bar is a more 
detailed Foo. If you cannot interact with a Bar as you would with 
a Foo, then Bar is breaking with the core principles of 
inheritance. A pointer to Foo, just means that you can assume 
less about it than if you had a pointer to Bar. If you can assume 
more about a pointer to a Foo than a pointer to a Bar then 
something is wrong.



More information about the Digitalmars-d mailing list