Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-02-19 09:09:53


Douglas Gregor wrote:
> On Thursday 19 February 2004 08:17 am, Peter Dimov wrote:
>> Douglas Gregor wrote:
>>> On Tuesday 17 February 2004 07:25 pm, Brian McNamara wrote:
>>>> - indirect functoids are imbued with "full functoid" features
>>>
>>> Hmmm, what would this involve? I know that we would need to
>>> implement an operator() that supports currying and an operator[]
>>> that supports the Lambda stuff.
>>
>> I don't agree that function<> should support currying. It can lead to
>> silent and hard to find bugs.
>
> It seems to me that the currying operator() only gets enabled when the
> placeholder '_' or something involving '_' shows up. Assuming we can
> detect those reliably, I don't see the problem. (I'm not supporting
> this on broken compilers, so I'd be perfectly happy to use enable_if
> to do it, if necessary).
>
> Could you give an example of a problem with this?

I have "prefix" currying in mind (the usual theoretical meaning of
"currying", but please correct me if I'm wrong).

    boost::function<void(int, int)> f;

    f(2)(3); // same as f(2, 3)

but note what happens when someone inadvertently omits a trailing argument:

    f(2); // compile-time error now, silent no-op with prefix currying
support

As for f(..., _[k], ...) as a shorthand for bind(f, ..., _k, ...), you can
do this today if you like, this isn't fc++ dependant in any way. Fact of the
matter is that you have not, ergo, there is no user demand, ergo, this
places the feature in the "but wouldn't it be cool if ..." category as far
as I'm concerned.


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