Skip to main content

What Flex is

A language for declaring the data that system components exchange and the protocols that govern those exchanges.

module radar::sensors.tracking

component Radar;
component CommandPost;

message struct TrackReport {
    track_id: uint32;
    bearing_deg: float32;
}

global protocol Report {
    exch any TrackReport from Radar to CommandPost;
}

The shape of a file​

A file names itself with a module header, lists its imports, then holds a run of global declarations.

  • A declaration stands at the top level and nowhere else, so a type is never nested inside another and a protocol is never nested inside a type.
  • Nothing stands outside a declaration. There is no entry point and no statement at file scope.
  • message marks the types that cross a component boundary. A protocol carries those and nothing else, so the boundary is visible in the declaration rather than inferred from the traffic.

Where to look​

  • modules and imports — the header a file carries, and how it reaches another file's declarations.
  • lexical basics — what a name may be, and what the language ignores.
  • types and constants — the data a component holds or sends, the invariants it has to satisfy, and the values a module names.
  • global protocols — which component sends what, to whom, and in what order.
  • local protocols — one component's own behavior, as an ordered sequence of statements.
  • functions — a named body that returns a value, and the translation between message types.
  • metadata — the annotations a tool reads, and the properties a contract states.
  • expressions — how a value is written, and the forms that compute one.