Sealed classes - would you want them in D?

KingJoffrey KingJoffrey at KingJoffrey.com
Wed May 16 06:19:13 UTC 2018


On Wednesday, 16 May 2018 at 06:11:13 UTC, Tobias Müller wrote:
> KingJoffrey <KingJoffrey at KingJoffrey.com> wrote:
>> actually, private is default in Rust.
>> 
>> public is default in D.
>> 
>> also, in Rust, private is private within the module, *and* its 
>> descendants.
>> 
>> I don't believe that is the case in D (someone correct me if 
>> I'm wrong)
>
> The point is, that the module is the abstraction boundary.

Yeah, but "The unit of object encapsulation in D is the class."
  - page 175, The D Programming Language, 2010, Andrei 
Alexandrescu.

They cannot both be true. And this leaves room for confusion for 
new comers to D,
unless they all get to page 200 in time, where it says:

"In all contexts, private has the same power: it restricts symbol 
access to the current module (file). This behavior is unlike that 
in other languages, which limit access to private symbols to the 
current class only. ...  If class-level protection is needed, 
simply put the class in its own file."

Now something like that in the spec I mentioned (on the D 
website), would not do any harm to the spec, would it?



More information about the Digitalmars-d mailing list