Summary: Small docs page about dynamic array implementation
--- Comment #0 from bearophile_h...@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
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------