v0.3 interop split author syntax from execution lowering; articles must not fork MUST tables.
Contract import syntax
Platform spec article
Contract import syntax
Spec standingStandard
-
Author-facing extern import rules live on this hub.
Context
Decision
This feature hub must own normative MUST/SHOULD contract text for foreign import. Sibling articles must not redefine hub requirements.
Consequences
Execution and tooling specs link here for
Externplacement and attribute shape.Verification anchors
/platform-spec/language-meta/interop/ffi-and-extern/;
compiler/crates/beskid_analysiscontract validation. -
Extern on non-contract declarations is E1510.
Context
Bulk C-style surfaces need stable contract blocks; module-level extern was exploratory.
Decision
Externmust apply only tocontractdeclarations in v0.3 Standard. The reference compiler must rejectExternon non-contract declarations (E1510).Consequences
Codegen collects
ExternImportfrom contract metadata; mod-level extern remains non-Standard.Verification anchors
compiler/crates/beskid_analysis/src/types/context/context.rs; extern attribute schema. -
Bulk import uses contract blocks with method signatures.
Context
Header-style
Externonmodwas considered for v0.3 but increases parser and ABI ambiguity.Decision
Externonmodis not part of v0.3 Standard. Authors must usecontractblocks with method signatures ending in;.Consequences
Future promotion requires a dedicated ADR and profile conformance tests.
Verification anchors
/platform-spec/language-meta/interop/ffi-and-extern/ v0.3 scope section.
-
Tier-1 user libraries use C profile; runtime builtins stay on Rust ABI.
Context
Mixing user
Externsymbols withBESKID_RUNTIME_ABI_VERSIONexports caused namespace and stability risk.Decision
Plane Rule User libraries C ABI profile + link-time binding Runtime embedding Rust ABI profile / frozen builtin table Separation User Externmust not mutate runtime builtin symbol namespaceConsequences
JIT registration and engine policy keep tables disjoint; see profile boundary map on hub.
Verification anchors
compiler/crates/beskid_abi; Rust ABI profile; C ABI profile. -
CLayout primitive structs are Proposed not v0.3.0 Standard.
Context
Arbitrary Beskid record
repr(C)needs layout rules beyond interop views.Decision
repr(C)on arbitrary Beskid types is out of scope for v0.3.0 Standard; CLayout primitive structs land in v0.3.1 (Proposed) per C layout types.Consequences
v0.3.0 Standard ships interop view types and link-time import first.
Verification anchors
- Contract import syntax How extern contracts declare foreign imports and map to symbols and call shapes.
- Extern attribute schema Normative Extern and per-method interop attributes for contract imports (v0.3).
- FFI and extern — Verification and traceability Conformance strategy for v0.3 FFI spec (fixtures, diagnostics, ignored runtime tests).
0 revisions (git unavailable at build; counts may be empty)
No commits recorded for this path.
Full tree: run pnpm verify:platform-spec-layout (writes src/generated/platform-spec-layout-report.json).
Import contracts
Section titled “Import contracts”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:
- One logical foreign symbol (method name or
Symboloverride). - One abstract call shape after Interop.Contracts normalization.
- One
ExternImportrow at codegen (symbol,abi,library).
Calling imported methods
Section titled “Calling imported methods”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.
Implementing contracts in Beskid
Section titled “Implementing contracts in Beskid”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
Section titled “Documentation”/// 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.
Relationship to corelib
Section titled “Relationship to corelib”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.