It is the year 2020: why should I use / learn D?
Eugene Wissner
belka at caraus.de
Wed Nov 14 18:08:31 UTC 2018
On Wednesday, 14 November 2018 at 17:47:10 UTC, Basile B. wrote:
> On Wednesday, 14 November 2018 at 16:09:32 UTC, Eugene Wissner
> wrote:
>> No, it wasn't the reason. Some algorithms cannot be
>> implemented with ranges as efficient as with iterators.
>>
>> "In other words, by converting the is_word_boundary from
>> iterators to D-style ranges, the algorithm goes from O(1) to
>> O(N). From this we draw the following conclusion: D’s choice
>> of algorithmic basis operations is inherently less efficient
>> than C++’s."
>>
>> C++ iterators are more flexible.
>
> You meant D ?
C++. An iterator points to some element in a range, and you can
mix it as you need. In D you always have two iterators: beginning
and the end of the range. The feature I miss most, is a
bidirectional iterator. In C++ you can go back and forth with
this iterator. In D if you do popBack there is no way back (or
front :)); with popFront you can't reach the element after back,
even if there such elements, you have to take an another range
from the container.
D ranges are more compact, because you need the begining and the
end in the most cases, so such functions just take one range
instead of two iterators. But there are still a lot of cases
where D ranges don't work.
Steven Schveighoffer mentioned an interesting solution but it
adds complexity: Implement Range, ConstRange, Cursor,
ConstCursor?, algorithms that accept ranges or cursors and so
forth...
>> I think of things like rotate and bringToFront ...
More information about the Digitalmars-d
mailing list