[Submission] D Slices
Jonathan M Davis
jmdavisProg at gmx.com
Tue May 31 14:15:00 PDT 2011
On 2011-05-31 13:19, eles wrote:
> == Quote from Ali Çehreli (acehreli at yahoo.com)'s article
>
> > On 05/31/2011 08:10 AM, eles wrote:
> > > I know no other examples where open-right limits are used.
> >
> > The C++ standard library uses open-right with its pairs of
>
> iterators.
>
> > The second iterator "points" at one beyond the last element of the
>
> range.
>
> > Ali
>
> C'mon, if C++ is such a good standard, then D would have never
> appeared. Why not dropping D completely and go to C++ then?
>
> The fact that C++ uses it that way does not making it good for us.
>
> D choose slices, not iterators. Maybe we should remind why it did it
> in the first place.
>
> Now, we are taking the "enemy" (well, is a joke) as a reference in
> the matter?
The fact that C++ does something does not inherently make that choice good or
bad. C++ has both good and bad stuff in it. D tries to take the good stuff and
improve or remove the bad stuff, but ultimately, D has a lot in common with
C++. So, the fact that C++ has a particular feature or behavior says _nothing_
in and of itself as to whether D should have that same feature or behavior.
They must all be taken or left individually on their own merits.
Iterators have a lot going for them. Ranges just take that to the next level.
And whether the right end of a range is open or closed has _nothing_ to do
with why ranges were implemented in Phobos instead of iterators. It was
determined that having the right end be open was desirable, so that's what was
implemented. And honestly, given how fantastic a lot of the STL is, in many
cases, the fact that the STL did it is definitely _not_ a mark against it. The
STL didn't do everything right, and D and Phobos strive to improve upon it by
creating a superior solution, but that doesn't mean that the fact that the STL
has a particular design decision makes it a bad decision - almost the opposite
in fact. But ultimately, all design decisions need to be examined in their own
right and whether a particular language or library made a particular design
decision doesn't in and of itself saying anything about whether that decision
was a good one or not.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list