vesper

package module
v0.0.0-...-809edf2 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2021 License: MIT Imports: 14 Imported by: 0

README

Vesper

Vesper Lisp

Documentation

Index

Constants

View Source
const Version = "vesper v0.1"

Version - this version of vesper

Variables

View Source
var (
	// BooleanType is the type of true and false
	BooleanType = defaultVM.Intern("<boolean>")
	// True is the singleton boolean true value
	True = &Object{Type: BooleanType, fval: 1}
	// False is the singleton boolean false value
	False = &Object{Type: BooleanType, fval: 0}
)
View Source
var (
	// ErrorKey - used for generic errors
	ErrorKey = defaultVM.Intern("error:")
	// ArgumentErrorKey used for argument errors
	ArgumentErrorKey = defaultVM.Intern("argument-error:")
	// SyntaxErrorKey used for syntax errors
	SyntaxErrorKey = defaultVM.Intern("syntax-error:")
	// MacroErrorKey used for macro errors
	MacroErrorKey = defaultVM.Intern("macro-error:")
	// IOErrorKey used for IO errors
	IOErrorKey = defaultVM.Intern("io-error:")
	// InterruptKey used for interrupts that were captured
	InterruptKey = defaultVM.Intern("interrupt:")
	// InternalErrorKey used for internal errors
	InternalErrorKey = defaultVM.Intern("internal-error:")
)
View Source
var (
	// GenfnsSymbol used to define generic Function
	GenfnsSymbol = defaultVM.Intern("*genfns*")
	// MethodsKeyword used to define methods
	MethodsKeyword = defaultVM.Intern("methods:")
)
View Source
var (
	// TypeType is the metatype, the type of all types
	TypeType *Object // bootstrapped in initSymbolTable => Intern("<type>")
	// KeywordType is the type of all keywords
	KeywordType *Object // bootstrapped in initSymbolTable => Intern("<keyword>")
	// SymbolType is the type of all symbols
	SymbolType *Object // bootstrapped in initSymbolTable = Intern("<symbol>")
	// StringType is the type of all strings
	StringType *Object // bootstrapped in initSymbolTable = Intern("<string>")

	// CharacterType is the type of all characters
	CharacterType = defaultVM.Intern("<character>")
	// NumberType is the type of all numbers
	NumberType = defaultVM.Intern("<number>")

	// BlobType is the type of all bytearrays
	BlobType = defaultVM.Intern("<blob>")
	// ListType is the type of all lists
	ListType = defaultVM.Intern("<list>")
	// ArrayType is the type of all arrays
	ArrayType = defaultVM.Intern("<array>")
	// StructType is the type of all structs
	StructType = defaultVM.Intern("<struct>")
	// FunctionType is the type of all functions
	FunctionType = defaultVM.Intern("<function>")
	// CodeType is the type of compiled code
	CodeType = defaultVM.Intern("<code>")
	// ErrorType is the type of all errors
	ErrorType = defaultVM.Intern("<error>")
	// AnyType is a pseudo type specifier indicating any type
	AnyType = defaultVM.Intern("<any>")
)
View Source
var (
	// NoneSymbol represents a nil operation
	NoneSymbol = defaultVM.Intern("none")
	// LiteralSymbol represents a bytecode for a literal
	LiteralSymbol = defaultVM.Intern("literal")
	// LocalSymbol represents bytecode for a local variable
	LocalSymbol = defaultVM.Intern("local")
	// JumpfalseSymbol represents a jump on false
	JumpfalseSymbol = defaultVM.Intern("jumpfalse")
	// JumpSymbol represents an unconditional jump
	JumpSymbol = defaultVM.Intern("jump")
	// TailcallSymbol represents a tailcall operation
	TailcallSymbol = defaultVM.Intern("tailcall")
	// CallSymbol represents a function call
	CallSymbol = defaultVM.Intern("call")
	// ReturnSymbol represents a return from the current function
	ReturnSymbol = defaultVM.Intern("return")
	// ClosureSymbol represents the creation of a closure
	ClosureSymbol = defaultVM.Intern("closure")
	// PopSymbol represents the pop operation
	PopSymbol = defaultVM.Intern("pop")
	// GlobalSymbol represents a reference to a global
	GlobalSymbol = defaultVM.Intern("global")
	// DefglobalSymbol represents the definition of a global symbol
	DefglobalSymbol = defaultVM.Intern("defglobal")
	// SetlocalSymbol represents setting a local varioble
	SetlocalSymbol = defaultVM.Intern("setlocal")
	// UseSymbol represents the "use" of a module
	UseSymbol = defaultVM.Intern("use")
	// DefmacroSymbol represents a macro definition
	DefmacroSymbol = defaultVM.Intern("defmacro")
	// ArraySymbol represents the creation of a literal array
	ArraySymbol = defaultVM.Intern("array")
	// StructSymbol represents creation of a literal struct
	StructSymbol = defaultVM.Intern("struct")
	// UndefineSymbol represents an undefine operation
	UndefineSymbol = defaultVM.Intern("undefine")
	// FuncSymbol represents a function definition
	FuncSymbol = defaultVM.Intern("func")
)
View Source
var Apply = &Object{Type: FunctionType}

Apply is a primitive instruction to apply a function to a list of arguments

View Source
var CallCC = &Object{Type: FunctionType}

CallCC is a primitive instruction to executable (restore) a continuation

View Source
var ChannelType = defaultVM.Intern("<channel>")

ChannelType - the type of Vesper's channel object

View Source
var EmptyBlob = MakeBlob(0)

EmptyBlob - a blob with no bytes

View Source
var EmptyList = initEmpty()

EmptyList - the value of (), terminates linked lists

View Source
var EmptyString = String("")

EmptyString an empty string

View Source
var EmptyStruct = MakeStruct(0)

EmptyStruct - a <struct> with no bindings

View Source
var GoFunc = &Object{Type: FunctionType}

GoFunc is a primitive instruction to create a goroutine

View Source
var MinusOne = Number(-1)

MinusOne is the Vesper -1 value

View Source
var Null = &Object{Type: NullType}

Null is a singleton representing nothing. It is distinct from an empty list.

View Source
var NullType = defaultVM.Intern("<null>")

NullType the type of the null object

View Source
var One = Number(1)

One is the Vesper 1 value

View Source
var QuasiquoteSymbol = defaultVM.Intern("quasiquote")

QuasiquoteSymbol represents a quasiquoted expression

View Source
var QuoteSymbol = defaultVM.Intern("quote")

QuoteSymbol represents a quoted expression

View Source
var UnquoteSplicingSymbol = defaultVM.Intern("unquote-splicing")

UnquoteSplicingSymbol represents an unquote-splicing expression

View Source
var UnquoteSymbol = defaultVM.Intern("unquote")

UnquoteSymbol represents an unquoted expression

View Source
var Zero = Number(0)

Zero is the Vesper 0 value

Functions

func ArrayEqual

func ArrayEqual(v1 *Object, v2 *Object) bool

ArrayEqual - return true of the two arrays are equal, i.e. the same length and all the elements are also equal

func AsByteValue

func AsByteValue(obj *Object) (byte, error)

AsByteValue returns the value of the object as a byte

func AsFloat64Value

func AsFloat64Value(obj *Object) (float64, error)

AsFloat64Value returns the floating point value of the object

func AsInt64Value

func AsInt64Value(obj *Object) (int64, error)

AsInt64Value returns the int64 value of the object

func AsIntValue

func AsIntValue(obj *Object) (int, error)

AsIntValue returns the int value of the object

func AsRuneValue

func AsRuneValue(c *Object) (rune, error)

AsRuneValue - return the native rune representation of the character object, if possible

func AsStringValue

func AsStringValue(obj *Object) (string, error)

AsStringValue - return the native string representation of the object, if possible

func BlobValue

func BlobValue(obj *Object) []byte

BlobValue - return native []byte value of the object

func BoolValue

func BoolValue(obj *Object) bool

BoolValue - return native bool value of the object

func ChannelValue

func ChannelValue(obj *Object) chan *Object

ChannelValue - return the Go channel object for the Vesper channel

func CloseChannel

func CloseChannel(obj *Object)

CloseChannel - close the channel object

func EncodeString

func EncodeString(s string) string

EncodeString - return the encoded form of a string value

func Equal

func Equal(o1 *Object, o2 *Object) bool

Equal checks if two objects are equal

func Error

func Error(errkey *Object, args ...interface{}) error

Error creates a new Error from the arguments. The first is an actual Vesper keyword object, the rest are interpreted as/converted to strings

func ExpandFilePath

func ExpandFilePath(path string) string

ExpandFilePath returns the absolute path of a file or directory

func ExpandPath

func ExpandPath(filename string) (string, error)

ExpandPath returns the absolute path including

func Fatal

func Fatal(args ...interface{})

Fatal prints the values, followed by immediate exit

func FindModuleByName

func FindModuleByName(moduleName string) (string, error)

FindModuleByName returns the file filename of a vesper module

func FindModuleFile

func FindModuleFile(name string) (string, error)

FindModuleFile finds a readable module file or errors

func Float64Value

func Float64Value(obj *Object) float64

Float64Value - return native float64 value of the object

func Has

func Has(obj *Object, key *Object) (bool, error)

Has returns whether the struct has the given key. Returns an error if the object is not a struct.

func Identical

func Identical(o1 *Object, o2 *Object) bool

Identical - return if two objects are identical

func Init

func Init()

Init initialise the base environment and extensions

func Int64Value

func Int64Value(obj *Object) int64

Int64Value - return native int64 value of the object

func IntValue

func IntValue(obj *Object) int

IntValue - return native int value of the object

func IsArray

func IsArray(obj *Object) bool

IsArray returns true if the object is an array

func IsBoolean

func IsBoolean(obj *Object) bool

IsBoolean returns true if the object type is boolean

func IsCharacter

func IsCharacter(obj *Object) bool

IsCharacter returns true if the object is a character

func IsCode

func IsCode(obj *Object) bool

IsCode returns true if the object is a code object

func IsDefined

func IsDefined(sym *Object) bool

IsDefined - return true if the there is a global value defined for the symbol

func IsDirectoryReadable

func IsDirectoryReadable(path string) bool

IsDirectoryReadable - return true of the directory is readable

func IsError

func IsError(o interface{}) bool

IsError returns true if the object is an error

func IsFileReadable

func IsFileReadable(path string) bool

IsFileReadable - return true of the file is readable

func IsFloat

func IsFloat(obj *Object) bool

IsFloat returns true if the object is a float

func IsFunction

func IsFunction(obj *Object) bool

IsFunction returns true if the object is a function

func IsInstance

func IsInstance(obj *Object) bool

IsInstance returns true if the object is an instance. Since instances have arbitrary Type symbols, all we can check is that the car value is set

func IsInt

func IsInt(obj *Object) bool

IsInt returns true if the object is an integer

func IsKeyword

func IsKeyword(obj *Object) bool

IsKeyword returns true if the object is a keyword

func IsList

func IsList(obj *Object) bool

IsList returns true if the object is a list

func IsNull

func IsNull(obj *Object) bool

IsNull returns true if the object is the null object

func IsNumber

func IsNumber(obj *Object) bool

IsNumber returns true if the object is a number

func IsPrimitiveType

func IsPrimitiveType(tag *Object) bool

IsPrimitiveType returns true if the object is a primitive

func IsString

func IsString(obj *Object) bool

IsString returns true if the object is a string

func IsStruct

func IsStruct(obj *Object) bool

IsStruct returns true if the object is a struct

func IsSymbol

func IsSymbol(obj *Object) bool

IsSymbol returns true if the object is a symbol

func IsType

func IsType(obj *Object) bool

IsType returns true if the object is a type

func IsValidKeywordName

func IsValidKeywordName(s string) bool

IsValidKeywordName returns true if the string is a keyword

func IsValidStructKey

func IsValidStructKey(o *Object) bool

IsValidStructKey - return true of the object is a valid <struct> key.

func IsValidSymbolName

func IsValidSymbolName(name string) bool

IsValidSymbolName returns true if the string is a valid symbol

func IsValidTypeName

func IsValidTypeName(s string) bool

IsValidTypeName returns true if the string is a typename

func ListEqual

func ListEqual(lst *Object, a *Object) bool

ListEqual returns true if the object is equal to the argument

func ListLength

func ListLength(lst *Object) int

ListLength returns the length of the list

func Now

func Now() float64

Now returns the time in seconds since the epoch

func NumberEqual

func NumberEqual(f1 float64, f2 float64) bool

NumberEqual returns true if the object is equal to the argument, within epsilon

func Pretty

func Pretty(obj *Object) string

Pretty returns a pretty-printed version of the object

func PrettyAll

func PrettyAll(obj *Object) string

PrettyAll - pretty-prints all the objects in the list to a string

func Print

func Print(args ...interface{})

Print prints the expressions

func Println

func Println(args ...interface{})

Println prints the values followed by a newline

func Put

func Put(obj *Object, key *Object, val *Object)

Put adds the given object to the struct with the given key

func REPL

func REPL(vm *VM) error

REPL starts a REPL with the given VM.

func RandomSeed

func RandomSeed(n int64)

RandomSeed seeds the random number generator with the given seed value

func Round

func Round(f float64) float64

Round - return the closest integer value to the float value

func RuneValue

func RuneValue(obj *Object) rune

RuneValue - return native rune value of the object

func Sleep

func Sleep(delayInSeconds float64)

Sleep for the given number of seconds

func SpitFile

func SpitFile(path string, data string) error

SpitFile - write the string to the file.

func StringLength

func StringLength(s string) int

StringLength - return the string length

func StringValue

func StringValue(obj *Object) string

StringValue - return native string value of the object

func StructEqual

func StructEqual(s1 *Object, s2 *Object) bool

StructEqual returns true if the object is equal to the argument

func StructLength

func StructLength(strct *Object) int

StructLength - return the length (field count) of the <struct> object

func Unput

func Unput(obj *Object, key *Object)

Unput deletes the given key from the struct

func Write

func Write(obj *Object) string

Write returns a string representation of the object

func WriteAll

func WriteAll(obj *Object) string

WriteAll writes all the objects in the list to a string

Types

type Code

type Code struct {
	// contains filtered or unexported fields
}

Code - compiled Vesper bytecode

func (*Code) String

func (code *Code) String(vm *VM) string

type Extension

type Extension interface {
	Name() string
	Init(*VM) error
}

Extension allows for extending Vesper

type Flags

type Flags struct {
	Debug       bool
	Verbose     bool
	Interactive bool
}

Flags a set of flags for the virtual machine

type Macro

type Macro struct {
	Name     *Object
	Expander *Object // a function of one argument
}

Macro a structure to hold Macro values

func NewMacro

func NewMacro(name *Object, expander *Object) *Macro

NewMacro - create a new Macro

func (*Macro) String

func (mac *Macro) String() string

type Object

type Object struct {
	Type *Object // i.e. <string>

	Value interface{} // the rest of the data for more complex things
	// contains filtered or unexported fields
}

Object represents all objects in Vesper

func Array

func Array(elements ...*Object) *Object

Array - create a new <array> object from the given element objects.

func ArrayFromElements

func ArrayFromElements(elements []*Object, count int) *Object

ArrayFromElements - return a new <array> object from the given slice of elements. The slice is copied.

func ArrayFromElementsNoCopy

func ArrayFromElementsNoCopy(elements []*Object) *Object

ArrayFromElementsNoCopy - create a new <array> object from the given slice of elements. The slice is NOT copied.

func Blob

func Blob(bytes []byte) *Object

Blob - create a new blob, using the specified byte slice as the data. The data is not copied.

func Caar

func Caar(lst *Object) *Object

Caar - return the Car of the Car of the list

func Cadar

func Cadar(lst *Object) *Object

Cadar - return the Car of the Cdr of the Car of the list

func Cadddr

func Cadddr(lst *Object) *Object

Cadddr - return the Car of the Cdr of the Cdr of the Cdr of the list

func Caddr

func Caddr(lst *Object) *Object

Caddr - return the Car of the Cdr of the Cdr of the list

func Cadr

func Cadr(lst *Object) *Object

Cadr - return the Car of the Cdr of the list

func Car

func Car(lst *Object) *Object

Car - return the first object in a list

func Cdar

func Cdar(lst *Object) *Object

Cdar - return the Cdr of the Car of the list

func Cddddr

func Cddddr(lst *Object) *Object

Cddddr - return the Cdr of the Cdr of the Cdr of the Cdr of the list

func Cdddr

func Cdddr(lst *Object) *Object

Cdddr - return the Cdr of the Cdr of the Cdr of the list

func Cddr

func Cddr(lst *Object) *Object

Cddr - return the Cdr of the Cdr of the list

func Cdr

func Cdr(lst *Object) *Object

Cdr - return the rest of the list

func Channel

func Channel(bufsize int, name string) *Object

Channel - create a new channel with the given buffer size and name

func Character

func Character(c rune) *Object

Character - return a new <character> object

func Closure

func Closure(code *Code, frame *frame) *Object

Closure creates a new closure in the given frame

func Concat

func Concat(seq1 *Object, seq2 *Object) (*Object, error)

Concat joins two lists

func Cons

func Cons(car *Object, cdr *Object) *Object

Cons - create a new list consisting of the first object and the rest of the list

func Continuation

func Continuation(frame *frame, ops []int, pc int, stack []*Object) *Object

Continuation creates a continuation object

func CopyArray

func CopyArray(a *Object) *Object

CopyArray - return a copy of the <array> object

func ErrorData

func ErrorData(err *Object) *Object

ErrorData returns the data associated with the error

func Flatten

func Flatten(lst *Object) *Object

Flatten flattens a list into a single list

func Get

func Get(obj *Object, key *Object) (*Object, error)

Get - return the value for the key of the object. The Value() function is first called to handle typed instances of <struct>. This is called by the VM, when a keyword is used as a function.

func GetGlobal

func GetGlobal(sym *Object) *Object

GetGlobal - return the global value for the specified symbol, or nil if the symbol is not defined.

func Instance

func Instance(tag *Object, val *Object) (*Object, error)

Instance returns a new instance of the type and value

func Int

func Int(n int64) *Object

Int converts an integer to a vector Number

func List

func List(values ...*Object) *Object

List creates a new list from the arguments

func ListFromValues

func ListFromValues(values []*Object) *Object

ListFromValues creates a list from the given array

func MakeArray

func MakeArray(size int, init *Object) *Object

MakeArray - create a new <array> object of the specified size, with all elements initialized to the specified value

func MakeBlob

func MakeBlob(size int) *Object

MakeBlob - create a new blob of the given size. It will be initialized to all zeroes

func MakeCode

func MakeCode(vm *VM, argc int, defaults []*Object, keys []*Object, name string) *Object

MakeCode creates a new code object

func MakeError

func MakeError(elements ...*Object) *Object

MakeError creates an error object with the given data

func MakeList

func MakeList(count int, val *Object) *Object

MakeList creates a list of length count, with all values set to val

func MakeStruct

func MakeStruct(capacity int) *Object

MakeStruct - create an empty <struct> object with the specified capacity

func NewObject

func NewObject(variant *Object, value interface{}) *Object

NewObject is the constructor for externally defined objects, where the value is an interface{}.

func Number

func Number(f float64) *Object

Number - create a Number object for the given value

func Primitive

func Primitive(name string, fun PrimitiveFunction, result *Object, args []*Object, rest *Object, defaults []*Object, keys []*Object) *Object

Primitive creates a primitive function

func Random

func Random(min float64, max float64) *Object

Random returns a random value within the given range

func RandomList

func RandomList(size int, min float64, max float64) *Object

RandomList returns a list of random numbers with the given size and range

func Reverse

func Reverse(lst *Object) *Object

Reverse reverses a linked list

func SlurpFile

func SlurpFile(path string) (*Object, error)

SlurpFile - return the file contents as a string

func String

func String(s string) *Object

String - create a new string object

func StringCharacters

func StringCharacters(s *Object) []*Object

StringCharacters - return a slice of <character> objects that represent the string

func StringJoin

func StringJoin(seq *Object, delims *Object) (*Object, error)

StringJoin joins a string with the given delimters

func StringRef

func StringRef(s *Object, idx int) *Object

StringRef - return the <character> object at the specified string index

func StringSplit

func StringSplit(obj *Object, delims *Object) (*Object, error)

StringSplit splits a string by the delimiters

func Struct

func Struct(fieldvals []*Object) (*Object, error)

Struct - create a new <struct> object from the arguments, which can be other structs, or key/value pairs

func StructKeys

func StructKeys(s *Object) *Object

StructKeys returns the keys of the struct

func StructValues

func StructValues(s *Object) *Object

StructValues returns a list of the values of the struct

func Timestamp

func Timestamp(t time.Time) *Object

Timestamp returns a string timestamp

func ToArray

func ToArray(obj *Object) (*Object, error)

ToArray - convert the object to an <array>, if possible

func ToBlob

func ToBlob(obj *Object) (*Object, error)

ToBlob - convert argument to a blob, if possible.

func ToCharacter

func ToCharacter(c *Object) (*Object, error)

ToCharacter - convert object to a <character> object, if possible

func ToInt

func ToInt(o *Object) (*Object, error)

ToInt - convert the object to an integer number, if possible

func ToList

func ToList(obj *Object) (*Object, error)

ToList - convert the argument to a List, if possible

func ToNumber

func ToNumber(o *Object) (*Object, error)

ToNumber - convert object to a number, if possible

func ToString

func ToString(a *Object) (*Object, error)

ToString - convert the object to a string, if possible

func ToStruct

func ToStruct(obj *Object) (*Object, error)

ToStruct converts an object to a struct

func Value

func Value(obj *Object) *Object

Value returns the result of dereferencing the object

func (*Object) Error

func (lob *Object) Error() string

Error converts the error to a string

func (*Object) String

func (lob *Object) String() string

String returns the string representation of the object

type PrimitiveFunction

type PrimitiveFunction func(argv []*Object) (*Object, error)

PrimitiveFunction is the native go function signature for all Vesper primitive functions

type VM

type VM struct {
	StackSize    int
	Symbols      map[string]*Object
	MacroMap     map[*Object]*Macro
	ConstantsMap map[*Object]int
	Constants    []*Object
	Extensions   []Extension
	Flags        Flags
}

VM - the Vesper VM

func CloneVM

func CloneVM(copy *VM) *VM

CloneVM creates a clone of the original VM

func NewVM

func NewVM() *VM

NewVM creates a new VM

func (*VM) AddVesperDirectory

func (vm *VM) AddVesperDirectory(dirname string)

AddVesperDirectory adds a directory to the load path

func (*VM) Compile

func (vm *VM) Compile(expr *Object) (*Object, error)

Compile - compile the source into a code object.

func (*VM) CompileFile

func (vm *VM) CompileFile(name string) (*Object, error)

CompileFile compiles a file and returns a String object or an error caveats: when you compile a file, you actually run it. This is so we can handle imports and macros correctly.

func (*VM) DefineFunction

func (vm *VM) DefineFunction(name string, fun PrimitiveFunction, result *Object, args ...*Object)

DefineFunction registers a primitive function to the specified global name

func (*VM) DefineFunctionKeyArgs

func (vm *VM) DefineFunctionKeyArgs(name string, fun PrimitiveFunction, result *Object, args []*Object, defaults []*Object, keys []*Object)

DefineFunctionKeyArgs registers a primitive function with keyword arguments to the specified global name

func (*VM) DefineFunctionOptionalArgs

func (vm *VM) DefineFunctionOptionalArgs(name string, fun PrimitiveFunction, result *Object, args []*Object, defaults ...*Object)

DefineFunctionOptionalArgs registers a primitive function with optional arguments to the specified global name

func (*VM) DefineFunctionRestArgs

func (vm *VM) DefineFunctionRestArgs(name string, fun PrimitiveFunction, result *Object, rest *Object, args ...*Object)

DefineFunctionRestArgs registers a primitive function with Rest arguments to the specified global name

func (*VM) DefineGlobal

func (vm *VM) DefineGlobal(name string, obj *Object)

DefineGlobal binds the value to the global name

func (*VM) DefineMacro

func (vm *VM) DefineMacro(name string, fun PrimitiveFunction)

DefineMacro registers a primitive macro with the specified name.

func (*VM) Eval

func (vm *VM) Eval(expr *Object) (*Object, error)

Eval evaluates an expression

func (*VM) Execute

func (vm *VM) Execute(code *Code, args []*Object) (*Object, error)

Execute runs the given code with the given arguments

func (*VM) GetKeywords

func (vm *VM) GetKeywords() []*Object

GetKeywords - return a slice of Vesper primitive reserved words

func (*VM) GetMacro

func (vm *VM) GetMacro(sym *Object) *Macro

GetMacro - return the macro for the symbol, or nil if not defined

func (*VM) Globals

func (vm *VM) Globals() []*Object

Globals - return a slice of all defined global symbols

func (*VM) Init

func (vm *VM) Init(extns ...Extension) *VM

Init initialise the base environment and extensions

func (*VM) InitPrimitives

func (vm *VM) InitPrimitives()

InitPrimitives defines the global functions/variables/macros for the top level environment

func (*VM) Intern

func (vm *VM) Intern(name string) *Object

Intern - internalize the name into the global symbol table

func (*VM) KeywordName

func (vm *VM) KeywordName(t *Object) (*Object, error)

KeywordName returns the keyword as a string

func (*VM) Load

func (vm *VM) Load(name string) error

Load checks for a loadable module and loads it, if it exists

func (*VM) LoadFile

func (vm *VM) LoadFile(file string) error

LoadFile loads and executes a file returning any error

func (*VM) Macroexpand

func (vm *VM) Macroexpand(expr *Object) (*Object, error)

Macroexpand - return the expansion of all macros in the object and return the result

func (*VM) Macros

func (vm *VM) Macros() []*Object

Macros - return a slice of all defined macros

func (*VM) Read

func (vm *VM) Read(input *Object, keys *Object) (*Object, error)

Read - only reads the first item in the input, along with how many characters it read for subsequence calls, you can slice the string to continue

func (*VM) ReadAll

func (vm *VM) ReadAll(input *Object, keys *Object) (*Object, error)

ReadAll - read all items in the input, returning a list of them.

func (*VM) Run

func (vm *VM) Run(args ...string)

Run the given files in the vesper vm

func (*VM) SetFlags

func (vm *VM) SetFlags(v bool, d bool, i bool)

SetFlags - set various flags controlling the vm

func (*VM) Symbol

func (vm *VM) Symbol(names []*Object) (*Object, error)

Symbol creates a symbol from the given objects

func (*VM) ToKeyword

func (vm *VM) ToKeyword(obj *Object) (*Object, error)

ToKeyword converts the object to a keyword, if possible

func (*VM) ToSymbol

func (vm *VM) ToSymbol(obj *Object) (*Object, error)

ToSymbol converts the object to a symbol, or returns an error if the object cannot be converted.

func (*VM) TypeName

func (vm *VM) TypeName(t *Object) (*Object, error)

TypeName returns the name of the type

func (*VM) Use

func (vm *VM) Use(sym *Object) error

Use is a synonym for load

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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