Boost logo

Boost :

Subject: Re: [boost] painless currying
From: Eric Niebler (eric_at_[hidden])
Date: 2011-08-24 11:02:41


On 8/24/2011 4:28 AM, Thomas Heller wrote:
>
> However, the problem comes with function objects having operator() overloads
> with different arity. Another problem I couldn't solve yet is how to decide
> which overload gets curryied or not.
> Consider:
>
> struct foo
> {
> void operator()(int);
> void operator()(int, int);
> };
>
> curryable<foo> f;
> auto curried = f(1); // To curry or not to curry, that is the question

As soon as enough arguments are collected to call the curried function,
it gets called. So in this case, f(1) calls f::operator()(int).

> TBH, i haven studied your code yet, Eric. would be cool if solvd these
> problems.

I doubt this approach has been tried before. It uses my
is_callable_with_args hack, which is rather obscure.

> Additionally I second the call to integrte it into phoenix. Using bind and
> placeholders is just not elegant enough.
> There even is a feature request about it in trac:
> https://svn.boost.org/trac/boost/ticket/5541

I'm not certain *all* phoenix lambdas should be curryable. That's not to
say they shouldn't -- I'm really not sure.

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com

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