[Article Contest, first draft] D Slices

Jonathan M Davis jmdavisProg at gmx.com
Sun May 22 19:46:13 PDT 2011


On 2011-05-18 11:03, Steven Schveighoffer wrote:
> Having seen quite a few incorrect descriptions of how D slices work
> (particularly regarding appending), I wrote an article that tries to
> describe how D slices work, and why they behave the way they do.
> 
> Being one of the only places where I have web space, it's on my
> dcollections site, I probably will move it to the D wiki eventually, but
> I'm much more familiar with the Trac wiki syntax.
> 
> Please, if you have any comments or recommendations, let me know.  I
> certainly am no author, so I probably screwed a few things up :)
> 
> http://www.dsource.org/projects/dcollections/wiki/ArrayArticle

Finally got around to reading it. Definitely a good article. I even learned a 
few things from it (primarily surrounding implementation details). I am a bit 
surprised that you never mentioned that a slice is essentially struct with the 
a C style array pointer and the length of the slice (particularly since that 
helps to explain why passing an array without ref means that altering the 
slice rather than its elements doesn't alter the array that was passed in), 
but it still works quite well without that. A couple of total nitpicks would 
be that the first sentence should say "...is its implementation..." rather 
than using "are", and the title "A Slice You Can Append On" should be "A Slice 
You Can Append To." But as those just nitpicky grammar issues. Overall, it's 
very good and definitely something that D programmers (especially newbies) 
should read. Dynamic arrays and slices throw them off too often.

- Jonathan M Davis


More information about the Digitalmars-d mailing list