Hi,
I have one proposal that could make it significantly easier to generate code using the preprocessor. One of the biggest problems in using the preprocessor for generating C or C++ code is that the preprocessor essentially requires
1. parenthesis to be balanced, and
2. commas to be parenthesized,
in order for them to be passed as macro parameters. Consider the following example:
#define ID(x) x ID( ( ) ID( a , b ) ID( ) )
The macro expansion of the above preprocessor code does not produce the intended result:
( a , b )
Although there are tricky ways of avoiding some of these limitations, it makes it significantly more difficult to perform extensive code generation with the preprocessor. My proposal is trivial and should be equally trivial to implement in a C or C++ compiler.
The basic idea is that the keywords '__l_paren__', '__r_paren__' and '__comma__' could be used in place of '(', ')' and ',', respectively. The above example would now become:
#define ID(x) x ID( __l_paren__ ) ID( a __comma__ b ) ID( __r_paren__ )
and it would expand into:
__l_paren__ a __comma__ b __r_paren__
which would be recognized in translation phases after macro replacement as equivalent to the token sequence:
( a , b )
This trivial extension would make it an order of magnitude easier to generate C++ code using the C preprocessor.
A trivial way to put this into standardeze would be to add a translation phase after macro replacement that would convert these alternative tokens to their usual representation.
-Vesa Karvonen
_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost