Bug 12274 – Add a finalize method for arrays

Status
NEW
Severity
enhancement
Priority
P4
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-02-27T17:30:12Z
Last change time
2024-12-07T13:33:30Z
Assigned to
No Owner
Creator
rswhite4
Moved to GitHub: dmd#17271 →

Comments

Comment #0 by rswhite4 — 2014-02-27T17:30:12Z
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.
Comment #1 by robert.schadek — 2024-12-07T13:33:30Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17271 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB