Boost logo

Boost :

Subject: Re: [boost] Rave for proposed Boost.Local (functions)
From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2011-02-02 06:13:56


Thomas Heller wrote:

> I would be interested in what limitations you ran into using Boost.Lambda
> and if you are aware of the recent efforts that were put into Boost.Phoenix?
>
>> To my mind this example looks a lot clearer if you reformat it as follows:
>>
>> BOOST_LOCAL_FUNCTION(
>> (void) (add)(
>> (double)(num)
>> (const bind)((factor))
>> (bind)((&sum))
>> )
>> ) {
>> sum += factor * num;
>> std::clog<< "Summed: "<< sum<< std::endl;
>> } BOOST_LOCAL_FUNCTION_END(add)
>> add(100.0);
>
> As far is a am concerned, I still find this syntax overly verbose.
> I do realize though that this is just a toy example. For better comparison,
> Here is how the same thing would like in Boost.Phoenix:
>
> boost::function<void(double)> add
> =(
> ref(sum) += factor * _1,
> std::clog << var("Summed: ") << sum << std::endl
> )
> ;
> add(100.0);

> but how are the above examples (both of
> Boost.Local and Boost.Phoenix) not C++ syntax?

Well, to spell out the obvious, the way that the Boost.Local code
terminates statements with ';' while the Pheonix code uses ',' is a
reasonably good example of "normal" vs. "obfuscated" syntax. Then
there is all the replacement of keywords, changing of brackets,
numbered vs. named parameters, and extra bits of fluff like ref() and
bind(). No doubt it seems like second-nature once you are used to it,
but I'd much prefer to use "normal" C++ syntax to write lambdas if I can.

Again, since the future is no doubt C++0x lambdas, should we be trying
to converge towards that? I.e. choosing whatever approach has the
closest syntax to that?

Regards, Phil.


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