
On 25 August 2011 13:59, Thomas Heller <thom.heller@googlemail.com> wrote:
On Thursday, August 25, 2011 11:16:21 AM Daniel James wrote:
I think explicit partial function calls would be a better fit for C++, i.e.
std::transform(begin(), end, inserter, partial(std::plus<int>(), 10));
It would be clear when you're explicitly calling the function, and when you're not. And the implementation would be considerably simpler. It could support placeholders if you don't like simplicity.
So, what is the difference to bind? Or the old bind1st bind2nd? Or just _1 + 10, or 10 + _1?
When bind receives extra arguments it discards them, when partial receives extra arguments it appends them to the end of the argument list. It's a lot simpler to implement and use than bind. Obviously std::plus isn't the most interesting example since it only ever has two arguments. The name partial comes from partial application: http://en.wikipedia.org/wiki/Partial_application