Documentation ¶
Overview ¶
Package value implements Lisp values and their evaluation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( EOF = Error("EOF") T = Intern("t") NIL = Intern("nil") // also: empty list )
View Source
var SystemEnvironment = &env{ env: map[string]Value{ "atom": Func1(atom), "null": Func1(null), "eq": equalFn, "equal": equalFn, "car": Func1(car), "cdr": Func1(cdr), "caar": Func1(caar), "cadr": Func1(cadr), "cddr": Func1(cddr), "caddr": Func1(caddr), "cadar": Func1(cadar), "caddar": Func1(caddar), "cons": Func2(func(x, y Value) Value { return Cons(x, y) }), "list": FuncN(list), "apply": FuncN(apply), "error": FuncN(raiseError), "ignore-errors": Func1(trapError), "environment-bindings": EnvFunc(bindings), }, }
SystemEnvironment is the toplevel environment where primitives are defined.
Functions ¶
Types ¶
type Cell ¶
Cell is an object that holds two values.
type Environment ¶
type Environment interface { Value // Returns the list of defined symbols. Names() []string // Lookup the value of a symbol. Lookup(name string) (Value, bool) // Define a new symbol. Define(name string, value Value) // Update the value of a symbol. Update(name string, value Value) error }
An environment maintains a set of bindings that are typically referenced when evaluating a Lisp expression.
func NewEnv ¶
func NewEnv(parent Environment) Environment
NewEnv returns a new environment that extends the bindings of parent. If parent is nil, then this is a toplevel environment.
type Function ¶
func EnvFunc ¶
func EnvFunc(fn func(Environment) Value) Function
FuncEnv creates a Function value from a native Go function that only accepts environments.
func Func1 ¶
Func1 creates a Function value from a native Go function that accepts a single argument.
Click to show internal directories.
Click to hide internal directories.