Skip to content
Beskid The Beskid Book

Beskid

Jump to a Beskid service

Beskid

Jump to a Beskid service

09.2 Contracts in source

Declare structural contracts, implement them on types, and embed requirements without inheritance theatre.

Contracts in source

A Beskid contract is a structural interface: required members, optional embeddings, checked at compile time when a type lists conformances.

contract Disposable
{
unit Dispose();
}
type Logger : Disposable
{
unit Dispose() { /* ... */ }
}

Normative detail: Contracts.

Types declare type Name : I, J { ... }. The compiler checks every required member (E1601–E1607). Conflicting embeddings from two contracts must error—no C#-style diamond denial as a lifestyle.

contract Readable
{
i32 Read(ref u8 buffer);
}
contract ReadWrite : Readable
{
i32 Write(ref u8 buffer);
}

Embedding flattens requirements; implementers satisfy the expanded surface once.

SurfacePurpose
contract Foo { ... } in user codeType conformance, static dispatch
Beskid.Compiler.* mod contractsCompile-time plugins (Compiler Mod SDK)

Contracts describe capabilities, not inheritance trees. Prefer small contracts composed with embeddings over one “god interface” copied from enterprise slides.

Effects and purity