
He was an enormous help in getting the preprocessing cost associated with Boost.Python under control. In particular, it's important to make good use of the _D, _R, and _Z suffixes described in http://www.boostpro.com/mplbook/preprocessor.html#id6
IMO, the syntax is "bad" but the compile-time overhead is the real barrier for a broader use of the lib. Therefore, improving compilation time (if at all possible) will be a priority right after the 1st Boost release.
The syntax is this way because of trying to support non-compliant preprocessors. If you look at say the `CHAOS_PP_ENUM_PARAMS` macro(from chaos pp), it doesn't deduce the recursion state, because it is not a higher order macro. Instead, it starts at the upper end of the recursion state and moves downward(whereas higher order macros move upward). That is, `CHAOS_PP_ENUM` moves through the recursion state as 1, 2, 3, 4,... etc, but `CHAOS_PP_ENUM_PARAMS` moves through the recursion state as 512, 511, 510, 509,... etc. This is all possible because of the ability to do recursion through deffered expressions. So, `CHAOS_PP_ENUM_PARAMS` doesn't have to rely on `CHAOS_PP_ENUM` to be implemented because its fairly easy to do recursion. Whereas `BOOST_PP_ENUM_PARAMS` relies on `BOOST_PP_ENUM` and thus there is no way to move throught the recursion state differently. Futhermore, working with a compliant preprocessor can improve performance as well, such as, using pp sequences rather pp lists, and better detection and lookup. However, most of these things can work with MSVC although boost doesn't support it. For example, using this macro here to detect parenthesis(which works in MSVC as well): #define IS_PAREN(x) IS_PAREN_CHECK(IS_PAREN_PROBE x) #define IS_PAREN_CHECK(...) IS_PAREN_CHECK_N(__VA_ARGS__,0) #define IS_PAREN_PROBE(...) ~, 1, #ifndef _MSC_VER #define IS_PAREN_CHECK_N(x, n, ...) n #else // MSVC workarounds #define IS_PAREN_CHECK_RES(x) x #define IS_PAREN_CHECK_II(x, n, ...) n #define IS_PAREN_CHECK_I(x) IS_PAREN_CHECK_RES(IS_PAREN_CHECK_II x) #define IS_PAREN_CHECK_N(...) IS_PAREN_CHECK_I((__VA_ARGS__)) #endif You can now detect if a sequence has zero elements or not, like this: #define SEQ_IS_EMPTY(seq) BOOST_PP_NOT(IS_PAREN(seq)) Also, if you want to check if a keyword is `public`, `private`, or `protected`: #define ACCESSOR_public () #define ACCESSOR_private () #define ACCESSOR_protected () #define IS_ACCESSOR(x) IS_PAREN(BOOST_PP_CAT(ACCESSOR_, x)) Which can be much faster than doing three comparisons with three nested if statements.
Thanks, --Lorenzo
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost