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: Coding standards



Since I didn't make these standards up, and since I don't especially
like some of them myself, perhaps this issue should really be
addressed. It is my strong preference not to get into a coding
standards/formatting holy war at this time, but would rather wait till
after the next snapshot, at the very least. 

That being said:


	7) Perhaps the member-init-list should be indented?

Why? And please provide an example. This is what most of the io code
looks like (although not a particularly hairy example):

explicit 
basic_iostream(basic_streambuf<_CharT, _Traits>* __sb)
: __istream_type(__sb), __ostream_type(__sb)
{ }

What's unreadable about this?


	08. Try/Catch blocks

Ditto. Long been mystified by this irregularity.


	9) I disagree strongly.  Declarations are all in one line in
        C, and member function declarations should work the same way.  I
        see that people have been ignoring this rule anyway.

I respectfully disagree with you, out of a frustration trying to get
stuff like this on one line:

  template<class _Traits>
    basic_istream<char,_Traits>&
    operator>>(basic_istream<char,_Traits>& __in, unsigned char* __s)
    { return (__in >> reinterpret_cast<char*>(__s)); }

Believe me, these member function names are HUGE, the argument lists
are long, the return values and types are unwieldy, the inclusion of
templates and having to provide a class-qualified name all end up
requiring some kind of typographical convention beyond what is
established practice in C. I've tried it both ways, and have grown to
prefer the style as outlined in C++STYLE item 9.

I think this way, you can at least scan the class declarations and
quickly see the names of the member functions (as they are all aligned
in the same column) and the return values. I believe this is in the
spirit of the C coding conventions, as referenced on this page:

http://www.gnu.ai.mit.edu/prep/standards_18.html#SEC18

Furthermore, I believe Java has adopted a similar policy. The last
time I talked to Per about this, he seemed to think the current
indentation policy was the sane approach.


-benjamin

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