This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: C++STYLE


On Fri, May 12, 2000 at 04:31:38PM -0400, Phil Edwards wrote:
> > It would be nice if the debate over where to put '*' and '&' could be
> > resolved within a week, for instance. 

Correct placement of "*" and "&" qualifiers was long since resolved: 
they are put next to the type, not the variable name.  The remaining 
issue in declarations is where to put "const", before or after the 
base type name.
 
> Let's recognize that C and C++ are very different languages at many
> different levels, and /not/ start working from the C coding standards.
> Let's start with the conventions of 14882 (which have been informally
> adopted by many of the knowledgeable members of the newsgroups), and
> then add in the most important GNU-isms (e.g., things required by emacs).

I agree that C and C++ call for surprisingy different formatting,
considering the close relationship between the two languages.  
When I write C it looks markedly different from my C++.  Reasons
for the difference arise from:

  - the many more syntactic structures that must be distinguished in C++;
  - the much longer names used in C++ code;
  - the different semantics of C++ statements and declarations.

Furthermore, industry has adopted some near-universal conventions 
that differ from GNU C style.  (It's probably time to reconsider 
the GNU C style standard, but that's somebody else's problem.)  
We benefit from observing industry practice even where that means 
dropping the LISP torch.  This means, for example, that "(" is 
not separated from the function name by a space.  It means that 
function-argument continuation lines aren't indented out to the 
open parenthesis, because there's just not enough room out there
for expressions involving the long names commonly used in C++.

It turns out to be pretty easy to make Emacs indent C++ code
reasonably, by changing just a couple of C++-specific variables.
I'll post a report later today.

Nathan Myers
ncm at cantrip dot org


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]