Sealed classes - would you want them in D?

Dukc ajieskola at gmail.com
Mon May 14 15:28:17 UTC 2018


On Monday, 14 May 2018 at 07:59:06 UTC, Jonathan M Davis wrote:
> On Monday, May 14, 2018 07:03:35 Dukc via Digitalmars-d wrote:
>> On Monday, 14 May 2018 at 07:02:37 UTC, Dukc wrote:
>> ------------
>> module test;
>> void main() { foo.i = 2; }
>> void foo() { static int i = 1; }
>> ------------
>
> If that's what you want, just make it a module-level variable.

Well, personally I don't care much because using static mutables 
sucks anyway, and there is rarely a reason to make static 
immutables just for one function. Enums are for that.

Just pointed out that it would be consistent with how classes 
encapsulate stuff. And the same point goes for eponymous 
templates, of course.


More information about the Digitalmars-d mailing list