ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> boost
boost
[boost] ATTN: All Developers Interested in Boost.Preprocessor
by Vesa Karvonen other posts by this author
Apr 30 2003 9:22AM messages near this date
Re: [boost] Threads and mutexes : assign_to error | Re: [boost] Re: ATTN: All Developers Interested in Boost.Preprocessor
[posted and e-mailed]

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
Thread:
Vesa Karvonen
Paul Mensonides
David Abrahams
Rene Rivera
Paul Mensonides
Rene Rivera
Paul Mensonides
Rene Rivera
Paul Mensonides
Rene Rivera
Paul Mensonides
David Abrahams
Beman Dawes
Hartmut Kaiser
David Abrahams
Beman Dawes
David Abrahams

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved