[Issue 23680] New: Support static classes in D
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Feb 8 10:22:33 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=23680
Issue ID: 23680
Summary: Support static classes in D
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: msnmancini at hotmail.com
D must support the following syntax:
```d
static class Abc
{
void print(){writeln("Print");}
}
```
This should be expanded to:
```d
class Abc
{
@disable this(); static:
void print(){writeln("Print");}
}
```
Rationale:
(This *could* be a DIP, but I don't want it to get hidden from who's developing
the compiler, plus that's a trivial request and I don't want to lost time again
writing useless things)
1: Currently `static class` has no meaning and the compiler simply ignores,
which can surprise a lot of newcomers as it *seems* valid code but it doesn't
seem to work.
2: A lot of people comes from C# and Java to test D and they find it
inexcusable to not have them. D does not have a namespace keyword and that
behavior is not possible to simulate using a single file, so a class must be
used. This should be trivial to implement and would be a beginner friend
feature.
Forum posts:
[1]: https://forum.dlang.org/post/gsangocdehujoonrmyyp@forum.dlang.org
[2]: https://forum.dlang.org/thread/hyjahtzdvxanzvgvpxkl@forum.dlang.org?page=1
Keep in mind that every now and then it appears people trying to do that on the
D discord so this is overlooked all the time.
--
More information about the Digitalmars-d-bugs
mailing list