| id | embedding-overview |
|---|---|
| title | Embedding Overview |
| slug | /embedding/overview |
FScript is designed for host applications that embed a scripting language safely.
- Reference Language/Runtime for embedding and the independent Extensibility SDK for provider authoring.
- Build a host context.
- Register typed extern handlers and, when needed, host-provided types your scripts can use.
- Load scripts (with include resolution if needed).
- Resolve exported function signatures.
- Execute exported functions and handle results/errors.
MagnusOpera.FScript.LanguageMagnusOpera.FScript.RuntimeMagnusOpera.FScript.Extensibility— independently versioned provider contracts and CLR helpers.
- Real-World Embedding (Load, Resolve Type, Execute)
- Fable and JavaScript Hosts
- Register Extern Functions
- Host-Provided Types
- Environment Configuration
- Resolver and Includes
- Sandbox and Safety
The FFI graphics walkthrough puts geometry, camera, lighting, and animation in FScript. A typed .NET provider uploads the generated Utah teapot and renders it with OpenGL. It demonstrates script-constructible scene records, opaque window/mesh resources, typed function adapters, and editor discovery through fscript.toml. Run it with fscript samples/ffi/main.fss; use -- --headless to exercise the scripts without a display.
To report potential FFI sharing before interpreting, call
ScriptHost.loadSourceWithTaskSharingAnalysis registration purity options report source.
Use PurityContracts.empty and TaskSharingAnalysis.defaults for conservative
defaults. The report callback receives diagnostics before script evaluation;
hosts decide whether to log warnings or reject execution.
loadFileWithTaskSharingAnalysis and loadProgramWithTaskSharingAnalysis support
file and parsed-program loading. They reuse the resolved inference result for
interpretation. Existing loading and invocation APIs skip analysis entirely, and
there is no runtime tracking or synchronization overhead.
See Checking FFI Task Sharing for examples, provider contracts, and how to interpret the warnings.