Adding a new design constraint to D

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Tue Jun 14 13:35:13 UTC 2022


On Tuesday, 14 June 2022 at 13:06:02 UTC, Mike Parker wrote:
> Bar has the *public* interface of Foo, true, but it does not 
> have the private one. The private one is internal to Foo, so to 
> get at it through an instance of Bar, then Bar either has to be 
> in the same module as Foo, or you have to convert the instance 
> to a Foo first.

This isn't exactly the end of the universe, but I don't see how 
shadowing public members is better than shadowing private members.

You end up with the same issues. If D was principled about this, 
should it not prevent shadowing of public members?

As it is, "private" in D is more than an access restriction, you 
also change the lookup rules.

(Clearly not the end of the world, as you would typically not 
write such code.)



More information about the Digitalmars-d mailing list