Stdlib module ffi/ffi.vitl

This page is a wiki-style reference for one concrete stdlib file. It explains what the file owns, where it fits in the family, and how to decide whether this is the right surface to depend on.

Visual portrait of ffi/ffi.vitl
Wiki-style portrait for ffi/ffi.vitl.

Family: ffi

Kind: public stdlib surface

Page style: this reference follows the same “encyclopedic card + portrait + usage contract” logic as the keyword pages, but for stdlib modules.

Summary

Overview

FieldValue
Pathffi/ffi.vitl
Familyffi
Kindpublic stdlib surface
Line count381
Declared procedures16
Declared forms/picks7

`ffi/ffi.vitl` is a public stdlib surface inside the `ffi` family. It should be read as one focused slice of the broader family responsibility: ABI and foreign-function boundaries used when Vitte code must cross language or runtime edges.

Purpose

This file should be chosen because of responsibility, not because its name “sounds close enough”. Inside the ffi family, it carries one focused part of the contract and keeps that responsibility separate from neighboring concerns.

  • A system integration module can expose a narrow ABI-facing wrapper while the rest of the program stays pure.
  • A runtime boundary should say exactly when the library stops and the foreign surface begins.

Taxonomy

Think of this page as a generated encyclopedia entry rather than a hand-written tutorial. The goal is to show what kind of module this is, how dense it is, and what reading strategy makes sense before depending on it.

  • Medium procedure surface: this file groups several related operations behind one namespace.
  • Owns domain vocabulary: the module declares data shapes in addition to executable helpers, so its types are part of the contract.
  • Narrow dependency fan-in: a small set of imports suggests a focused collaboration surface.

Implementation profile

This profile is inferred directly from the source text. It does not replace reading the file, but it tells you quickly whether the module is mostly declarative, loop-heavy, branch-heavy, or organized around many small exits.

SignalCountWhat it suggests
if31Branching density and local decision-making.
while0Loop-heavy or iterative implementation style.
for1Collection-style traversal at source level.
match0Variant-driven branching or grammar-style decoding.
let55Local state and intermediate value density.
give38Number of explicit exit points and result shaping.

Top-level API inventory

SurfaceItems
Proceduresffi_load_library, ffi_get_stdlib, ffi_register_function, ffi_call, ffi_call_str, ffi_call_f64, ffi_unload_library, math_lib_load, stdio_lib_load, strlib_load, pthread_lib_load, callback_create
FormsForeignFunction, ForeignLibrary, MathLib, StdioLib, StrlibLib, PthreadLib, Callback
Picksnone declared at top level
Constantsnone declared at top level
Exportsnone declared at top level

Imported surfaces

  • vitte/stdlib/ffi/abi // FFI

Position in family

This file is module 2 of 2 in the ffi family when ordered by path. By procedure count it ranks 2, and by line count it ranks 2. Those ranks are useful as rough signals of breadth, not as quality judgments.

Declaration map

The declaration map turns raw source into a scan-friendly catalog. It is useful when the file is large enough that a reader wants to orient by kinds of surfaces first.

LineNameKindRole
1vitte/stdlib/ffi/ffispaceDeclares the namespace that anchors this file in the stdlib tree.
3vitte/stdlib/ffi/abiuseImports a sibling or supporting surface used by the module.
8ForeignFunctionformIntroduces a structured data shape that other procedures can exchange.
19ForeignLibraryformIntroduces a structured data shape that other procedures can exchange.
28ffi_load_libraryprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
50ffi_get_stdlibprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
60ffi_register_functionprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
85ffi_callprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
130ffi_call_strprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
135ffi_call_f64procRepresents one top-level surface in the file contract and should be read as part of the module boundary.
173ffi_unload_libraryprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
183MathLibformIntroduces a structured data shape that other procedures can exchange.
194math_lib_loadprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
212StdioLibformIntroduces a structured data shape that other procedures can exchange.
222stdio_lib_loadprocOwns byte movement or host I/O interaction.
239StrlibLibformIntroduces a structured data shape that other procedures can exchange.
249strlib_loadprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
266PthreadLibformIntroduces a structured data shape that other procedures can exchange.
276pthread_lib_loadprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
293CallbackformIntroduces a structured data shape that other procedures can exchange.
300callback_createprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
313callback_get_pointerprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
318get_stdlib_pathprocOwns path semantics, traversal, or normalization.
335panicprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.
339is_known_symbolprocRepresents one top-level surface in the file contract and should be read as part of the module boundary.

The table is exhaustive for top-level declarations of the selected kinds. This file declares 25 matching surfaces.

Representative signatures

These signatures are shown in source order so the page keeps the feel of a reference manual, not just a keyword cloud.

  • form ForeignFunction { (line 8)
  • form ForeignLibrary { (line 19)
  • proc ffi_load_library(path: string) -> ForeignLibrary { (line 28)
  • proc ffi_get_stdlib(name: string) -> ForeignLibrary { (line 50)
  • proc ffi_register_function(lib: ForeignLibrary, fn_name: string, arg_types: [string], return_type: string) -> ForeignFunction { (line 60)
  • proc ffi_call(func: ForeignFunction, args: [int]) -> int { (line 85)
  • proc ffi_call_str(func: ForeignFunction, args: [int]) -> string { (line 130)
  • proc ffi_call_f64(func: ForeignFunction, args: [int]) -> f64 { (line 135)
  • proc ffi_unload_library(lib: ForeignLibrary) -> bool { (line 173)
  • form MathLib { (line 183)
  • proc math_lib_load() -> MathLib { (line 194)
  • form StdioLib { (line 212)
  • proc stdio_lib_load() -> StdioLib { (line 222)
  • form StrlibLib { (line 239)
  • proc strlib_load() -> StrlibLib { (line 249)
  • form PthreadLib { (line 266)
  • proc pthread_lib_load() -> PthreadLib { (line 276)
  • form Callback { (line 293)

The list is intentionally capped here; the source file declares 23 matching signatures in total.

How to use this module

Start by reading the file as an ownership boundary. Ask three questions: what enters this module, what stable types or procedures it exports, and what adjacent module should stay outside of it.

  1. Read space and top-level imports first so the ownership boundary of ffi/ffi.vitl is explicit.
  2. Read declared forms and picks before algorithms so the data vocabulary is stable in your head.
  3. Traverse procedures in source order; the early helpers usually explain the naming and numeric conventions used later.
  4. Only after that compare neighbor modules, because the right boundary choice matters more than memorizing one helper name.

User example

This example is generated from the actual stdlib module surface. Its job is not to be the smallest snippet possible; its job is to show a realistic consumer-shaped file that exercises the module and mirrors the language keywords the module itself relies on.

space demo/ffi_ffi
use vitte/stdlib/ffi/ffi
form UserReport {
  label: string,
  ready: bool
}
proc run_example() -> UserReport {
  let result = ffi_load_library("sample")
  let ready: bool = ffi_unload_library(ForeignLibrary())
  let failed: bool = false
  let stable: bool = ready and true
  let retries: int = 0
  set retries = retries + 1
  for sample in [1] {
    let seen: int = sample
  }
  if not ready {
    give UserReport { label: "not-ready", ready: false }
  }
    give UserReport { label: "ok", ready: true }
}

Keyword coverage

This table makes the “all keywords of the module” requirement auditable. It compares the detected Vitte keywords in the source file with the generated consumer example above.

KeywordPresent in module sourceUsed in generated user example
spaceyesyes
useyesyes
formyesyes
procyesyes
letyesyes
setyesyes
ifyesyes
foryesyes
giveyesyes
trueyesyes
falseyesyes
andyesyes
notyesyes

The generated snippet exercises every detected Vitte keyword used by this module.

Source shape

space vitte/stdlib/ffi/ffi
use vitte/stdlib/ffi/abi
// FFI - Foreign Function Interface
// Enables calling C and other native libraries
form ForeignFunction {
  name: string,
  lib_name: string,
  arg_types: [string],      // Type signatures
  return_type: string,
  calling_convention: string, // "cdecl", "stdcall", etc.

The excerpt is not meant to replace the file. It exists to make the module recognizable at first glance, the same way a Wikipedia infobox helps the reader orient before reading the whole article.

Source landmarks

Large files are easier to retain when they have visible landmarks. When the source contains explicit section banners, they are surfaced here; otherwise the first major declarations are used as anchors.

  • Line 1: space vitte/stdlib/ffi/ffi
  • Line 3: use vitte/stdlib/ffi/abi
  • Line 8: form ForeignFunction {
  • Line 19: form ForeignLibrary {
  • Line 28: proc ffi_load_library(path: string) -> ForeignLibrary {
  • Line 50: proc ffi_get_stdlib(name: string) -> ForeignLibrary {
  • Line 60: proc ffi_register_function(lib: ForeignLibrary, fn_name: string, arg_types: [string], return_type: string) -> ForeignFunction {
  • Line 85: proc ffi_call(func: ForeignFunction, args: [int]) -> int {

Source organization

When a file carries its own internal chaptering, those chapters usually reveal the intended reading order better than a flat symbol list. This section reconstructs that organization from the source itself.

File surfaces

Top-level items: 25. Procedures: 16. Data surfaces: 7. Constants: 0.

First visible names: vitte/stdlib/ffi/ffi, vitte/stdlib/ffi/abi, ForeignFunction, ForeignLibrary, ffi_load_library, ffi_get_stdlib, ffi_register_function, ffi_call, ffi_call_str, ffi_call_f64

Complete API catalog

This catalog is the exhaustive file-level index for the module. It is intentionally closer to a generated encyclopedia appendix than to a tutorial summary.

Data surfaces

LineNameSignatureRole
8ForeignFunctionform ForeignFunction {Introduces a structured data shape that other procedures can exchange.
19ForeignLibraryform ForeignLibrary {Introduces a structured data shape that other procedures can exchange.
183MathLibform MathLib {Introduces a structured data shape that other procedures can exchange.
212StdioLibform StdioLib {Introduces a structured data shape that other procedures can exchange.
239StrlibLibform StrlibLib {Introduces a structured data shape that other procedures can exchange.
266PthreadLibform PthreadLib {Introduces a structured data shape that other procedures can exchange.
293Callbackform Callback {Introduces a structured data shape that other procedures can exchange.

Procedures

LineNameSignatureRole
28ffi_load_libraryproc ffi_load_library(path: string) -> ForeignLibrary {Represents one top-level surface in the file contract and should be read as part of the module boundary.
50ffi_get_stdlibproc ffi_get_stdlib(name: string) -> ForeignLibrary {Represents one top-level surface in the file contract and should be read as part of the module boundary.
60ffi_register_functionproc ffi_register_function(lib: ForeignLibrary, fn_name: string, arg_types: [string], return_type: string) -> ForeignFunction {Represents one top-level surface in the file contract and should be read as part of the module boundary.
85ffi_callproc ffi_call(func: ForeignFunction, args: [int]) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
130ffi_call_strproc ffi_call_str(func: ForeignFunction, args: [int]) -> string {Represents one top-level surface in the file contract and should be read as part of the module boundary.
135ffi_call_f64proc ffi_call_f64(func: ForeignFunction, args: [int]) -> f64 {Represents one top-level surface in the file contract and should be read as part of the module boundary.
173ffi_unload_libraryproc ffi_unload_library(lib: ForeignLibrary) -> bool {Represents one top-level surface in the file contract and should be read as part of the module boundary.
194math_lib_loadproc math_lib_load() -> MathLib {Represents one top-level surface in the file contract and should be read as part of the module boundary.
222stdio_lib_loadproc stdio_lib_load() -> StdioLib {Owns byte movement or host I/O interaction.
249strlib_loadproc strlib_load() -> StrlibLib {Represents one top-level surface in the file contract and should be read as part of the module boundary.
276pthread_lib_loadproc pthread_lib_load() -> PthreadLib {Represents one top-level surface in the file contract and should be read as part of the module boundary.
300callback_createproc callback_create(closure: proc, signature: string) -> Callback {Represents one top-level surface in the file contract and should be read as part of the module boundary.
313callback_get_pointerproc callback_get_pointer(cb: Callback) -> int {Represents one top-level surface in the file contract and should be read as part of the module boundary.
318get_stdlib_pathproc get_stdlib_path(name: string) -> string {Owns path semantics, traversal, or normalization.
335panicproc panic(msg: string) -> bool {Represents one top-level surface in the file contract and should be read as part of the module boundary.
339is_known_symbolproc is_known_symbol(lib_name: string, fn_name: string) -> bool {Represents one top-level surface in the file contract and should be read as part of the module boundary.

Imports

LineNameSignatureRole
3vitte/stdlib/ffi/abiuse vitte/stdlib/ffi/abiImports a sibling or supporting surface used by the module.

Integration boundaries

Within ffi, this file should remain focused. If a future helper changes the host boundary, scheduling boundary, or data-shape boundary, it probably belongs in a neighbor module instead of being added here by convenience.

  • Family responsibility: ABI and foreign-function boundaries used when Vitte code must cross language or runtime edges.
  • Family architecture role: Use `ffi` only when the program really needs a foreign boundary. This family should make coupling visible instead of hiding it.

Composition guidance

Choose this module when

  • Choose ffi/ffi.vitl when the main question is owned by this module rather than by transport, storage, orchestration, or user-interface code.
  • A system integration module can expose a narrow ABI-facing wrapper while the rest of the program stays pure.
  • A runtime boundary should say exactly when the library stops and the foreign surface begins.

Pause before extending it when

  • Avoid extending this file when the new helper mostly changes the boundary to host I/O, runtime coordination, or foreign integration instead of staying inside ffi.
  • Check nearby modules such as ffi/abi.vitl before adding convenience wrappers here.

Relationship table

This table keeps the page closer to a real encyclopedia entry: a module is easier to understand when compared with its nearest alternatives in the same family.

NeighborProceduresData surfacesWhy compare it
ffi/abi.vitl317Shares the same family boundary but carries a distinct slice of responsibility.

Neighbor modules