[Issue 4091] New: Small docs page about dynamic array implementation

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Apr 14 15:05:12 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4091

           Summary: Small docs page about dynamic array implementation
           Product: D
           Version: future
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: www.digitalmars.com
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2010-04-14 15:05:09 PDT ---
I suggest to add a very short page to D docs on the digitalmars site (for
example in the "Articles" section) that explains how dynamic arrays are
implemented and exactly how this data structure works regarding item append
(and maybe why this is the chosen design of arrays instead of other possible
designs, and how it interacts with the current GC).

The purpose of this short text is to help D programmers understand what dynamic
arrays are and why they work this way in their programs.

Often it's not necessary to know how an object manages its inner data, but:
- Dynamic arrays are a basic data structure in D, they are among the most
common data structure in D programs, so they are quite important.
- From what I have seen so far it's quite not intuitive how the current dynamic
arrays work and how they are implemented in the runtime.
- Dynamic arrays, as objects in OOP, are an abstraction. But from what I have
seen so far the current implementation of D dynamic arrays is an abstraction
that leaks a lot (http://en.wikipedia.org/wiki/Leaky_abstraction ), to program
efficiently with arrays you must predict how they behave, but I've seen that
this is hard to do if you don't know how they are implemented.

This HTML page can also contain one or two images with boxes & pointers, to
help the explanation. In case of need I can help in creating such images.

D specs don't need to fully specify how dynamic array append is implemented,
this detail can be left to front-end implementations. So this HTML page is not
part of D specs, it's documentation to help D programmers that use the dmd
front-end.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list