Difference between range `save` and copy constructor
uranuz
neuranuz at gmail.com
Sun Feb 16 14:05:18 UTC 2020
In general for value-semantics and ref-semantics the different
code is actually needed. But generic algorithm try to pretend
that the logic is the same. But it's not true. But in wide subset
of trivial algorithm it's true. So it's incorrectly interpolated
that it's true for every case. The very bad thing if range is
passed by value it still can have value or reference semantic.
And algorithm cannot say which is it actually. There is not such
problemme for classes. So as I already said when passing ranges
by ref in algorithms they behave predictible. And if I want
algrorithm to operate on copy of algorithm then I can just create
this copy before passing it to this algorithm. And again
intention is more clear. But Phobos algorithms don't work like
that. It's why I can't use them in some cases, because they are
looking unpredictable for me.
More information about the Digitalmars-d-learn
mailing list