Foreign interoperability
Interop is built from existing types, classes, effects, target blocks, representations, and transfer—not from an unchecked foreign escape hatch.
Current status: Native compiler-owned extern/provider declarations exist, but generic extern ABI validation is incomplete and .NET/JavaScript providers are planned rather than available execution backends.
Foreign declarations belong to targets
target dotnet {
extern function writeLine(text:String) : Unit;
};Target imports provide metadata:
import System.Console target dotnet;Where metadata is available, the compiler checks signatures, effects, and identity against the provider boundary.
Portable contract first
A robust binding starts with a portable algebra, class, or effect. A target block then supplies the foreign implementation. Application code depends on the semantic contract, not a raw platform symbol.
Data mapping
repr describes explicit semantic-to-storage conversion. Transfer describes movement between target handles. They are separate because converting layout is not the same as moving ownership or residence.
Host object models
Canonical classes may map to .NET, JavaScript/TypeScript, C++, or another host class model when inheritance, dispatch, fields, nullability, and exceptions can be preserved. Ordinary dot and class syntax remain uniform after checked metadata resolution.
Effects at the boundary
Foreign null, exceptions, mutation, asynchronous behavior, lifetime, and ownership must appear in types/effects or be discharged by a checked wrapper. They are never silently treated as pure tulam behavior.
Seamless does not mean invisible
The long-term goal is natural access to each platform’s ecosystem while retaining one language. “Seamless” means the boundary is typed and ergonomic; it does not mean cost, failure, or conversion disappears.
Common mistakes
Do not put raw foreign calls outside a target contract, hide exceptions or null inside a pure type, or use repr as if it transferred ownership to another target. Planned .NET and JavaScript providers are not current execution paths.
Recap
Interop starts from a portable semantic declaration and adds checked target metadata and implementations. Host-specific cost and failure remain explicit.
Normative details: Language Reference §18 and Interop Design.