Boost logo

Boost :

From: Vesa Karvonen (vesa_karvonen_at_[hidden])
Date: 2002-04-04 01:32:36


Aleksey Gurtovoy:
>David Abrahams wrote:
>>It's not what I'm after. I want the standard release to contain
>>debuggable, expanded code for the commonly-used low-repetition cases
>>(without the need for special user configuration), and for higher
>>repetition counts I would like to use the PP lib.
>
>I guess I failed to explain my suggestion properly :). Here is another try:
>
>[my_header.hpp]
> #include "my_library/preprocessor.hpp"
>
> #if !defined(BOOST_MY_LIBRARY_GENERATOR_MODE)
> # include "my_library/preprocessed/my_header.hpp"
> # define BOOST_MY_LIBRARY_REPETITION_START 5
> # define BOOST_MY_LIBRARY_REPETITION_END 15
> #else
> # define BOOST_MY_LIBRARY_REPETITION_START 0
> # define BOOST_MY_LIBRARY_REPETITION_END 5
> #endif

Hmm... That is an ingenious idea. Let me get this one more time. The
requirements are:
- debuggable code for low repetition cases from 0 to D
- generated code for high repetition cases from D to N
- ability to verify the correctness of both debuggable and generated code

Here is a refinement of the header template:

  #ifndef INCLUDE_GUARD
  #define INCLUDE_GUARD

  // Always include macro definition headers.
  #include <macro definition headers required>

  #ifndef GENERATE

  // Add any code here not generated, including:
  // - #includes for normal headers required by the code
  // - definitions that are not generated

  // Include the nicely formatted debuggable cases.
  #include <debuggable_cases>

  #define GENERATOR_START D
  #define GENERATOR_END N
  #else
  #define GENERATOR_START 0
  #define GENERATOR_END D
  #endif

  // Macros generating code from GENERATOR_START to GENERATOR_END

  #endif

When the above header is normally included:
- the header includes the debuggable cases from 0 to D from a pregenerated
and formatted header, and
- then generates the cases from D to N using macros.
When the GENERATE macro is defined:
- the header simply generates cases from 0 to D.

In order to generate the debuggable cases, while (re)installing the library,
you do something like this:

  cpp -DGENERATE header | cpp_pretty_print > debuggable_cases

No code is actually duplicated. All we now need is the cpp_pretty_print
utility.

>P.S. Just in case if you want to try the above, here is
>BOOST_MY_LIBRARY_PP_REPEAT_FROM_TO macro definition:
[...]

I think that a variation of this macro (namely with the extra parameter as
it enables composition) might be worth including in the preprocessor
library:

  BOOST_PP_REPEAT_FROM_TO(S,E,M,P)

Actually, I think there should be one for each repeat dimension. What do you
think?

_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail.
http://www.hotmail.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk