Boost logo

Boost :

Subject: Re: [boost] painless currying
From: Daniel James (dnljms_at_[hidden])
Date: 2011-08-25 09:16:02


On 25 August 2011 13:59, Thomas Heller <thom.heller_at_[hidden]> 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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk