Sealed classes - would you want them in D?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Mon May 14 07:59:06 UTC 2018


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; }
> > of encapsulation
> > void foo() { static int i = 1; }
> > ------------
>
> meant
>
> ------------
> 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. I don't think
that providing access to symbols inside functions like that wouldn really
buy us anything. In addition, we rely on function encapsulation for
Voldemort types, and the rules for local variables and types are a bit
special anyway. Trying to treat them as if they were at the module-level but
namespaced by the function seems like it would be complicating things
considerably for no real benefit.

- Jonathan M Davis



More information about the Digitalmars-d mailing list