bootstrap

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

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/*.

Package bootstrap initializes the top-level Scheme environment.

The package creates and bootstraps complete runtime environments using the registry pattern:

env, err := bootstrap.NewNamespaceFrame(ctx)

Initialization

NewNamespaceFrame 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.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownProfile = werr.NewStaticError("unknown profile")

ErrUnknownProfile is returned by ProfileExtensions when given a name outside the known set (tiny, console, console-with-load, small, kitchen-sink).

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 NewNamespaceFrame added in v1.14.244

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

NewNamespaceFrame 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 NewProfileEnvironment added in v1.14.244

func NewProfileEnvironment(ctx context.Context, callerNS *environment.Namespace, exts []registry.Extension) (*environment.Namespace, error)

NewProfileEnvironment creates a new *environment.Namespace initialized with the given extension set. It shares symbol interning with callerNS but has its own bindings so the caller's top-level definitions do not leak in. Intended for Scheme-level (environment '(wile <profile>)) construction.

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.

func ProfileExtensions added in v1.14.244

func ProfileExtensions(name string) ([]registry.Extension, error)

ProfileExtensions returns the extension set for a named profile. It is the single source of truth for profile→extensions mapping; callers in the public wile package (profile.go Profile.extensions) and in extensions/eval (tryWileProfile, for Scheme-level (environment '(wile <name>))) both dispatch through here.

Valid names: "tiny", "console", "console-with-load", "small", "kitchen-sink". An unknown name returns ErrUnknownProfile wrapped with the offending string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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