On Jan 11, 4:16 pm, Nick Keighley <
[email protected]>
wrote:
spinoza1111wrote:
He didn't want to explain "my" 1990 rule (parenthesize formal
parameters in macro definitions, decide whether to return an
expression or a statement, return nothing else, if you return an
expression return it in its own set of round parentheses, if you
return a statement return the statement list in its own set of braces)
because there might have been counter-examples and the rule is rather
complicated.
There is no sensible rule, simple or complicated, about what macros
return, because macros don't return anything. We covered this already.
How silly. And for years myself and other long term programmers managed
to understand what "the macro returns X" means.
to be fair spinoza seems to be using the term in a slightly different
fashion. he's talking about the textual expansion of the macro. So
#define INC(X) (X + 1)
INC(y);
"returns" (y + 1)
I was going to say that spinoza's usage, though non-standard, was
clear but perhaps it isn't...
In other words, I'm being trashed and you're afraid of being subject
to the same treatment.
no. It's surprising how often "in other words" is used to introduce a
phrase that has a radically different meaning from that which it
replaces (a sort of natural language macro).
I was actually trying to spin your post so it made some sort of sense..
Foolish of me.
Your macro rule para-phrased:-
"parenthesize formal parameters in macro definitions, decide whether
to [expand to] an
expression or a statement, [not anything] else, if you [expand to] an
expression [enclose] it in its own set of round parentheses, if you
[expand to] a statement [enclose] the statement list in its own set of
braces"
this rules out expanding to a complete function (I've done this) or
chunk of code. Your rule is more a rule of thumb; that I've seen