R
Richard Heathfield
(e-mail address removed) said:
Or read the docs. And if it's a function, you don't know what it does unless
you examine the implementation, or read the docs. So you have to do this
anyway.
Sure. So read the docs for MAX.
Read the documentation. Knowing what it is that you're calling - or being
able to find out - is part of being a programmer.
No, by their very nature, programmers are defective and cause defects. They
can cause these defects just as devastatingly in functions as they can in
macros. Indeed, more so, since there are more places to hide a function's
source code (the macro's source has to be visible, to a certain extent, or
the preprocessor won't be able to find it - the same cannot be said of a
function).
Right. And writing bad macros (or calling good macros in a bad way) is worse
than not writing them. That doesn't mean we can't write good macros, and
call them in a good way.
Quibbling over use of the word "use". What I mean is that a programmer who
puts a call to gets() into a program is risk-exposing his program and
potentially any computer system on which it is used.
No, gets() has no safe use (see above).
No. I am saying that you do not know if MAX(a,b) is a macro or a
function unless you examine the implementation.
Or read the docs. And if it's a function, you don't know what it does unless
you examine the implementation, or read the docs. So you have to do this
anyway.
MAX(++a,++b) is prefectly fine if it is a function and we do not know
if it is OK if it is a macro.
Sure. So read the docs for MAX.
The arguments are stupid if it is a macro and not stupid if it is a
function. But you cannot tell which is which unless you see the actual
definition. In a ten million line C project, will you know for sure
which things are macros and which things are functions?
Read the documentation. Knowing what it is that you're calling - or being
able to find out - is part of being a programmer.
By their very nature, function macros are defective and cause defects.
No, by their very nature, programmers are defective and cause defects. They
can cause these defects just as devastatingly in functions as they can in
macros. Indeed, more so, since there are more places to hide a function's
source code (the macro's source has to be visible, to a certain extent, or
the preprocessor won't be able to find it - the same cannot be said of a
function).
Reusing bad software is worse than not reusing it.
Right. And writing bad macros (or calling good macros in a bad way) is worse
than not writing them. That doesn't mean we can't write good macros, and
call them in a good way.
Wrong. It is used safely when you never input more bytes than the size
of the object.
Quibbling over use of the word "use". What I mean is that a programmer who
puts a call to gets() into a program is risk-exposing his program and
potentially any computer system on which it is used.
In a similar way, function macros are fatally flawed. They can be used
safely, but normal use is not safe.
Just like gets() -- only with extreme care.
No, gets() has no safe use (see above).