This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Converting GCC to compilation with C++

> Probably the next step in taking this discussion past generalities
> (including the above) which have characterized it so far is for
> someone to propose a detailed set of coding standards.

While I don't advocate requiring a C++ compiler for gcc at this time,
I'd be really happy when that happens.  I've been programming in C++
since cfront 1.0, and here are my opinions about C++ usage, which
boils down to "C with simple and obvious inheritance and overloads".
I prefer C++ features that make the source more obvious, not less.

Note that I offer these just as a reference point, and not as
something I'm interesting in arguing for at this time ;-)

Things to allow

Overloaded functions, *iff* they vary only in parameter type, and not
parameter order/meaning/semantics or function semantics.  Occasionally
replacing a single arg with an arg pair (i.e. buffer class vs
pointer+length), where obvious, on a case by case basis.

Single inheritance, where inheritance is obviously appropriate, with
virtual functions also subject to the above restrictions.

Operator overload only for purely arithmetic types (i.e. arbitrary
length integers, etc).

Simple string buffer type WITHOUT operator overloading (i.e. use plain
methods to access), except for operands corresponding to Pascal string

Declaring variables where they're used in the block, instead of at the
beginning, where such variables are used in a small locality of the

Things to avoid

Multiple inheritance.

Template/envelope classes (makes debugging and following code

Reference counting (it never works simply enough in complex programs).

Overloading except as allowed above, especially overloading that
changes the common semantics of the operator (i.e. "+" should add
numbers, not add objects to a list).

"First class" types that don't correspond to categories of simple

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