Confirmed users, Bureaucrats and Sysops emeriti
419
edits
| Line 12: | Line 12: | ||
== Tabs and Spaces == | == Tabs and Spaces == | ||
* Do not add tabs to source files (expand them at 8-space stops if they creep back in). | |||
* Observe the 80-column limit per line, and break down lines that are too long. | |||
* Four spaces of indentation per statement nesting level. | * Four spaces of indentation per statement nesting level. | ||
* | * "case L:" labels in "switch" statements count as half of a nesting level, so indent two spaces, with the labeled statements indenting two more for a standard four spaces indentation from "switch" to a case-controlled statement. | ||
* | switch (discriminant) { | ||
case L1: | |||
DoSomething(); | |||
. . . | |||
} | |||
* Exception: for switches with every case labeling a trivially-short statement it's ok to put the case, the statement, and the break; all on one line. | |||
* Comment /* FALL THROUGH */ in place of missing break when intentionally falling through from one case-controlled statement sequence into another, or into the default statements. | |||
* Do not use spaces between a function name and its arguments list, or between an array name and the square bracket. Also, do no use spaces after a bracket. Use a space after a comma to separate arguments. | * Do not use spaces between a function name and its arguments list, or between an array name and the square bracket. Also, do no use spaces after a bracket. Use a space after a comma to separate arguments. | ||
JS_SetContext ( rt, cx ); // bad | JS_SetContext ( rt, cx ); // bad | ||