Subject: Re: [boost] Review Request: Variadic Macro Data library
From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2011-02-21 14:44:24


On Mon, 21 Feb 2011 13:22:41 -0600, Hartmut Kaiser wrote:

>> #define MACRO(...) [__VA_ARGS__]
>>
>> MACRO() // [<placemarker>] -> []
>> MACRO( ) // [<placemarker>] -> []
>> MACRO(a) // [a]
>> MACRO(a,b) // [a,b]
>> MACRO(a, b) // [a, b]
>> MACRO( a,b, c ) // [ a,b, c ]
>>
>> * Note that I don't know of a single preprocessor that actually handles
>> whitespace correctly in all cases.
>
> Damn, I know I had that right in Wave at some point. Must have broken it
> later... And apparently there are no tests in Wave verifying this is
> functioning as expected.
>
> I'll fix both things asap.

Note that there is only one way that the lack of proper handling can
effect the semantics of a program: stringizing. Further, it must
internal whitespace because stringizing removes leading and trailing
whitespace and condenses adjacent internal whitespace by definition--
which you can get because the normal whitespace condensation happens in
an earlier separate phase:

#define A(x) 1 x 3

A(2) // 1 2 3
A( 2 ) // 1 2 3

When stringized these both result in "1 2 3". However, something like
this is where things change:

#define B(x) (1)x(3)

STRINGIZE(B(3)) // "(1)3(2)"
STRINGIZE(B( 3 )) // "(1) 3 (2)" -- aha! different semantics

Other than scenarios like that, it makes no effective difference.

Regards,
Paul Mensonides