ElectricalFire Compiler
Coding Style
Author: Scott
Furman
Last Modified:
Editor: This is where we'll add guidelines about what C++ features to avoid
so as to promote portability, how to add documentation, etc. For now, it just
contains some notes about white-space conventions.
Many of the files in ElectricalFire were created before the conventions below
were adopted. Hence, not all EF code is conformant, but we will gradually make
it so.
Tab characters
-
The use of tab characters is discouraged since there is no cross-platform
convention for uniformly displaying files which contain tabs. However,
since some toy editors make it difficult to abstain from using them, tab
characters are not actually forbidden.
-
Tab stops are four character positions apart, i.e. tab stop positions are
0, 4, 8, 12, etc.
Note: this is not the same as saying that tab characters expand to
four spaces.
Indentation
-
When indenting is applicable, code shall be indented four character positions.
This rule applies to the creation of new blocks and to the interior of
switch statements. It doesn't govern the formatting of case labels.
| It is suggested that the following comment be placed as the first line
of all C++ and header files to make it easier for emacs users to follow
the guidelines concerning tabs and indenting:
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil
-*-
| mode:C++ |
Enable editing, formatting, and display aids for C++ |
| tab-width:4 |
Tab stops are four character positions apart |
| c-basic-offset:4 |
When auto-formatting code, indent by four character positions |
| indent-tabs-mode:nil |
Don't insert tab characters. Instead, insert the appropriate
number of spaces when the tab key is pressed.
|
|