Ioannis said:
And again, i would rather see those applications done with non-macro
code if possible.
I think you are missing what I'm getting at. I'm not talking about something
trivial like min/max. I'm also not talking about something that has an obvious
and easy solution as either a macro or a template (or whatever).
As an example, it is certainly possible to define a closure mechanism by
manually (i.e. copy-and-paste) writing a bunch of overloads/specializations with
varying arities--say up to 20 arguments as a maximum. The point is that doing
that is ridiculous when the preprocessor provides the facilities needed to do
that for you. When you make 20 specializations, you introduce 20 (actually
probably some multiple of 20) maintenance points into your source. A slight
step up is to use macros purely to reduce that burden in an isolated way, where
you factor out the things that change into macro arguments (changing arity is
not a good example here without variadic macros). A significant step up, OTOH,
is to generalize the concept of varying repetitions, so that it can be used in
many other places as well.
What it comes down to, is that, fundamentally, you aren't doing anything with
macros that you can't directly write out. So, it isn't a question of whether or
not you can do something without macros (there are only two major categories of
things that you can only do with macros--alternate source blocks in code
subjected to more than one environment and include guards). Even the
stringizing operator (#) is unnecessary for assertions--you can simply rewrite
the expression in quotes. The question than becomes where is it *better* to use
the preprocessor and where it is not? In some cases, the answer is simple, in
others it is not, but in no cases can you apply the generalization "avoid macros
as much as possible" and expect to get the best possible solution in all cases.
It is simply too general. As I said before, you need to break that
generalization down into constituent elements that are actually worthwhile.
Regards,
Paul Mensonides