Re: [patch] C99 & /usr/share/misc/style

Valery Ushakov <[email protected]>
Newsgroups gmane.os.netbsd.devel.toolchain
Message-ID <Y65GvHWDSICtiH/[email protected]>
On Thu, Dec 29, 2022 at 20:11:43 -0500, Greg Troxel wrote:

> Joseph Koshy <[email protected]> writes:
> 
> > +// C99 single-line comments are allowed.
> > +
> > +// C99 single-line comments can also be used to write longer form
> > +// comments.  Fill these so they look like real paragraphs.
> > +
> >  /*
> >   * Attempt to wrap lines longer than 80 characters appropriately.
> >   * Refer to the examples below for more information.
> 
> 
> I don't like this.  This is C++ creeping into C, and the kernel has been
> C forever (well early 70s).  But more seriously, there is currently one
> way to write comments, and having both C and C++ comments is a mess as
> it will be inconsistent, which is just bad style before you even talk
> about code.  I don't think anyone wants to mass edit /* to //.

I don't think this is what is being proposed (cf. "allowed").

Given 80 character width limit and (imho - ridiculously large :) 8
column indent, we are kinda starved on space, so a traling // comment
at the end of a line saves 3 characters (" */").

I'm not a big fan of column-0 // comments, b/c they tend to be less
visually distinct w.r.t. to the stuff that follows.  I.e. I find this:

/*
 * This is a function that does some interesting stuff.  Please see
 * also some other function that is its counterpart
 */
int
foo()
{ ...
}

To be more readable than this:

// This is a function that does some interesting stuff.  Please see
// also some other function that is its counterpart
int
foo()
{ ...
}

and in this case // doesn't provide any width savings either.

This tends to flip for indented multiline comments, where /**/ stand
out too much for me.

I think "allowed" plus some taste and common sense (which you cannot
legalize no matter how you try) can go a long way :).


-uwe
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.