|
Boost : |
Subject: Re: [boost] painless currying
From: Dave Abrahams (dave_at_[hidden])
Date: 2011-08-24 12:55:47
on Wed Aug 24 2011, Eric Niebler <eric-AT-boostpro.com> wrote:
> 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).
That's an asymmetry about most currying syntax that I never liked, at
least for C++. I suppose when all functions are fully lazy there's no
assymmetry, but that's not C++. In C++ we have parens to trigger
evaluation. Even in Phoenix, laziness only goes partway: you still need
parens to trigger final evaluation.
-- Dave Abrahams 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