[Issue 12274] New: Add a finalize method for arrays
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Feb 27 17:30:15 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12274
Summary: Add a finalize method for arrays
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: druntime
AssignedTo: nobody at puremagic.com
ReportedBy: rswhite4 at googlemail.com
--- Comment #0 from rswhite4 at googlemail.com 2014-02-27 17:30:12 PST ---
Since dynamic arrays don't call the DTor of their elements (thanks to the silly
GC) _and_ the destroy method don't call them as well (see issue #12256 :
https://d.puremagic.com/issues/show_bug.cgi?id=12256) I suggest to add a
finalize method to object.d. Something like:
----
void finalize(T)(T[] slice) {
static if(is(T == struct) || is(T == class)) {
foreach (ref T value; slice) {
.destroy!(T)(value);
}
}
slice = null; // or: destroy(slice);
}
----
Or we extend the related destroy method with the static if.
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list