Skip to content
Beskid Platform specification

Beskid

Jump to a Beskid service

Beskid

Jump to a Beskid service

Contract import syntax

Platform spec article

Contract import syntax

Spec standingStandard

Owner
Piotr Mikstacki
Submitter
Piotr Mikstacki

Foreign surface area is declared with contract blocks. Importing methods use signatures that end with ; (no Beskid body), consistent with contract grammar in compiler/crates/beskid_analysis/src/beskid.pest.

Each import method contributes:

  1. One logical foreign symbol (method name or Symbol override).
  2. One abstract call shape after Interop.Contracts normalization.
  3. One ExternImport row at codegen (symbol, abi, library).

Beskid code calls foreign entrypoints through the contract type, for example Libc.getpid(). Type checking treats the call as contract dispatch lowered through the C ABI profile.

Beskid types may implement non-extern contracts in normal source. Extern contracts are import-only in v0.3: methods must not have Beskid bodies on the same contract.

/// documentation on the contract and its methods should describe:

  • Threading and re-entrancy expectations at the foreign side.
  • Ownership of each parameter (borrow vs transfer).
  • Error representation (return codes vs out-parameters).

Use @arg only on callable parameters (methods), not on contract-level metadata fields.

Platform packages (for example console and threading) should group foreign entrypoints into small Extern contracts per library (libc, libpthread) rather than scattering raw integer pointer parameters across unrelated APIs.