runtime

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package runtime provides the core API for embedding Wile Scheme in Go applications.

This package exposes the essential functions for compiling and executing Scheme code:

  • Compile transforms syntax into executable templates
  • Run executes compiled templates
  • Load reads and evaluates Scheme code from an io.Reader

Basic Usage

To evaluate Scheme code from a string:

env, _ := bootstrap.NewTopLevelEnvironmentFrameTiny(ctx)
reader := strings.NewReader(`(+ 1 2)`)
err := runtime.Load(ctx, env, reader, "example.scm")

Creating Environments

Use github.com/aalpar/wile/internal/bootstrap.NewTopLevelEnvironmentFrameTiny to create a top-level environment with all standard bindings.

Package runtime provides the core API for embedding Wile Scheme in Go applications.

This package exposes the essential functions for compiling and executing Scheme code:

  • Compile transforms syntax into executable templates
  • Run executes compiled templates
  • Load reads and evaluates Scheme code from an io.Reader

Basic Usage

To evaluate Scheme code from a string:

env, _ := bootstrap.NewTopLevelEnvironmentFrameTiny(ctx)
reader := strings.NewReader(`(+ 1 2)`)
err := runtime.Load(ctx, env, reader, "example.scm")

Creating Environments

Use github.com/aalpar/wile/internal/bootstrap.NewTopLevelEnvironmentFrameTiny to create a top-level environment with all standard bindings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

Compile expands and compiles a syntax expression into an executable template.

The returned machine.NativeTemplate can be executed multiple times with Run. This is useful when the same code needs to be evaluated repeatedly.

func Load

func Load(ctx context.Context, env *environment.EnvironmentFrame, r io.Reader, filename string) error

Load reads and evaluates Scheme expressions from a reader into the environment.

All expressions are read, wrapped in a (begin ...) form, compiled, and executed. This is the primary way to load Scheme libraries or configuration files.

The filename parameter is used for error messages and source location tracking. Pass an empty string if the source has no associated filename.

func Run

Run executes a compiled template and returns the result values.

The template is executed in the context of the given environment. Any definitions or side effects will modify the environment.

Types

This section is empty.

Jump to

Keyboard shortcuts

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