Sealed classes - would you want them in D? (v2)

Zoadian no at no.no
Thu May 17 10:34:18 UTC 2018


On Thursday, 17 May 2018 at 02:32:07 UTC, KingJoffrey wrote:
> I propose an idea, for discussion (robust discussion even 
> better ;-)
>
> Add an new attribute to class, named 'sealed'.

If class level protection is added, please do not call it sealed.
People from c++ might be suprised by 'private' already. We do not 
have to confuse those c#ies too.

Module level protection is enough to hide implementation details 
though. So while i do understand why you want this in D, i don't 
think it is worth it to complicate the language for something you 
can work around easily by putting the classes in their own 
modules.
I'm also not convinced think that your 'sealed' would be used 
much, because accessing private state in the module is actually 
extremly useful (e.g. unittests).

That beeing said, if you are convinced it would be a good 
addition, please write a DIP.
Even if it will not be accepted it will at least force a 
decision. And we can point to the reasons it got 
accepted/rejected in the future.


More information about the Digitalmars-d mailing list