Boost logo

Boost :

Subject: Re: [boost] painless currying
From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2011-08-26 09:51:14


On Thu, Aug 25, 2011 at 6:21 PM, Eric Niebler <eric_at_[hidden]> wrote:
> On 8/24/2011 6:15 PM, Dave Abrahams wrote:
>>
>> on Wed Aug 24 2011, "Peter Dimov" <pdimov-AT-pdimov.com> wrote:
>>
>>> Dave Abrahams wrote:
>>>
>>>> I suppose the symmetrical non-lazy version looks like:
>>>>
>>>>   f(x) => doesn't call f
>>>>   f(x)(y) => doesn't call f
>>>>   f(x)(y)(z) => doesn't call f
>>>>   f(x)(y)(z)() => calls f
>
> I simply don't see the problem with:
>
> f(x) ==> curry
> f(x, y) or f(x)(y) ==> curry
> f(x, y, z) or etc. ==> evaluate
>
> Can you say specifically what you think the problem is? This is how its
> done in Haskell, for instance (although Haskell doesn't use parens
> around argument lists).
>
>>> This allows you to express bind( f, x, y, z ), which was impossible
>>> before, but you've now lost the capability to express bind( f, x, y,
>>> _1 ), which was.
>>>
>>> bind( f, _1, y, z ), which is often needed in practice, is possible
>>> under neither, which makes me view this whole exercise as somewhat
>>> academic.
>
> I don't see any technical obstacles to:
>
> f(_, y, z)
>
> where _ is a placeholder. You could use positional placeholders for
> argument reordering.

I'm a big fan of this syntax!

+1 for both implicit currying and _ placeholders!

-- 
gpd

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