Boost logo

Boost :

Subject: Re: [boost] Formal Review: Boost.RangeEx
From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2009-02-25 13:22:58


On Wed, Feb 25, 2009 at 7:04 PM, Thorsten Ottosen
<thorsten.ottosen_at_[hidden]> wrote:
> Giovanni Piero Deretta skrev:
>
>> FWIW, I have code like this:
>>
>> total = ( r | filter(_r, f) | map(_r, m) | accumulate(_r, zero, a)  );
>>
>> i.e. I don't have a strong distinction between adaptor and algorithms.
>
> The question is we should have weak or no distinction, or perhaps
> a little strong destinction. I must admit, the code looks nice.
>
> What about something like
>
>  total = r | filter(f) | map(m) -> accumulate(zero, a);
>

how would you make this work (leaving the framework extensible to new
algorithm)? Maybe you meant ->*.

> or
>
>  total = r | filter(f) | map(m) >> accumulate(zero, a);
>

I sort of like the >> syntax (btw, I think that there are functional
languages that use the same syntax for function chaining), but I do
not see the necessity of distinguishing between '|' and '>>'. Just use
one.

> ?
>
> The is a problem when we just want to apply several algorithms:
>
>  boost::erase( cont, boost::unique( boost::sort(cont) ) );
>

I woudn't put many inplace algorithm in the same expression nor
encourage users to do it. The unique->erase idiom is common, on the
other hand sort has little reason being in that expression.

-- 
gpd

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