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

KingJoffrey KingJoffrey at KingJoffrey.com
Fri May 18 12:29:40 UTC 2018


On Friday, 18 May 2018 at 12:00:58 UTC, Gheorghe Gabriel wrote:
>
> I think this code has cleaner sintax:
>
> class A {
>     private int x;
>     sealed int y;
> }
> void main() {
>     A a = new A();
>     a.x = 7; // ok, it's private to module
>     a.y = 3; // error, it's sealed to class
> }

I agree. I actually like your solution much better, and, it's 
less likely to cause confusion with use of the word 'sealed', 
because it's applied to the variable (and therefore people from 
other languages won't get confused having sealed applied at the 
class level - unless there are languages that applye sealed at 
the variable level).

Now, you write that DIP (that everyone will ignore).


More information about the Digitalmars-d mailing list