16. Interop and ABI (pocket version)

TL;DR (5 lines)

  • Interop is a narrow boundary, not a default tool.
  • The chapter should expose coupling cost clearly.
  • Unsafe or foreign edges must stay visible.
  • Safe wrappers are part of the teaching model.
  • The goal is controlled integration, not hidden magic.

Concrete Problem

Interop pages become dangerous when they normalize foreign boundaries instead of isolating them.

Coherent example

space demo/interop

unsafe proc call_host(code: int) -> int {
  if code < 0 { give 11 }
  give 0
}

Global explanation

Interop is not a convenience feature. It is a coupling boundary. The chapter should therefore explain why the foreign edge exists, how narrow it is, and how the rest of the program stays readable around it.

Short exercise

Wrap the interop call in a safer procedure that exposes a domain-oriented result instead of a raw foreign detail.

Next best action

Keep the example small, reproduce it locally, then continue to the full chapter if you need the broader context.