From: Thomas Wenisch (twenisch_at_[hidden])
Date: 2002-06-26 09:43:11
Wandering a bit off topic, but interesting nonetheless...
On Tue, 25 Jun 2002, Paul Mensonides wrote:
> If we had a #redef directive and the ability to *evaluate* a macro in the
> definition of a macro--rather than the lazy evaluation that we have now, I think
> that would a much more general solution:
> #define frog "my"
> #define APPEND_STRING( arg1, append ) arg1 append
> // ...
> #redef frog @APPEND_STRING(frog, " dog")
> // ^-- force evaluation at the time of definition
This would also be very nice for local macros. Often times, for
particularly complex macros, and for stuff used with Boost.PP, I will use
a number of "local" macros which are only referred to in the definitions
of other macros. The purpose of these is just to make the "primary" macro
Since the primary macros are used throughout my source,
the local macros also need to be defined everywhere. I would
greatly prefer it if these local macros weren't polluting my macro
"namespace" and potentially colliding with other names and causing the
general havoc that macros can cause.
If we could force early evaluation as Paul describes, I could
#undef all these local macros right after the primary macro definition,
and only my documented primary macro would "pollute" the rest of my code,
but I can keep the readability benefits of using the local macros.
Computer Architecture Lab
Carnegie Mellon University
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk