Documentation ¶
Index ¶
- Variables
- func AddVileDirectory(dirname string)
- func AsByteValue(obj *Object) (byte, error)
- func AsFloat64Value(obj *Object) (float64, error)
- func AsInt64Value(obj *Object) (int64, error)
- func AsIntValue(obj *Object) (int, error)
- func AsRuneValue(c *Object) (rune, error)
- func AsStringValue(obj *Object) (string, error)
- func BoolValue(obj *Object) bool
- func Cleanup()
- func DefineFunction(name string, fun PrimitiveFunction, result *Object, args ...*Object)
- func DefineFunctionKeyArgs(name string, fun PrimitiveFunction, result *Object, args []*Object, ...)
- func DefineFunctionOptionalArgs(name string, fun PrimitiveFunction, result *Object, args []*Object, ...)
- func DefineFunctionRestArgs(name string, fun PrimitiveFunction, result *Object, rest *Object, ...)
- func DefineGlobal(name string, obj *Object)
- func DefineMacro(name string, fun PrimitiveFunction)
- func EncodeString(s string) string
- func Equal(o1 *Object, o2 *Object) bool
- func Error(errkey *Object, args ...interface{}) error
- func ExpandFilePath(path string) string
- func Fatal(args ...interface{})
- func FindModuleByName(moduleName string) (string, error)
- func FindModuleFile(name string) (string, error)
- func Float64Value(obj *Object) float64
- func GetMacro(sym *Object) *macro
- func Has(obj *Object, key *Object) (bool, error)
- func Identical(o1 *Object, o2 *Object) bool
- func Import(sym *Object) error
- func Init(extns ...Extension)
- func InitPrimitives()
- func Int64Value(obj *Object) int64
- func IntValue(obj *Object) int
- func IsBoolean(obj *Object) bool
- func IsCharacter(obj *Object) bool
- func IsCode(obj *Object) bool
- func IsDefined(sym *Object) bool
- func IsDirectoryReadable(path string) bool
- func IsError(o interface{}) bool
- func IsFileReadable(path string) bool
- func IsFloat(obj *Object) bool
- func IsFunction(obj *Object) bool
- func IsInstance(obj *Object) bool
- func IsInt(obj *Object) bool
- func IsKeyword(obj *Object) bool
- func IsList(obj *Object) bool
- func IsNull(obj *Object) bool
- func IsNumber(obj *Object) bool
- func IsPrimitiveType(tag *Object) bool
- func IsString(obj *Object) bool
- func IsStruct(obj *Object) bool
- func IsSymbol(obj *Object) bool
- func IsType(obj *Object) bool
- func IsValidKeywordName(s string) bool
- func IsValidStructKey(o *Object) bool
- func IsValidSymbolName(name string) bool
- func IsValidTypeName(s string) bool
- func IsVector(obj *Object) bool
- func ListEqual(lst *Object, a *Object) bool
- func ListLength(lst *Object) int
- func Load(name string) error
- func LoadFile(file string) error
- func Macro(name *Object, expander *Object) *macro
- func Main(extns ...Extension)
- func NumberEqual(f1 float64, f2 float64) bool
- func Pretty(obj *Object) string
- func PrettyAll(obj *Object) string
- func Print(args ...interface{})
- func Println(args ...interface{})
- func Put(obj *Object, key *Object, val *Object)
- func RandomSeed(n int64)
- func ReadEvalPrintLoop()
- func Round(f float64) float64
- func Run(args ...string)
- func RunStringEval(vileCode string) error
- func RuneValue(obj *Object) rune
- func SetFlags(o bool, v bool, d bool, t bool, i bool)
- func SpitFile(path string, data string) error
- func StringLength(s string) int
- func StringValue(obj *Object) string
- func StructEqual(s1 *Object, s2 *Object) bool
- func StructLength(strct *Object) int
- func Unput(obj *Object, key *Object)
- func VM(stackSize int) *vm
- func VectorEqual(v1 *Object, v2 *Object) bool
- func Write(obj *Object) string
- func WriteAll(obj *Object) string
- type Code
- type Extension
- type Object
- func Caar(lst *Object) *Object
- func Cadar(lst *Object) *Object
- func Cadddr(lst *Object) *Object
- func Caddr(lst *Object) *Object
- func Cadr(lst *Object) *Object
- func Car(lst *Object) *Object
- func Cdar(lst *Object) *Object
- func Cddddr(lst *Object) *Object
- func Cdddr(lst *Object) *Object
- func Cddr(lst *Object) *Object
- func Cdr(lst *Object) *Object
- func Character(c rune) *Object
- func Closure(code *Code, frame *frame) *Object
- func Compile(expr *Object) (*Object, error)
- func CompileFile(name string) (*Object, error)
- func Concat(seq1 *Object, seq2 *Object) (*Object, error)
- func Cons(car *Object, cdr *Object) *Object
- func Continuation(frame *frame, ops []int, pc int, stack []*Object) *Object
- func CopyVector(vec *Object) *Object
- func ErrorData(err *Object) *Object
- func Eval(expr *Object) (*Object, error)
- func Flatten(lst *Object) *Object
- func Get(obj *Object, key *Object) (*Object, error)
- func GetGlobal(sym *Object) *Object
- func GetKeywords() []*Object
- func Globals() []*Object
- func Instance(tag *Object, val *Object) (*Object, error)
- func Int(n int64) *Object
- func Intern(name string) *Object
- func KeywordName(t *Object) (*Object, error)
- func List(values ...*Object) *Object
- func ListFromValues(values []*Object) *Object
- func Macroexpand(expr *Object) (*Object, error)
- func Macros() []*Object
- func MakeCode(argc int, defaults []*Object, keys []*Object, name string) *Object
- func MakeError(elements ...*Object) *Object
- func MakeList(count int, val *Object) *Object
- func MakeStruct(capacity int) *Object
- func MakeVector(size int, init *Object) *Object
- func NewObject(variant *Object, value interface{}) *Object
- func Number(f float64) *Object
- func Primitive(name string, fun PrimitiveFunction, result *Object, args []*Object, ...) *Object
- func Random(min float64, max float64) *Object
- func RandomList(size int, min float64, max float64) *Object
- func Read(input *Object, keys *Object) (*Object, error)
- func ReadAll(input *Object, keys *Object) (*Object, error)
- func Reverse(lst *Object) *Object
- func SlurpFile(path string) (*Object, error)
- func String(s string) *Object
- func StringCharacters(s *Object) []*Object
- func StringJoin(seq *Object, delims *Object) (*Object, error)
- func StringRef(s *Object, idx int) *Object
- func StringSplit(obj *Object, delims *Object) (*Object, error)
- func Struct(fieldvals []*Object) (*Object, error)
- func StructKeys(s *Object) *Object
- func StructValues(s *Object) *Object
- func Symbol(names []*Object) (*Object, error)
- func Symbols() []*Object
- func ToCharacter(c *Object) (*Object, error)
- func ToInt(o *Object) (*Object, error)
- func ToKeyword(obj *Object) (*Object, error)
- func ToList(obj *Object) (*Object, error)
- func ToNumber(o *Object) (*Object, error)
- func ToString(a *Object) (*Object, error)
- func ToStruct(obj *Object) (*Object, error)
- func ToSymbol(obj *Object) (*Object, error)
- func ToVector(obj *Object) (*Object, error)
- func TypeName(t *Object) (*Object, error)
- func Value(obj *Object) *Object
- func Vector(elements ...*Object) *Object
- func VectorFromElements(elements []*Object, count int) *Object
- func VectorFromElementsNoCopy(elements []*Object) *Object
- type PrimitiveFunction
Constants ¶
This section is empty.
Variables ¶
var AnyType = Intern("<any>")
AnyType is a pseudo type specifier indicating any type
var Apply = &Object{Type: FunctionType}
Apply is a primitive instruction to apply a function to a list of arguments
var ArgumentErrorKey = Intern("argument-error:")
ArgumentErrorKey
var BooleanType = Intern("<boolean>")
BooleanType is the type of true and false
var CallCC = &Object{Type: FunctionType}
CallCC is a primitive instruction to executable (restore) a continuation
var CallSymbol = Intern("call")
var CharacterType = Intern("<character>")
CharacterType is the type of all characters
var ClosureSymbol = Intern("closure")
var CodeType = Intern("<code>")
CodeType is the type of compiled code
var DefglobalSymbol = Intern("defglobal")
var DefmacroSymbol = Intern("macro")
var EmptyList = initEmpty()
EmptyList - the value of (), terminates linked lists
var EmptyString = String("")
EmptyString
var EmptyStruct = MakeStruct(0)
EmptyStruct - a <struct> with no bindings
var ErrorKey = Intern("error:")
ErrorKey - used to generic errors
var ErrorType = Intern("<error>")
ErrorType is the type of all errors
var False = &Object{Type: BooleanType, fval: 0}
False is the singleton boolean false value
var FuncSymbol = Intern("func")
var FunctionType = Intern("<function>")
FunctionType is the type of all functions
var GlobalSymbol = Intern("global")
var HTTPErrorKey = Intern("http-error:")
HttpErrorKey
var IOErrorKey = Intern("io-error:")
IOErrorKey
var ImportSymbol = Intern("import")
var InterruptKey = Intern("interrupt:")
InterruptKey
var JumpSymbol = Intern("jump")
var JumpfalseSymbol = Intern("jumpfalse")
var ListType = Intern("<list>")
ListType is the type of all lists
var LiteralSymbol = Intern("literal")
var LocalSymbol = Intern("local")
var MacroErrorKey = Intern("macro-error:")
MacroErrorKey
var MinusOne = Number(-1)
MinusOne is the Vile -1 value
var Null = &Object{Type: NullType}
Null is Vile's version of nil. It means "nothing" and is not the same as EmptyList. It is a singleton.
var NullType = Intern("<null>")
NullType the type of the null object
var NumberType = Intern("<number>")
NumberType is the type of all numbers
var One = Number(1)
One is the Vile 1 value
var PopSymbol = Intern("pop")
var QuasiquoteSymbol = Intern("quasiquote")
var QuoteSymbol = Intern("quote")
var ReturnSymbol = Intern("return")
var SetlocalSymbol = Intern("setlocal")
var Spawn = &Object{Type: FunctionType}
Apply is a primitive instruction to apply a function to a list of arguments
var StringType = Intern("<string>")
StringType is the type of all strings
var StructSymbol = Intern("struct")
var StructType = Intern("<struct>")
VectorType is the type of all structs
var SyntaxErrorKey = Intern("syntax-error:")
SyntaxErrorKey
var TailcallSymbol = Intern("tailcall")
var True = &Object{Type: BooleanType, fval: 1}
True is the singleton boolean true value
var UndefineSymbol = Intern("undefine")
var UnquoteSymbol = Intern("unquote")
var UnquoteSymbolSplicing = Intern("unquote-splicing")
var VectorSymbol = Intern("vector")
var VectorType = Intern("<vector>")
VectorType is the type of all vectors
var Version = "(development version)"
Version - this version of vole
var Zero = Number(0)
Zero is the Vile 0 value
Functions ¶
func AddVileDirectory ¶
func AddVileDirectory(dirname string)
func AsByteValue ¶
func AsFloat64Value ¶
func AsInt64Value ¶
func AsIntValue ¶
func AsRuneValue ¶
AsCharacter - return the native rune representation of the character object, if possible
func AsStringValue ¶
AsStringValue - return the native string representation of the object, if possible
func DefineFunction ¶
func DefineFunction(name string, fun PrimitiveFunction, result *Object, args ...*Object)
Register a primitive function to the specified global name
func DefineFunctionKeyArgs ¶
func DefineFunctionKeyArgs(name string, fun PrimitiveFunction, result *Object, args []*Object, defaults []*Object, keys []*Object)
Register a primitive function with keyword arguments to the specified global name
func DefineFunctionOptionalArgs ¶
func DefineFunctionOptionalArgs(name string, fun PrimitiveFunction, result *Object, args []*Object, defaults ...*Object)
Register a primitive function with optional arguments to the specified global name
func DefineFunctionRestArgs ¶
func DefineFunctionRestArgs(name string, fun PrimitiveFunction, result *Object, rest *Object, args ...*Object)
Register a primitive function with Rest arguments to the specified global name
func DefineMacro ¶
func DefineMacro(name string, fun PrimitiveFunction)
Register a primitive macro with the specified name.
func EncodeString ¶
EncodeString - return the encoded form of a string value
func Error ¶
Error - creates a new Error from the arguments. The first is an actual Vile keyword object, the rest are interpreted as/converted to strings
func ExpandFilePath ¶
func FindModuleByName ¶
func FindModuleFile ¶
func Float64Value ¶
Float64Value - return native float64 value of the object
func GetMacro ¶
func GetMacro(sym *Object) *macro
GetMacro - return the macro for the symbol, or nil if not defined
func InitPrimitives ¶
func InitPrimitives()
func Int64Value ¶
Int64Value - return native int64 value of the object
func IsCharacter ¶
func IsDirectoryReadable ¶
IsDirectoryReadable - return true of the directory is readable
func IsFileReadable ¶
IsFileReadable - return true of the file is readable
func IsFunction ¶
func IsInstance ¶
instances have arbitrary Type symbols, all we can check is that the instanceValue is set
func IsPrimitiveType ¶
func IsValidKeywordName ¶
func IsValidStructKey ¶
IsValidStructKey - return true of the object is a valid <struct> key.
func IsValidSymbolName ¶
func IsValidTypeName ¶
func ListLength ¶
func NumberEqual ¶
Equal returns true if the object is equal to the argument, within epsilon
func RandomSeed ¶
func RandomSeed(n int64)
func ReadEvalPrintLoop ¶
func ReadEvalPrintLoop()
func RunStringEval ¶
func StringValue ¶
StringValue - return native string value of the object
func StructEqual ¶
Equal returns true if the object is equal to the argument
func StructLength ¶
StructLength - return the length (field count) of the <struct> object
func VectorEqual ¶
VectorEqual - return true of the two vectors are equal, i.e. the same length and all the elements are also equal
Types ¶
type Code ¶
type Code struct {
// contains filtered or unexported fields
}
Code - compiled Vile bytecode
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 is the Vile object: a union of all possible primitive types. Which fields are used depends on the variant the variant is a type object i.e. Intern("<string>"). For arbitrary embedded extension types, the Value field is an interface{}. It is used for Channels internally, but is generally useful for app-specific native types when extending Vile.
var KeywordType *Object // bootstrapped in initSymbolTable => Intern("<keyword>")
KeywordType is the type of all keywords
var SymbolType *Object // bootstrapped in initSymbolTable = Intern("<symbol>")
SymbolType is the type of all symbols
var TypeType *Object // bootstrapped in initSymbolTable => Intern("<type>")
TypeType is the metatype, the type of all types | Wikipedia => "... kind (a type of a type, or metatype) ..."
func CompileFile ¶
caveats: when you compile a file, you actually run it. This is so we can handle imports and macros correctly.
func Get ¶
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 ¶
GetGlobal - return the global value for the specified symbol, or nil if the symbol is not defined.
func GetKeywords ¶
func GetKeywords() []*Object
GetKeywords - return a slice of Vile primitive reserved words Vile keywords e.g: ("fn" main(n1 n2) (+ n1 n2))
func ListFromValues ¶
func Macroexpand ¶
Macroexpand - return the expansion of all macros in the object and return the result
func MakeStruct ¶
MakeStruct - create an empty <struct> object with the specified capacity
func MakeVector ¶
MakeVector - create a new <vector> object of the specified size, with all elements initialized to the specified value
func NewObject ¶
NewObject is the constructor for externally defined objects, where the value is an interface{}.
func Primitive ¶
func Primitive(name string, fun PrimitiveFunction, result *Object, args []*Object, rest *Object, defaults []*Object, keys []*Object) *Object
used in module.go - five places
func Read ¶
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 StringCharacters ¶
StringCharacters - return a slice of <character> objects that represent the string
func Struct ¶
Struct - create a new <struct> object from the arguments, which can be other structs, or key/value pairs
func StructKeys ¶
func StructValues ¶
func ToCharacter ¶
ToCharacter - convert object to a <character> object, if possible
func VectorFromElements ¶
VectorFromElements - return a new <vector> object from the given slice of elements. The slice is copied.
func VectorFromElementsNoCopy ¶
VectorFromElementsNoCopy - create a new <vector> object from the given slice of elements. The slice is NOT copied.
type PrimitiveFunction ¶
PrimitiveFunction is the native go function signature for all Vile primitive functions