Boost logo

Boost :

Subject: Re: [boost] painless currying
From: Simonson, Lucanus J (lucanus.j.simonson_at_[hidden])
Date: 2011-08-24 17:52:24


Peter Dimov 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
>
> 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.

My casting operator suggestion addresses this I think, though there could be something I overlooked.

> 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 was about to suggest a solution to that also, but I wanted to keep my post short. We would need some kind of syntax to enable binding arbitrary function arguments rather than just the first, and ideally more than one at a time as well. I don't think it would be hard to do, but it might be hard to do in a way that is very satisfying. If we could use simply _ as a placeholder argument then it seems like that would be an intuitive and elegant syntax to me. It may well be that the exercise is academic if the end result is no better than bind for the general case. Bind seems to be one of the easier boost libraries for people to pick up and use successfully. Perhaps Eric can expand upon his rationale for not using bind.

Regards,
Luke


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