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: [email protected]
Reporter: [email protected]
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);
}
```
--