Pascal Coding Practices
Application skill for classic Pascal style learning (from the archived awesome-guidelines style capsules). For Lazarus/LCL or Delphi VCL/Object Pascal, use delphi-coding-practices instead.
Core Principle
Pascal library quality is dialect-picked layout + ordered units, declare FPC-tight or GPC-spaced style once, mirror interface in implementation, compile warning-clean.
When to Use / NOT
- FPC compiler/RTL patches, GNU Pascal (GPC) code, portable
.pas libraries without Delphi RTL.
- Setting up
fpc -Wall, fpsonar, or project compile checks in CI.
NOT when:
- Lazarus LCL components or Delphi IDE projects, use
delphi-coding-practices.
- Generated
.pas, validate generators.
Workflow
- Layout, indent, begin/end, spacing profile (
pascal-style-formatting-layout.md).
- Naming, keywords, T/P types (
pascal-style-naming-types.md).
- Units, files, order, uses (
pascal-style-units-structure.md).
- Comments/control, braces, flow, CI (
pascal-style-comments-control.md).
- Verify,
fpc -Wall, fpsonar optional, tests on changed units.
Red Flags
- Tab indentation
- UPPERCASE keywords
- Mixed FPC-tight and GPC-spaced styles in one project
if x then begin on one line
- Spaces around operators in FPC compiler tree
- Missing space before
( in GPC published calls
(* *) or // comments in published GPC code
- Function assigns to its name instead of
result (FPC)
- Implicit Result variable against GPC rules
- Multiple units per
.pas file
- Uppercase filenames
- Missing license/header block (GPC)
- Interface/implementation declaration order mismatch
- Unit cycles in interface uses
- Empty unit
begin end.
- Wrong case semicolon in
case before else
- Undocumented interface exports (GPC)
- Macros for constants
- goto/Exit for ordinary control flow
for counter mutation or post-loop reliance
- Commenting out code with
{ … } instead of {$if False}
- Comments inside compiler directives
- FCL-style non-indented routines in FPC compiler tree (or reverse)
Verification
fpc -Wall (and project -O3 if GPC baseline) on changed units
- fpsonar or house linter (NoTabs, LowercaseKeywords, BeginEndRequired)
- Uses-cycle and interface-order review on new units
- Capsule checklist on spacing profile declaration in AGENTS/project docs
References
awesome-guidelines/references/pascal-style-learning-note.md
awesome-guidelines/references/pascal-style-formatting-layout.md
awesome-guidelines/references/pascal-style-naming-types.md
awesome-guidelines/references/pascal-style-units-structure.md
awesome-guidelines/references/pascal-style-comments-control.md
1---2name: pascal-coding-practices3description: Use when authoring or reviewing Free Pascal/GNU Pascal, 2-space/no-tab layout, lowercase keywords, PascalCase T/P types, unit block order, brace comments, result returns, and fpc -Wall or fpsonar in CI.4---56# Pascal Coding Practices78Application skill for classic Pascal style learning (from the archived `awesome-guidelines` style capsules). For Lazarus/LCL or Delphi VCL/Object Pascal, use `delphi-coding-practices` instead.910## Core Principle1112Pascal library quality is **dialect-picked layout + ordered units**, declare FPC-tight or GPC-spaced style once, mirror interface in implementation, compile warning-clean.1314## When to Use / NOT1516- FPC compiler/RTL patches, GNU Pascal (GPC) code, portable `.pas` libraries without Delphi RTL.17- Setting up `fpc -Wall`, fpsonar, or project compile checks in CI.1819**NOT when:**2021- Lazarus LCL components or Delphi IDE projects, use `delphi-coding-practices`.22- Generated `.pas`, validate generators.2324## Workflow25261. **Layout**, indent, begin/end, spacing profile (`pascal-style-formatting-layout.md`).272. **Naming**, keywords, T/P types (`pascal-style-naming-types.md`).283. **Units**, files, order, uses (`pascal-style-units-structure.md`).294. **Comments/control**, braces, flow, CI (`pascal-style-comments-control.md`).305. **Verify**, `fpc -Wall`, fpsonar optional, tests on changed units.3132## Red Flags3334- Tab indentation35- UPPERCASE keywords36- Mixed FPC-tight and GPC-spaced styles in one project37- `if x then begin` on one line38- Spaces around operators in FPC compiler tree39- Missing space before `(` in GPC published calls40- `(* *)` or `//` comments in published GPC code41- Function assigns to its name instead of `result` (FPC)42- Implicit Result variable against GPC rules43- Multiple units per `.pas` file44- Uppercase filenames45- Missing license/header block (GPC)46- Interface/implementation declaration order mismatch47- Unit cycles in interface uses48- Empty unit `begin end.`49- Wrong case semicolon in `case` before `else`50- Undocumented interface exports (GPC)51- Macros for constants52- goto/Exit for ordinary control flow53- `for` counter mutation or post-loop reliance54- Commenting out code with `{ … }` instead of `{$if False}`55- Comments inside compiler directives56- FCL-style non-indented routines in FPC compiler tree (or reverse)5758## Verification5960- `fpc -Wall` (and project `-O3` if GPC baseline) on changed units61- fpsonar or house linter (NoTabs, LowercaseKeywords, BeginEndRequired)62- Uses-cycle and interface-order review on new units63- Capsule checklist on spacing profile declaration in AGENTS/project docs646566## References6768- `awesome-guidelines/references/pascal-style-learning-note.md`69- `awesome-guidelines/references/pascal-style-formatting-layout.md`70- `awesome-guidelines/references/pascal-style-naming-types.md`71- `awesome-guidelines/references/pascal-style-units-structure.md`72- `awesome-guidelines/references/pascal-style-comments-control.md`