-
Notifications
You must be signed in to change notification settings - Fork 6
Code style
Florine W. Dekker edited this page May 26, 2023
·
14 revisions
The scripts used to generate the dumps are written in a special form of Object Pascal. This article details the style guide used for these scripts.
- Units and types should be in Pascal case.
- This includes
Integer,String, andBoolean.
- This includes
- Functions and procedures should be in dromedary case.
- Variables and parameters should be in dromedary case.
- Keywords (e.g.
result,break,and,true,false) should be in lowercase.- The only exception is
NULL, which should be in uppercase.
- The only exception is
- Documentation
- Each function/procedure must have a Javadoc-ish comment block above it.
- Parameter descriptions should be aligned horizontally.
- Parameter names and their descriptions should be separated by at least two spaces.
- Comments
- Inline comments should be preceded by at least two spaces.
- Inline comments should not be terminated by a period.
- Avoid using non-documentation block comments.
- Avoid using global variables.
- Names of global variables should be prefixed with the originating unit's name and an underscore.
- Indent using 4 spaces.
- Use a continuation indent of 4 spaces.
- When breaking up a line at an operator, place the operator on the second line.
- Lines should be limited to 120 columns.
- Always end the file with a trailing newline.
Always add parentheses when defining or invoking a procedure, even if it takes no arguments.
- Write spaces around operators.
- Do not write a space before
:or,. - Write one space after
:or,.
- Never place multiple statements on one line.
- Declare a function or procedure's first variable on the same line as the
var. - Do not place unnecessary parentheses around conditions.
- Always use compound statements for
if,for,while,repeats,case, andtry. - Use a semicolon for the last statement in a compound statement.
- Place the
beginkeyword on the same line as the condition. - Place the
elseon the same line as the precedingif'send.