Documentation
¶
Overview ¶
Package bootstrap initializes the top-level Scheme environment.
The package creates and bootstraps complete runtime environments using the registry pattern:
env, err := bootstrap.NewNamespaceFrameTiny(ctx)
Initialization ¶
NewNamespaceFrameTiny performs these steps:
- Creates a registry with core primitives
- Adds all extensions (io, files, math, eval, exceptions, threads, etc.)
- Creates a new Namespace with per-instance symbol interning
- Applies all primitives to the environment
- Registers syntax compilers and primitive expanders
- Loads bootstrap macros
Library Environments ¶
NewLibraryEnvironmentFrame creates environments for R7RS libraries that share symbol interning with the caller but isolate bindings:
libEnv, err := bootstrap.NewLibraryEnvironmentFrame(ctx, callerEnv)
This ensures (eq? 'foo (string->symbol "foo")) returns #t across library boundaries per R7RS 6.5.
Package runtime provides the runtime environment initialization for the Scheme interpreter.
This package is responsible for:
- Creating and initializing the top-level environment with all R7RS primitives
- Loading bootstrap macros (and, or, let, let*, letrec, cond, when, unless)
Architecture ¶
The runtime creates a three-phase environment hierarchy:
TopLevel (Runtime) -> Expand -> Compile
Primitives are registered via the registry pattern from registry/core and extensions/*.
Index ¶
- func NewLibraryEnvironmentFrame(ctx context.Context, callerEnv *environment.EnvironmentFrame, _ []string) (*environment.EnvironmentFrame, error)
- func NewNamespaceFrameTiny(ctx context.Context) (*environment.EnvironmentFrame, error)
- func NewTopLevelWithRegistry(ctx context.Context) (*environment.EnvironmentFrame, *registry.Registry, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLibraryEnvironmentFrame ¶
func NewLibraryEnvironmentFrame(ctx context.Context, callerEnv *environment.EnvironmentFrame, _ []string) (*environment.EnvironmentFrame, error)
NewLibraryEnvironmentFrame creates a new environment for a library that shares the Namespace with the caller. This ensures symbol identity is preserved across library boundaries per R7RS §6.5: (eq? 'foo (string->symbol "foo")) must be #t.
The library gets its own:
- GlobalEnvironmentFrame for bindings (isolates library definitions)
- PhaseRegistry for expand/compile phases
But shares with caller:
- Namespace (symbol and syntax interning)
- LibraryRegistry (for nested imports)
func NewNamespaceFrameTiny ¶ added in v1.7.0
func NewNamespaceFrameTiny(ctx context.Context) (*environment.EnvironmentFrame, error)
NewNamespaceFrameTiny creates and initializes a complete Scheme runtime environment.
This function:
- Creates a registry with core primitives
- Adds all extensions (io, files, math, introspection, eval, threads, gointerop, all, system)
- Creates a new Namespace with per-instance symbol interning
- Applies the registry to register all primitives
- Registers primitive compilers in the compile environment
- Loads bootstrap macros (and, or, let, let*, letrec, cond, when, unless, parameterize)
The resulting environment is ready for parsing, expanding, compiling, and executing Scheme programs.
func NewTopLevelWithRegistry ¶ added in v1.5.0
func NewTopLevelWithRegistry(ctx context.Context) (*environment.EnvironmentFrame, *registry.Registry, error)
NewTopLevelWithRegistry creates a top-level environment and returns both the environment frame and the primitive registry for doc introspection.
Types ¶
This section is empty.