Skip to content
beskid The Beskid Book

Beskid

Jump to a Beskid service

Beskid

Jump to a Beskid service

07.5 Control flow

if, match, loops, and branching without turning every decision into a framework.

Control flow

Control flow is how programs admit they have choices. Beskid expects you to make those choices explicit enough for the analyzer to follow.

Standard conditional binding: exact grammar in lexical and syntax. Do not use if to simulate nullable checks; narrow Option<T> with match.

match is the honest tool for enums and Option<T>:

  • Exhaustive arms are a feature, not bureaucracy
  • Combine with enums and match for algebraic types
flowchart TD
  accTitle: Match arms
  accDescr: A match on an enum or Option dispatches to one arm, and the arms must be exhaustive.
  E[enum or Option] --> M[match]
  M --> A1[arm 1]
  M --> A2[arm 2]
  M --> AN[arm n - exhaustive]

Iteration and concurrency primitives live under evaluation features (fibers and spawn etc.). This tutorial does not pretend to be the concurrency bible. Read spec before spawning threads because a blog post said async.

Branching across contract boundaries may interact with effect tracking. When in doubt, run beskid dev syntax analyze and read the diagnostic rather than guessing.

Read a diagnostic