Boost logo

Boost :

From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2006-01-21 18:30:01


> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]] On Behalf Of AlisdairM

> Tobias Schwinger wrote:
>
> > Anyway: since you seem to have that new compiler installed I would
> > find it interesting to know whether the "tuple testers" in
> the detail
> > directory of Boost.Preprocessor work as expected now (they did not
> > work with older versions of the Borland preprocessor):

Tobias hit the nail on the head here. :) The Borland preprocessor is actually
quite good. In fact, the separate (non-integrated) command-line preprocessor
doesn't have this bug, but until know the integrated preprocessor had a problem
in situations like this:

#define CAT(a, b) PRIMITIVE_CAT(a, b)
#define PRIMITIVE_CAT(a, b) a ## b

#define SPLIT(i, im) PRIMITIVE_CAT(SPLIT_, i)(im)
#define SPLIT_0(a, b) a
#define SPLIT_1(a, b) b

#define IS_NULLARY(x) \
    SPLIT(0, CAT(IS_NULLARY_R_, IS_NULLARY_C x)) \
    /**/ // ^^^^^^^^^^^^^^
#define IS_NULLARY_C() 1
#define IS_NULLARY_R_1 1, ~
#define IS_NULLARY_R_IS_NULLARY_C 0, ~

The Borland preprocessor would "merge" the marked function-like macro name with
whatever follows it. E.g. if 'x' was 'foo', that part would become
'IS_NULLARY_Cfoo'. It is a pretty localized bug and predictable, but it ruins
all sorts of detection idioms. Besides this, the rest of the preprocessor was
pretty good--no major problems with order of evaluation or not doing certain
steps. If this is fixed, than the preprocessor should be able to use the strict
configuration without any problems, because this was the only thing that the
Borland configuration is working around.

There doesn't appear to be a way that I can get my hands on the new
preprocessor, so I can't do more extensive testing. However, if you're willing,
I can give you a stable copy of Chaos (much more advanced), and you can try some
of the more advanced examples in the documentation.

Regarding variadic macros... The pp-lib is not designed to support variadics,
so there is no option to enable such support. Chaos, however, is built from the
ground up to support them. The differences that matter between the current C++
and C99 preprocessors are variadic macros and placemarkers. Placemarkers are a
fancy way of making empty arguments (no preprocessing tokens) work properly with
concatenation and stringizing. E.g.

#define MACRO(x) abc ## x +

MACRO()

Because the argument to 'x' is empty, when MACRO gets expanded, the preprocessor
must substitute 'x' in the replacement list with a placemarker:

abc ## <placemarker> +

So that token-pasting works like it should...

 abc ## <placemarker> +
|____________________|
          |

Rather than:

 abc ## +
|________|
    |

Regards,
Paul Mensonides


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