Boost logo

Boost :

Subject: Re: [boost] Case study: Boost.Local versus Boost.Phoenix
From: Pierre Morcello (pmorcell-cppfrance_at_[hidden])
Date: 2011-02-04 15:12:53

AM, Hartmut Kaiser wrote: > Just my 2c: I find the proposed macro syntax to be > ugly, unreadable and very difficult to associate with > the corresponding function definition. Gregory Crosswhite wrote: > I thought so at first, but it didn't take very long to get > used to it. Hello, I have written the first implementation of the boost local function a year and a half ago, and later send it to Lorenzo, since he began later to work on the subject too. (Please note that he redid everything completely differently than my first implementation. The current Boost.Local is 100% his work as far as I know). Anyway, I made the first implementation with several different macro frontend, one of the simplest call being : void TestBreakable3::example1() { // USAGE : int i = 0; int j = 0; // Seems easiest way to handle 'This' TestBreakable3* This = this; NESTEDFUNCTION((i)(j)(This)) { ++j; // we manipulate a reference to j // I can add another nested function. NESTEDFUNCTION((i)(j)(This)) { j--; i++; // calling private member is working // (I use defect 45, which has a DR status...) This->otherFunction(j); }NESTEDFUNCTION_END if(i == 1) return; ++i; }NESTEDFUNCTION_END; assert(i == 1); assert(j == 15); } Adding the function name, and making it a functor would have been pretty easy too. As a consequence, concerning the current Boost.Local, adding another macro like BOOST_LOCAL_FUNCTION_AUTO((functionName)(i)(j)(k)) { // do what you want here with i,j,k } BOOST_LOCAL_FUNCTION_AUTO_END(functionName) seems very feasible from my point of view. I wanted to wait later (eg the library review) to see if there were any ouside interest for this auto-macro (not only me), and if I could contribute to this element. BTW I consider that writing a local struct is very easy to read, but with a macro like the one I describe, things are also very straight forwards. This can save time and lines if you use a lot of local functions. Concerning the interest for 'macro for local function', one year and a half ago, a few boosters expressed interest towards it. Some other were not interested for the same reasons already expressed in this thread. So there is no need to feel lonely, whatever your point of view is :-) ! Best regards, Pierre PS : I wanted to thank Gregory Crosswhite for the very detailed examples concerning the differences between boost.local and boost.phoenix. It is very interesting.

Boost list run by bdawes at, gregod at, cpdaniel at, john at