From: Dylan Cuthbert (dylan_at_[hidden])
Date: 2002-06-26 00:07:54
I see what you mean - it would probably be more trivial to implement than my
escaped #cmds method. (and hence easier to persuade "those-that-be").
Macros *are* evil, yet sometimes there is just is no solution but to use
them, so when you are forced to use them it would be nice if their feature
set was just that little more complete. They (cpp steering committee?) took
far too long to even implement the "new" __VA_ARGS__ feature, a feature I
have been using in gcc since around 1993.
To bring it back to the boost newsgroup :-) imagine how much simpler the
BOOST_PP_INC/DEC set of macros would be eh?
-- --------------------------------- Q-Games, Dylan Cuthbert. http://www.q-games.com "Paul Mensonides" <pmenso57_at_[hidden]> wrote in message news:001101c21cc8$61fc3230$7772e50c_at_c161550a... > > Hi, > > > > I'd like to be able to assign a macro a new value from within another macro > > definition. Actually, come to think about it, the ability to issue > > "escaped" # pre-processor cmds from within a macro definition would be > > remarkably useful. > > > > Something like: > > > > #define frog "my" > > > > #define APPEND_STRING( arg1, append ) > > \#redefine ###arg1 arg1 append > > > > APPEND_STRING( frog, " dog" ) > > > > would (magically) expand to: > > > > #redefine frog "my" " dog" > > How about this.... > > 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 > > I would *love* to have this feature. It would make it possible to do arithmetic > with the preprocessor in an intuitive way: > > #define X 10 > #define MULTIPLY(a, b) a * b > > #redef X @MULTIPLY(X, 2) > > The preprocessor already knows how to do the arithmetic--it does it in #if/#elif > directives. > > > 1. This is very rough and sketchy and I take no account for the order and > > timing of macro expansion so don't pick it apart on that basis, its *just* > > an outline of a pre-processor feature that I have wanted for mm.. around 10 > > years. > > Unfortunately, many people seem to think that token-mode (as opposed to > syntax-mode) processing is evil. Sometimes people take that argument to far and > ignore the benefits that the preprocessor *can* provide. The main arguments > against the preprocessor are that it doesn't respect syntax, type, and scope. > Personally, I think the preprocessor is useful specifically *because* it doesn't > respect syntax, type, and scope. This is not always a good thing, but there are > times that it is. > > > 2. Obviously, there is no "#redefine" but a little bit of shuffling around > > with #undefs and a temporary define would do the same thing. > > > > The command #redefine would be rather useful - header files are *littered* > > with #undef blah, #define blah's. > > > > Just some outlandish ideas :-) > > Not outlandish to me. :) > > Paul Mensonides > > _______________________________________________ > 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