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 ¶
func Compile(ctx context.Context, env *environment.EnvironmentFrame, expr syntax.SyntaxValue) (*machine.NativeTemplate, error)
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 ¶
func Run(ctx context.Context, tpl *machine.NativeTemplate, env *environment.EnvironmentFrame) (machine.MultipleValues, error)
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.