Subject: Re: [boost] The C++ Post-Processor
From: Christopher Jefferson (chris_at_[hidden])
Date: 2009-10-20 07:07:20
On 20 Oct 2009, at 10:59, Mathias Gaunard wrote:
> Christian Schladetsch wrote:
>> Why has the PP received so little attention over the years, from
>> its early
>> use as M4?
> There is a library around the C preprocessor in Boost,
> Boost.Preprocessor (or Boost.PP, depending on how you want to call
> It allows to do very powerful things and it is the most advanced
> usage of the C preprocessor I've seen.
> It is widely used by most Boost libraries.
However, it is, and I say this in the best possible way, in many
places really really horrible and inefficent. These problems are
caused entirely by a large number of very clever ways of getting
around some crippling limitations of the preprocessor, which is being
pushed far beyond it's original intention.
What kind of things would make using the preprocessor easier, while
keeping all remaining programs valid?
Here's something I've been playing with (on paper) during this
conversation, I'd be interested in what people think.
At first I thought about trying to add extra things fairly directly,
perhaps by adding some special macros which are compiler-defined. I
think now I prefer the idea of adding new types of expressions,
because it's easier to show that these won't interfere with the
existing rules. As an example:
#function defines a simple arithmetic language, for example:
#function f(x,y) x + y + 1
The intention is that such expressions will be evaluated by first
extending any #function or #define macros, and then evaluating the
resulting expression. This would simplify much of the current
Of course, using such a thing would require changing your preprocessor
to be Boost.wave, instead of your compiler's built-in preprocessor.
I've tried doing this in the past as an experiment and it works fine,
but I didn't previously find it a particularly useful thing to do.
>> We have Boost.Wave to start with... Why not give it real
>> Expressions? Loops?
>> Scopes? Classes? Templates? memory management? IO?
> Expressions, loops, scopes can already be done.
> For classes, just use tuples.
> Templates and memory management don't make much sense; IO can be
> done in terms of #warning or something like that.
>> Is there any interest in a Boost.C++ ?
> You mean an implementation of C++, implemented as a post-processor
> over another compiler, that would add new features?
> I believe this could be interesting, but mainly to fix deficiencies
> or to add future standard features not available in compilers yet.
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk