|
Boost : |
Subject: Re: [boost] Case study: Boost.Local versus Boost.Phoenix
From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2011-02-05 09:55:42
Simonson, Lucanus J wrote:
>
> Phil Endecott wrote:
>> The main complaint about that from the advocates of both Pheonix and
>> Local seems to be that it's too far from the point of use.
> It isn't a matter of distance or familiarity, it is a matter of scope.
Right, typically you have to pass-by-reference any local variables that
you need to the functors' constructor. It would often be better to
have automatic access to the content of the local scope. C++0x lambdas
can have that.
With Boost.Local I believe that you still have to explicitly capture
the local variables that you need: (approximate syntax here:)
void my_function()
{
foo_type foo;
bar_type bar;
BOOST_LOCAL_FUNCTION(
(void) (my_lambda) ( (arg_type)(a) (bind)(&foo) (bind)(&bar) )
) { .......
Note the (bind)(&foo) bit.
> If we instead declare the function as a local function it has
> access to the local scope data of the function in which it was declared
If Boost.Local has some way to automatically access variables in the
scope in which it is declared without having to explicitly list them,
that is something that I have missed.
Regards, Phil.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk