Liste des Groupes | Revenir à cl c |
On Fri, 29 Nov 2024 20:38:51 -0500
James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
>On 11/29/24 19:55, Waldek Hebisch wrote:>
...
>Hmm, in well-written code static functions are likely to be a>
majority. Some people prefer to declare all functions and
put declarations of static functions in the same file as the
functions itself. Conseqently, function declarations are not
rare in such code. Do you consider it well-written?
I wouldn't go so far as to say that it's poorly written, but I don't
like the unnecessary redundancy of that approach. Whenever possible, I
prefer to let each static function's definition serve as it's only
declaration. This isn't possible, for instance, if you have a pair of
mutually recursive functions.
>
The redundancy between a header file's function declaration and the
corresponding function definition is necessary, given the way that C
works. Avoiding that is one of the reasons I like declaring static
functions, where appropriate.
Top-down-minded people don't like details textually preceding "big
picture".
>
[O.T.]
Better solution would be if static function definition anywhere in the
file serves like declaration (prototype) for the whole file, including
preceding part. We are long past the time where single-pass compiler
was a legit argument against such arrangement. Nowadays the only
possible counter argument would be breaking existing code. But I don't
see how such change breaks anything.
Les messages affichés proviennent d'usenet.