R
Rick C. Hodgin
Note: I tried to post this a few times. There were errors. I apologize
if it is double- or multi-posted. I do not see it presently, which
is why I am now re-posting it.
Best regards,
Rick C. Hodgin
-----
It doubles your workload. It introduces places where there can be
errors / discrepancies. I ran into two last night. I had something
defined as ** in the prototype, but as * in the function. It had
been some time since I wrote the code so I had to figure out which was
correct. It turned out * was correct, which was the function
definition and the prototype in another file simply was not updated.
And since I had not used that function yet, it was a silent error
that cropped through.
Had I defined it one place it would be right or wrong in one place.
As it is with prototypes one needs a truth table:
Prototype | Function
--------------------
Right | Right
Right | Wrong
Wrong | Right
Wrong | Wrong
If I have only the function definition, which serves also as the
prototype it becomes much easier:
Function
--------
Right
Wrong
Easy to track down. Easy to identify the cause. Errors are a constant,
not a variable. You know things rather than are guessing at things.
It helps the digestion, rather than causing it to become irritated.
And so on.
It's a no brainer, IMHO.
Best regards,
Rick C. Hodgin
if it is double- or multi-posted. I do not see it presently, which
is why I am now re-posting it.
Best regards,
Rick C. Hodgin
-----
I can think of no good reason to use non-prototype declarations
or definitions. (Saving a few characters is not IMHO a good reason.)
It doubles your workload. It introduces places where there can be
errors / discrepancies. I ran into two last night. I had something
defined as ** in the prototype, but as * in the function. It had
been some time since I wrote the code so I had to figure out which was
correct. It turned out * was correct, which was the function
definition and the prototype in another file simply was not updated.
And since I had not used that function yet, it was a silent error
that cropped through.
Had I defined it one place it would be right or wrong in one place.
As it is with prototypes one needs a truth table:
Prototype | Function
--------------------
Right | Right
Right | Wrong
Wrong | Right
Wrong | Wrong
If I have only the function definition, which serves also as the
prototype it becomes much easier:
Function
--------
Right
Wrong
Easy to track down. Easy to identify the cause. Errors are a constant,
not a variable. You know things rather than are guessing at things.
It helps the digestion, rather than causing it to become irritated.
And so on.
It's a no brainer, IMHO.
Best regards,
Rick C. Hodgin