www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12274] New: Add a finalize method for arrays


           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 puremagic.com
        ReportedBy: rswhite4 googlemail.com

--- Comment #0 from rswhite4 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) {

    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: -------
Feb 27 2014