|
Boost : |
Subject: Re: [boost] painless currying
From: Eric Niebler (eric_at_[hidden])
Date: 2011-08-24 15:42:09
On 8/24/2011 12:55 PM, Dave Abrahams wrote:
>
> 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++.
Could you explain what you mean by asymmetry here? That my currying code
prefers one function over another based on the available arguments?
> 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.
I'm afraid I don't see your objection.
-- 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