On Tuesday, 16 February 2016 at 07:59:49 UTC, w0rp wrote:
Personally, I find this proposal for C++ to be laughable. It's
like hitch hiking from New York to California, and only getting
as far as Texas and calling it good.
The great thing about our UFCS is the left-to-right chaining of
algorithms.
x.map!(...).filter!(...).reduce!(...)
It beats the Hell out of...
reduce!(...)(filter!(...)(map!(...)(x)))
This proposal will encourage non member functions, which is
good, but will never reach the "aha" moment D had which gave us
UFCS chaining.
I agree completely. Form my point of view, UFCS is D's biggest
advantage over C++ (beating CTFE and saner templates). It was the
thing that I hoped for the most in C++17. Alas, we'll be forced
to write onion code. This sucks.
By the way, your example in C++ would be even worse:
auto sum_of_filtered = x
.map([&](auto&& val){ foo(val); })
.filter([](auto&& val){ return is_bar(val); })
.reduce(std::plus<>{});
vs
auto sum_of_filtered =
reduce(filter(map(x, [&](auto&& val){ foo(val); }) ,[](auto&&
val){ return is_bar(val); }), std::plus<>{});
Try adding an additional pass there. Where do you put the comma
and second/third argument?
I have no idea how to indent that properly and creating a myriad
of named temporary variables for no valid reason makes me hurt
inside.