Ranges and Take
Jacob via Digitalmars-d
digitalmars-d at puremagic.com
Tue Oct 4 07:22:51 PDT 2016
Currently some implementations rely on the struct Take from
std.range to obtain certain functionality. I think this is a bit
flawed, as it isn't generic enough. As such you end being locked
to this "Take" structure. Which means you can't define your own
implementation if needed.
https://github.com/dlang/phobos/blob/v2.071.2/std/container/dlist.d#L649
It is used here in DList in "linearRemove". There is a function
"tail" which implements getting a range for the last few
elements. But it is a bit inefficient as it first has to go
through every single element from the front. At least in the case
of a linked list. So maybe I want to implement my own "TailTake",
that now means defining a new overload for "linearRemove" in
DList. Then not only that there are already other functions in
std.range that do define their on constructs, "takeOne()" for
example does this. So that function can't be used with DList, and
so forth.
More information about the Digitalmars-d
mailing list