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

KingJoffrey KingJoffrey at KingJoffrey.com
Sat May 19 04:36:47 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.

I'm really struggling to come up with any acceptable use case, 
whereby my class would want to have both private and sealed 
variables.( whether the word sealed is used, or private(this) is 
used, is irrelevant to this point though).

Can anyone come up with use case for this code below?

(It may well encourage even poorer software engineering, that 
private morhping into public).

-----
class A
{
    private int x; // ok, really public within the module.
    sealed int y; // now really private within the module.
}
----



More information about the Digitalmars-d mailing list