www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4091] New: Small docs page about dynamic array implementation

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs 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: -------
Apr 14 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4091



--- Comment #1 from Sobirari Muhomori <dfj1esp02 sneakemail.com> 2010-04-16
13:19:15 PDT ---
To understand a system programming language "abstraction", OOP and Grady Booch
are not the right way to go :3
Implementation is not abstract, it's concrete.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 16 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4091



--- Comment #2 from bearophile_hugs eml.cc 2010-04-19 01:14:03 PDT ---
I don't understand what your point it.

D dynamic arrays are not simple things, they contain pointers, length, the GC
keeps the length of the allocated memory, they have a capacity and a cache.
They are managed by the GC, so they are not just are chunk of raw memory. So an
append to a D dynamic array is an abstraction, it's an high-level operation.

What I meant to say is that to program in D it's quite important to understand
this specific abstraction. So in my opinion a docs page about them can be
useful.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 19 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4091


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich gmail.com
         Resolution|                            |FIXED


--- Comment #3 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-10-21
20:35:23 PDT ---
We now have this: http://dlang.org/d-array-article.html

If insufficient feel free to reopen and add suggestions.

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