bootstrap

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: Apache-2.0 Imports: 19 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.NewTopLevelEnvironmentFrameTiny(ctx)

Initialization

NewTopLevelEnvironmentFrameTiny 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 TopLevelEnvironment 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) (*environment.EnvironmentFrame, error)

NewLibraryEnvironmentFrame creates a new environment for a library that shares the TopLevelEnvironment 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:

  • TopLevelEnvironment (symbol and syntax interning)
  • LibraryRegistry (for nested imports)

func NewTopLevelEnvironmentFrameTiny

func NewTopLevelEnvironmentFrameTiny(ctx context.Context) (*environment.EnvironmentFrame, error)

NewTopLevelEnvironmentFrameTiny creates and initializes a complete Scheme runtime environment.

This function:

  1. Creates a registry with core primitives
  2. Adds all extensions (io, files, math, eval, exceptions, threads, gointerop, all, system)
  3. Creates a new TopLevelEnvironment 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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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