I don't like that "feature" of C.
This feature is found in other languages.
(defun lisp-function (arg)
(incf arg))
It's harder to debug, it's harder to maintain.
This sort of statement is impossible to justify without a lot of
qualifications. Undoubtedly whenever you modify *any* variable, be it
a by-value argument or not, you can create bugs. (Just ask any proponent of
functional languages.)
The trick of destructively manipulating by-value arguemnts keeps
small and simple functions small and simple, where extra variables
might just create clutter.
Everything you add to the function, some maintainer will have to suspect was
done for a significant reason beyond mere style.
It helps to retain sanity.
N
e.g.
int f2(int len, struct foo *fob)
{
...
for (j = 0; j < len; j++)
{
fob->a = fq(...);
fob++;
}
...
for (j = 0; j < len; j++)
{
fob->b = fr(...);
fob++;
}
...
}
Oops!
This function suggests to me that it is two functions combined into one.
Or, possibly, that the separate loop bodies can be combined into a single pass.
If there is no need for two passes, then the above code wastes my time
trying to confirming a suspicion that there have to be two passes,
because I respect the intelligence of the prior coder and assume he or
she did things for a good reason.
Thus if the following is a correct rewrite, then it is better:
for (j = 0; j < len; j++)
{
fob->a = fq(...);
fob->b = fr(...);
fob++;
}