Skip to content

Code style

Felix W. Dekker edited this page May 31, 2019 · 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.

Indentation

  • 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.

Line length

  • Lines should be limited to 120 columns.
  • Always end the file with a trailing newline.

Spacing

  • Write spaces around operators.
  • Do not write a space before : or ,, and write one space after : or ,.

Capitalisation

  • Units and types should be in Pascal case.
    • This includes Integer, String, and Boolean.
  • Functions and procedures should be in dromedary case.
  • Variables and parameters should be in dromedary case.
  • Keywords (e.g. result, break, and, true) should be in lowercase.
    • The only exception is NULL, which should be in uppercase.

Statements

  • 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, and try.
  • Use a semicolon for the last statement in a compound statement.
  • Place the begin keyword on the same line as the condition.
  • Place the else on the same line as the preceding if's end.

Clone this wiki locally