[Issue 13155] Disallow final abstract classes

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Jul 18 06:32:03 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13155

--- Comment #2 from Denis Shelomovskij <verylonglogin.reg at gmail.com> ---
(In reply to Sobirari Muhomori from comment #1)
> In C# it's not an error, but a normal idiom when a class should not be
> inherited and instances should not be created.

1. In C# `class` can't be derived as `abstract`, it have to be explicitly
marked so there is no `final class C` problem where reader may expect `C` to
not be abstract.

2. In C# `class` can't be both `sealed` and `abstract` (error CS0418). Also
there is `static` class syntax which ensures all class members are static and
in D it's suggested to use modules with named imports for this purpose.
Note: `static` classes are implemented as `abstract sealed` on IL level, but
it's not visible for the user and is just a workaround for languages without
support for static classes.

--


More information about the Digitalmars-d-bugs mailing list