6. Procedures and rules (pocket version)

TL;DR (5 lines)

  • A procedure is a full contract, not just a named block.
  • The signature and the result shape belong together.
  • Branch logic should remain visible inside the procedure.
  • Broken procedures usually hide a missing contract part.
  • A good example is small but complete.

Concrete Problem

Procedure chapters often explain signatures and bodies separately, so readers miss how a complete procedure contract works.

Coherent example

space demo/procedures

proc normalize_score(raw: int) -> int {
  if raw < 0 { give 0 }
  if raw > 100 { give 100 }
  give raw
}

Global explanation

A procedure chapter should teach one stable idea: the signature, the branch logic, and the returned result are one contract. The reader should not have to infer what comes back from the procedure.

Short exercise

Add one extra input parameter and keep the procedure contract as readable as before.

Next best action

Keep the example small, reproduce it locally, then continue to the full chapter if you need the broader context.