digitalmars.D.bugs - [Issue 24046] New: static destructors should be allowed in function
- d-bugmail puremagic.com (30/30) Jul 13 2023 https://issues.dlang.org/show_bug.cgi?id=24046
https://issues.dlang.org/show_bug.cgi?id=24046 Issue ID: 24046 Summary: static destructors should be allowed in function bodies Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: b2.temp gmx.com Here is why : as we can hide static variables in function bodies there should be a way to cleanup them. A way to do that would be to allow local static destructors, for example ```d struct S { } S getS() { static S result; static ~this() // run when the program finishes { destroy(result); } return result ? result : (result = new S); } ``` --
Jul 13 2023