bootstrap

package
v1.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

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:

  1. Creates a registry with core primitives
  2. Adds all extensions (io, files, math, eval, exceptions, threads, etc.)
  3. Creates a new Namespace with per-instance symbol interning
  4. Applies all primitives to the environment
  5. Registers syntax compilers and primitive expanders
  6. 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

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:

  1. Creates a registry with core primitives
  2. Adds all extensions (io, files, math, introspection, eval, threads, gointerop, all, system)
  3. Creates a new Namespace with per-instance symbol interning
  4. Applies the registry to register all primitives
  5. Registers primitive compilers in the compile environment
  6. 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL