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.
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
- Purpose
- Taxonomy
- Implementation profile
- Top-level API inventory
- Position in family
- Declaration map
- Representative signatures
- How to use this module
- User example
- Keyword coverage
- Source shape
- Source landmarks
- Source organization
- Complete API catalog
- Integration boundaries
- Composition guidance
- Relationship table
- Neighbor modules
Overview
| Field | Value |
|---|---|
| Path | ffi/ffi.vitl |
| Family | ffi |
| Kind | public stdlib surface |
| Line count | 381 |
| Declared procedures | 16 |
| Declared forms/picks | 7 |
`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.
| Signal | Count | What it suggests |
|---|---|---|
if | 31 | Branching density and local decision-making. |
while | 0 | Loop-heavy or iterative implementation style. |
for | 1 | Collection-style traversal at source level. |
match | 0 | Variant-driven branching or grammar-style decoding. |
let | 55 | Local state and intermediate value density. |
give | 38 | Number of explicit exit points and result shaping. |
Top-level API inventory
| Surface | Items |
|---|---|
| Procedures | ffi_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 |
| Forms | ForeignFunction, ForeignLibrary, MathLib, StdioLib, StrlibLib, PthreadLib, Callback |
| Picks | none declared at top level |
| Constants | none declared at top level |
| Exports | none 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.
| Line | Name | Kind | Role |
|---|---|---|---|
| 1 | vitte/stdlib/ffi/ffi | space | Declares the namespace that anchors this file in the stdlib tree. |
| 3 | vitte/stdlib/ffi/abi | use | Imports a sibling or supporting surface used by the module. |
| 8 | ForeignFunction | form | Introduces a structured data shape that other procedures can exchange. |
| 19 | ForeignLibrary | form | Introduces a structured data shape that other procedures can exchange. |
| 28 | ffi_load_library | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 50 | ffi_get_stdlib | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 60 | ffi_register_function | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 85 | ffi_call | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 130 | ffi_call_str | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 135 | ffi_call_f64 | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 173 | ffi_unload_library | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 183 | MathLib | form | Introduces a structured data shape that other procedures can exchange. |
| 194 | math_lib_load | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 212 | StdioLib | form | Introduces a structured data shape that other procedures can exchange. |
| 222 | stdio_lib_load | proc | Owns byte movement or host I/O interaction. |
| 239 | StrlibLib | form | Introduces a structured data shape that other procedures can exchange. |
| 249 | strlib_load | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 266 | PthreadLib | form | Introduces a structured data shape that other procedures can exchange. |
| 276 | pthread_lib_load | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 293 | Callback | form | Introduces a structured data shape that other procedures can exchange. |
| 300 | callback_create | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 313 | callback_get_pointer | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 318 | get_stdlib_path | proc | Owns path semantics, traversal, or normalization. |
| 335 | panic | proc | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 339 | is_known_symbol | proc | Represents 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.
- Read
spaceand top-level imports first so the ownership boundary offfi/ffi.vitlis explicit. - Read declared forms and picks before algorithms so the data vocabulary is stable in your head.
- Traverse procedures in source order; the early helpers usually explain the naming and numeric conventions used later.
- 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.
| Keyword | Present in module source | Used in generated user example |
|---|---|---|
space | yes | yes |
use | yes | yes |
form | yes | yes |
proc | yes | yes |
let | yes | yes |
set | yes | yes |
if | yes | yes |
for | yes | yes |
give | yes | yes |
true | yes | yes |
false | yes | yes |
and | yes | yes |
not | yes | yes |
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
| Line | Name | Signature | Role |
|---|---|---|---|
| 8 | ForeignFunction | form ForeignFunction { | Introduces a structured data shape that other procedures can exchange. |
| 19 | ForeignLibrary | form ForeignLibrary { | Introduces a structured data shape that other procedures can exchange. |
| 183 | MathLib | form MathLib { | Introduces a structured data shape that other procedures can exchange. |
| 212 | StdioLib | form StdioLib { | Introduces a structured data shape that other procedures can exchange. |
| 239 | StrlibLib | form StrlibLib { | Introduces a structured data shape that other procedures can exchange. |
| 266 | PthreadLib | form PthreadLib { | Introduces a structured data shape that other procedures can exchange. |
| 293 | Callback | form Callback { | Introduces a structured data shape that other procedures can exchange. |
Procedures
| Line | Name | Signature | Role |
|---|---|---|---|
| 28 | ffi_load_library | proc 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. |
| 50 | ffi_get_stdlib | proc 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. |
| 60 | ffi_register_function | proc 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. |
| 85 | ffi_call | proc 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. |
| 130 | ffi_call_str | proc 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. |
| 135 | ffi_call_f64 | proc 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. |
| 173 | ffi_unload_library | proc 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. |
| 194 | math_lib_load | proc math_lib_load() -> MathLib { | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 222 | stdio_lib_load | proc stdio_lib_load() -> StdioLib { | Owns byte movement or host I/O interaction. |
| 249 | strlib_load | proc strlib_load() -> StrlibLib { | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 276 | pthread_lib_load | proc pthread_lib_load() -> PthreadLib { | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 300 | callback_create | proc 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. |
| 313 | callback_get_pointer | proc 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. |
| 318 | get_stdlib_path | proc get_stdlib_path(name: string) -> string { | Owns path semantics, traversal, or normalization. |
| 335 | panic | proc panic(msg: string) -> bool { | Represents one top-level surface in the file contract and should be read as part of the module boundary. |
| 339 | is_known_symbol | proc 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
| Line | Name | Signature | Role |
|---|---|---|---|
| 3 | vitte/stdlib/ffi/abi | use vitte/stdlib/ffi/abi | Imports 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.vitlwhen 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.vitlbefore 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.
| Neighbor | Procedures | Data surfaces | Why compare it |
|---|---|---|---|
ffi/abi.vitl | 31 | 7 | Shares the same family boundary but carries a distinct slice of responsibility. |