Sujet : Re: Block Comments Or Rest-Of-Line Comments?
De : 433-929-6894 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 21. Mar 2024, 21:35:33
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240321133230.122@kylheku.com>
References : 1 2 3 4 5
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-03-21, Scott Lurndal <
scott@slp53.sl.home> wrote:
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
Richard Harnden <richard.nospam@gmail.invalid> writes:
[...]
And sometimes, when it's not a really a comment, but rather a block of
code I don't want right now:
>
#ifdef 0
...
#endif
>
I think you mean "#if 0".
>
I use that sometimes, but one disadvantage is that if you're viewing the
middle of a very large block of code, it can be hard to tell that it's
been "commented" out.
>
Often syntax highlighting (e.g. vim) will solve that.
>
In projects with many fingers in the pie, I generally prefer either a
descriptive (and undefined) macro name or a block comment in
the #if 0 region to indicate exactly _why_ it was not just removed
from the source file entirely.
>
Makes it easier for whomever is reading and/or maintaining the
code to follow it.
I have a simpler approach: commits which introduced commented-out
code, whether with #if 0, or any other means, shall not be merged.
I don't perpetrate that in my open source projects, and "-1" such
submissions at work.
When someone wants to remove code, I encourage them to actually
delete it. The comment about why it was deleted goes into the
commit log.
Usually people are relieved; deleting it was what they wanted, but they
weren't sure due the code not being their area or whatever.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca