
On Sun, Feb 6, 2011 at 4:02 PM, Dave Abrahams <dave@boostpro.com> wrote:
At Sat, 5 Feb 2011 18:32:06 -0500, Lorenzo Caminiti wrote:
Agreed. I think we discussed the syntax stuff enough.
Well, just one thing I'd like to add: it would be a shame if your Boost library doesn't provide alternate macros usable by anyone who is willing to depend on the C99 preprocessor, that take advantage of variadics.
BOOST_LOCAL_FUNCTION_(...)
anyone?
Hello all, I have reworked Boost.Local macro syntax to take advantage of variadics. The latest code is in the sandbox http://svn.boost.org/svn/boost/sandbox/local/. I still have to update the docs and polish the code but I would like your early feedback. I would also like to hear from people that have used the older syntax so they can compare it with the new one. For example, if variadic macros are supported by your compiler: #include <boost/local/function.hpp> #include <iostream> int main() { double sum = 0.0; int factor = 10; void BOOST_LOCAL_FUNCTION_PARAMS(double num, const bind factor, bind& sum) { sum += factor * num; std::clog << "Summed: " << sum << std::endl; } BOOST_LOCAL_FUNCTION_NAME(add) add(100.0); return 0; } In any case, regardless of varidic macros or not, and for all compilers, the same macros also support this syntax: #include <boost/local/function.hpp> #include <iostream> int main() { double sum = 0.0; int factor = 10; void BOOST_LOCAL_FUNCTION_PARAMS( (double num) (const bind factor) (bind& sum) ) { sum += factor * num; std::clog << "Summed: " << sum << std::endl; } BOOST_LOCAL_FUNCTION_NAME(add) add(100.0); return 0; } The syntax of local exits and blocks also changed accordingly: http://svn.boost.org/svn/boost/sandbox/local/libs/local/doc/html/index.html#... IMO, the new syntax is much simpler and it greatly reduces (and with variadics it completely eliminates) the number of extra parenthesis. This simplification comes to the cost of generality: The new syntax cannot be used as a general syntax to unify the syntax of all macros that spoil function declarations but this is not a requirement for Boost.Local so this lack of generality is not a problem. Many thanks for pushing me in improving Boost.Local syntax and for all your suggestions! -- Lorenzo