Sealed classes - would you want them in D? (v2)
KingJoffrey
KingJoffrey at KingJoffrey.com
Sat May 19 04:01:18 UTC 2018
On Friday, 18 May 2018 at 16:24:24 UTC, Gheorghe Gabriel wrote:
> On Friday, 18 May 2018 at 15:57:06 UTC, bachmeier wrote:
>> On Friday, 18 May 2018 at 15:40:52 UTC, KingJo
>>
>> class A {
>> private int x;
>> private(this) int y;
>> }
>>
>
> I agree that this looks a bit strange.
> My initial proposal was "sealed" instead "private(this)" today.
Mmm.. that brings me back to the idea of sealed at the class
level again.
class A
{
private int x;
private(this) int y; // imagine if you have lots of private
variables.
// this could become pretty anoying -
and kinda redundant.
}
class A
{
private int x;
sealed int y; // again, what if you have lots of private
variables that
// that you really want sealed.
}
// Now. Back to the idea of sealed.
// abosolute consistency of your private variables.
// no redundancy.
// no some 'private', some 'sealed' confusion.
// no some 'private' (but really public) some 'private(this) ..
confusion.
//
sealed class A{
private int x;
private int y;
}
downside, is adding a new keyword, and getting agreement on what
that new keyword should be.
So I've come full circle again, and believe my idea is worth
further consideration.
More information about the Digitalmars-d
mailing list