This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: patch: morpho ms1-elf support
- From: DJ Delorie <dj at redhat dot com>
- To: kenner at vlsi1 dot ultra dot nyu dot edu
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 5 Jul 2005 21:24:32 -0400
- Subject: Re: patch: morpho ms1-elf support
- References: <10507060103.AA01186@vlsi1.ultra.nyu.edu>
> Right, I was mostly concerned about codifying "all functions must have
> comments" when what we want is "all functions that should have
> comments, have comments". IMHO the former is detrimental to
> maintenance.
>
> Are you talking about comments within the body of the function or in
> front of the function?
In the above quote, I was referring to the block comment preceeding
each function, macro, etc.
> It is an absolute requirement that every function document its
> intention and arguments.
Since for 90% of the functions, that requirement is met with the
existing tm.texi documentation, why ALSO require a block comment?
I don't disagree that functions should be documented. I disagree with
someone making this rule:
It is an absolute requirement that every function have a comment
block before it.
One of my teachers in high school required comments. Not *meaningful*
comments, just *comments*. She got code like this:
i := 0; { set i to 0 }
...because she had the wrong goal in mind when she made the rule (btw
the purpose of 'i' was documented at its declaration).
> Or this, which is self-explanatory (given the target's constraint
> documentation):
>
> int
> m32c_extra_memory_constraint (char c, const char *str ATTRIBUTE_UNUSED)
> {
> return c == 'S';
> }
>
> This could easily use a comment.
/* Our extra memory constraints all start with 'S'. */
Sigh.
> But sometimes you do indeed have a
> bunch of simple functions that are fairly regular. So just put a
> comment saying "in the next group of functions ...".
In my case, that comment is /* Register Classes */
I always try to keep the macros and functions defined in the same
order as the documentation, and in my case I cut and paste the
documentation's section headers into the sources, and name the
functions/macros according to the name used in the documentation
(macro or hook name), hoping to make it very easy for the reader to
find the documentation for each function.
It also saves me a lot of typing.