
Phil Endecott wrote:
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.
I never looked at the library. I didn't plan on using it or participating in the review and I'm not sure what problem it is solving with these macros. I was talking about local functions in general. What is wrong with: void my_function() { foo_type foo; bar_type bar; void my_lambda( arg_type a) { ....... Is it that my_lambda isn't allowed to be a template parameter or some other strange restriction on local functions or local functions aren't allowed in template functions? I know there was a linker problem with local functions in header files, which sort of interferes with their use in templates. If the library doesn't allow access to a local variable without passing them to a macro what's the point? I can easily declare a struct with members that reference the local varaibles and construct one then pass it as a functor. Did this guy just do that and wrap it with a macro? Regards, Luke