Bartosz Milewski seems to like D more than C++ now :)

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Fri Sep 20 08:42:03 PDT 2013


On 20/09/13 17:22, H. S. Teoh wrote:
> Which makes it even more confusing, since newbies would probably equate
> arrays (the container) with ranges from their frequent use in range
> examples.

Yes, it's completely non-obvious.  I think the first time I realized the 
range/container distinction was when I tried experimentally replacing some 
built-in arrays with std.container.Array and discovered that I couldn't use them 
in a foreach loop.

> Perhaps it's more useful to think of T[] not as an array per se, but as
> a *slice* of the underlying array data which is managed by druntime. I
> think I'm OK with saying that arrays (i.e. the underlying data) are
> containers, while slices (what we think of today as "arrays") are
> ranges.

It's not a bad description, but I'm not sure that takes into account the 
const(T[]) case.


More information about the Digitalmars-d mailing list