scheme

package module
v0.0.0-...-49dbbbd Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 15 Imported by: 1

README

R6RS Scheme in Go

This Scheme implementation provides mostly R6RS compliant scheme written in Go. The system has a compiler that translates the scheme program into a byte code and a virtual machine that executes the code. It will implement all necessary Scheme features, including tail calls and continuations.

The compiler implements a simple API for processing S-expressions. The API gives a clean and high-level abstraction, for example, configuration file parsing, data encoding and decoding, and other structured data operations.

Language

The implementation follows the R6RS specification but makes the following non-compliant design decisions:

  • The language is type aware and the compiler uses type inference to decide types for all expressions. The root of the type tree is any which is the supertype of all types. Please, see the type tree definition below.
  • Numeric tower:
    • Has exact and inexact integer and floating point types. The exact numbers use Go's big.Int and big.Float types and inexact numbers use int64 and float64 respectively
    • Operations between exact and inexact numbers generate converts to exact values (int64 + big.Int = big.Int), when the R6RS specifies that the result should be inexact.
  • Global definitions are final and can't be redefined. However, it is possible to set their values if the new values are type-compatible with the variable definition. You can assing values of same type or subtype to a global variable.
  • The define-constant syntax defines constant variables which can't be redefined.
  • Several unary (pair?, null?, zero?, car, cdr, not) and binary (cons, +, -, *, /, =, <, >, <=, >=) functions are inlined and implemented as VM bytecode operands. The runtime also implements the funtions as procedures so it is possible to apply them to arguments.
Types

The compiler uses type inference to resolve types for all expressions. The type hierarchy is as follows:

Any
  |
  +-- Nil
  |
  +-- Boolean
  |
  +-- String
  |
  +-- Character
  |
  +-- Symbol
  |
  +-- Vector
  |
  +-- Bytevector
  |
  +-- Number
  |     |
  |     +-- ExactInteger (big.Int)
  |     |     |
  |     |     +-- InxactInteger (int64)
  |     |
  |     +-- ExactFloat (big.Float)
  |           |
  |           +-- InxactFloat (float64)
  |
  +-- Lambda(Type...) Type
  |
  +-- Pair(Type, Type)

TODO

  • Shortlist
    • Top-levels with (import)
    • Library local symbols
  • API
    • Marshal / unmarshal
  • VM
    • Tail-call within same function as jump
    • 5.8. Multiple return values
    • Error handlers
    • Call with current continuation
  • Compiler
    • 7.1. Library form
      • import/export
      • rename
      • xxx
    • 8. Top-level programs
    • 9. Primitive syntax
      • 9.2. Macros
    • 10. Expansion process
  • 11. Base Library (rnrs base (6))
    • 11.2.2. Syntax definitions
      • define-syntax
    • 11.3. Bodies
    • 11.7. Arithmetic
      • complex?
      • real?
      • rational?
      • real-valued?
      • rational-valued?
      • integer-valued?
      • inexact
      • exact
      • finite?
      • infinite?
      • nan?
      • abs
      • div-and-mod
      • div
      • div0-and-mod0
      • div0
      • mod0
      • gcm
      • lcm
      • numerator
      • denominator
      • floor
      • ceiling
      • truncate
      • round
      • rationalize
      • exp
      • log
      • sin
      • cos
      • tan
      • asin
      • acos
      • atan
      • sqrt
      • exact-integer-sqrt
      • make-rectangular
      • make-polar
      • real-part
      • imag-part
      • magnitude
      • angle
      • number->string
      • string->number
    • 11.16. Iteration
      • Named let
    • 11.17. Quasiquotation
      • quasiquote
      • unquote
      • unquote-splicing
  • R6RS Libraries
    • 1. Unicode (rnrs unicode (6))
      • char-foldcase
      • char-general-category
      • string-titlecase
      • string-foldcase
      • string-normalize-nfd
      • string-normalize-nfkd
      • string-normalize-nfc
      • string-normalize-nfkc
    • 2. Bytevectors (rnrs bytevectors (6))
      • endianness
      • native-endianness
      • bytevector-u8-set!
      • bytevector-s8-set!
      • bytevector->u8-list
      • u8-list->bytevector
      • xxx
    • 3. List utilities (rnrs lists (6))
      • find
      • for-all
      • exists
      • filter
      • partition
      • fold-left
      • fold-right
      • remp
      • remove
      • remv
      • remq
      • cons*
    • 4. Sorting (rnrs sorting (6))
      • list-sort
      • vector-sort
      • vector-sort!
    • 5. Control structures (rnrs control (6))
      • when
      • unless
      • do
      • case-lambda
    • 6. Records
    • 7. Exceptions and conditions
    • 8. I/O
      • 8.2. Port I/O (rnrs io ports (6))
      • 8.3. Simple I/O (rnrs io simple (6))
        • eof-object
        • eof-object?
        • call-with-input-file
        • call-with-output-file
        • current-input-port
        • with-input-from-file
        • with-output-to-file
        • open-input-file
        • open-output-file
        • close-input-port
        • close-output-port
        • read-char
        • peek-char
        • read
        • write-char
    • 9. File system (rnrs files (6))
    • 10. Command-line access and exit values (rnrs programs (6))
    • 11. Arithmetic
    • 12. syntax-case (rnrs syntax-case (6))
    • 13. Hashtables (rnrs hashtables (6))
    • 14. Enumerations (rnrs enums (6))
    • 15. Composite library (rnrs (6))
    • 16. Eval (rnrs eval (6))
    • 17. Mutable pairs (rnrs mutable-pairs (6))
    • 18. Mutable strings (rnrs mutable-strings (6))
      • string-set!
      • string-fill!
    • 19. R5RS compatibility (rnrs r5rs (6))
      • exact->inexact
      • inexact->exact
      • quotient
      • remainder
      • modulo
      • delay
      • force
      • null-environment
      • scheme-report-environment

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorInvalidList = errors.New("invalid list")

ErrorInvalidList is used to indicate when a malformed or otherwise invalid list is passed to list functions.

Functions

func BooleanToScheme

func BooleanToScheme(v bool) string

BooleanToScheme returns the bool as Scheme boolean literal.

func CharacterToScheme

func CharacterToScheme(r rune) string

CharacterToScheme returns the rune as Scheme character literal.

func Eq

func Eq(a, b Value) bool

Eq tests if the values are eq?.

func Equal

func Equal(a, b Value) bool

Equal tests if the values are equal?.

func Int64

func Int64(v Value) (int64, error)

Int64 returns the number value as int64 integer number. The function returns an error if the argument is not a number.

func IsBoolean

func IsBoolean(value Value) (v bool, ok bool)

IsBoolean tests if the value is boolean.

func IsString

func IsString(value Value) (v string, ok bool)

IsString tests if the value is string.

func IsTrue

func IsTrue(v Value) bool

IsTrue tests if the argument value is true according to Scheme truth semantics i.e. the value is true unless it is boolean #f.

func ListLength

func ListLength(list Value) (int, bool)

ListLength check if the argument value is a valid Scheme list.

func Map

func Map(f func(idx int, v Value) error, list Value) error

Map maps function for each element of the list. The function returns nil if the argument list is a list and map functions returns nil for each of its element.

func MapPairs

func MapPairs(f func(idx int, p Pair) error, list Value) error

MapPairs maps function for each pair of the list. The function returns nil if the argument list is a list and map functions returns nil for each of its element.

func StringToScheme

func StringToScheme(s string) string

StringToScheme returns the string as Scheme string literal.

func ToScheme

func ToScheme(v Value) string

ToScheme returns a Scheme representation of the value.

func ToString

func ToString(v Value) string

ToString returns a display representation of the value.

Types

type AST

type AST interface {
	Locator() Locator
	Equal(o AST) bool
	Type(ctx types.Ctx) *types.Type
	Typecheck(lib *Library, round int) error
	Bytecode(lib *Library) error
}

AST defines an abstract syntax tree entry

type ASTAnd

type ASTAnd struct {
	From  Locator
	Exprs []AST
}

ASTAnd implements (and ...) syntax.

func (*ASTAnd) Bytecode

func (ast *ASTAnd) Bytecode(lib *Library) error

Bytecode implements AST.Bytecode.

func (*ASTAnd) Equal

func (ast *ASTAnd) Equal(o AST) bool

Equal implements AST.Equal.

func (*ASTAnd) Locator

func (ast *ASTAnd) Locator() Locator

Locator implements AST.Locator.

func (*ASTAnd) Type

func (ast *ASTAnd) Type(ctx types.Ctx) *types.Type

Type implements AST.Type.

func (*ASTAnd) Typecheck

func (ast *ASTAnd) Typecheck(lib *Library, round int) error

Typecheck implements AST.Typecheck.

type ASTApply

type ASTApply struct {
	From   Locator
	Lambda AST
	Args   AST
	Tail   bool
}

ASTApply implements apply syntax.

func (*ASTApply) Bytecode

func (ast *ASTApply) Bytecode(lib *Library) error

Bytecode implements AST.Bytecode.

func (*ASTApply) Equal

func (ast *ASTApply) Equal(o AST) bool

Equal implements AST.Equal.

func (*ASTApply) Locator

func (ast *ASTApply) Locator() Locator

Locator implements AST.Locator.

func (*ASTApply) Type

func (ast *ASTApply) Type(ctx types.Ctx) *types.Type

Type implements AST.Type.

func (*ASTApply) Typecheck

func (ast *ASTApply) Typecheck(lib *Library, round int) error

Typecheck implements AST.Typecheck.

type ASTCall

type ASTCall struct {
	From     Locator
	Inline   bool
	InlineOp Operand
	Func     AST
	ArgFrame *EnvFrame
	Args     []AST
	ArgLocs  []Locator
	Tail     bool
}

ASTCall implements function call syntax.

func (*ASTCall) Bytecode

func (ast *ASTCall) Bytecode(lib *Library) error

Bytecode implements AST.Bytecode.

func (*ASTCall) Equal

func (ast *ASTCall) Equal(o AST) bool

Equal implements AST.Equal.

func (*ASTCall) Locator

func (ast *ASTCall) Locator() Locator

Locator implements AST.Locator.

func (*ASTCall) String

func (ast *ASTCall) String() string

func (*ASTCall) Type

func (ast *ASTCall) Type(ctx types.Ctx) *types.Type

Type implements AST.Type.

func (*ASTCall) Typecheck

func (ast *ASTCall) Typecheck(lib *Library, round int) error

Typecheck implements AST.Typecheck.

type ASTCallUnary

type ASTCallUnary struct {
	From Locator
	Op   Operand
	I    int
	Arg  AST
}

ASTCallUnary implements inlined unary function calls.

func (*ASTCallUnary) Bytecode

func (ast *ASTCallUnary) Bytecode(lib *Library) error

Bytecode implements AST.Bytecode.

func (*ASTCallUnary) Equal

func (ast *ASTCallUnary) Equal(o AST) bool

Equal implements AST.Equal.

func (*ASTCallUnary) Locator

func (ast *ASTCallUnary) Locator() Locator

Locator implements AST.Locator.

func (*ASTCallUnary) Type

func (ast *ASTCallUnary) Type(ctx types.Ctx) *types.Type

Type implements AST.Type.

func (*ASTCallUnary) Typecheck

func (ast *ASTCallUnary) Typecheck(lib *Library, round int) error

Typecheck implements AST.Typecheck.

type ASTCase

type ASTCase struct {
	From        Locator
	Choices     []*ASTCaseChoice
	ValueFrame  *EnvFrame
	EqvArgFrame *EnvFrame
	Expr        AST
	Tail        bool
	Captures    bool
}

ASTCase implements case syntax.

func (*ASTCase) Bytecode

func (ast *ASTCase) Bytecode(lib *Library) error

Bytecode implements AST.Bytecode.

func (*ASTCase) Equal

func (ast *ASTCase) Equal(o AST) bool

Equal implements AST.Equal.

func (*ASTCase) Locator

func (ast *ASTCase) Locator() Locator

Locator implements AST.Locator.

func (*ASTCase) Type

func (ast *ASTCase) Type(ctx types.Ctx) *types.Type

Type implements AST.Type.

func (*ASTCase) Typecheck

func (ast *ASTCase) Typecheck(lib *Library, round int) error

Typecheck implements AST.Typecheck.

type ASTCaseChoice

type ASTCaseChoice struct {
	From      Locator
	Datums    []Value
	DatumLocs []Locator
	Exprs     []AST
}

ASTCaseChoice implements a case choice.

func (*ASTCaseChoice) Equal

func (c *ASTCaseChoice) Equal(o *ASTCaseChoice) bool

Equal test if this choice is equal to the argument choice.

type ASTCond

type ASTCond struct {
	From     Locator
	Choices  []*ASTCondChoice
	Tail     bool
	Captures bool
}

ASTCond implements cond syntax.

func (*ASTCond) Bytecode

func (ast *ASTCond) Bytecode(lib *Library) error

Bytecode implements AST.Bytecode.

func (*ASTCond) Equal

func (ast *ASTCond) Equal(o AST) bool

Equal implements AST.Equal.

func (*ASTCond) Locator

func (ast *ASTCond) Locator() Locator

Locator implements AST.Locator.

func (*ASTCond) Type

func (ast *ASTCond) Type(ctx types.Ctx) *types.Type

Type implements AST.Type.

func (*ASTCond) Typecheck

func (ast *ASTCond) Typecheck(lib *Library, round int) error

Typecheck implements AST.Typecheck.

type ASTCondChoice

type ASTCondChoice struct {
	From           Locator
	Cond           AST
	Func           AST
	FuncValueFrame *EnvFrame
	FuncArgsFrame  *EnvFrame
	Exprs          []AST
}

ASTCondChoice implements a cond choice.

func (*ASTCondChoice) Equal

func (c *ASTCondChoice) Equal(o *ASTCondChoice) bool

Equal test if this choice is equal to the argument choice.

type ASTConstant

type ASTConstant struct {
	From  Locator
	Value Value
}

ASTConstant implements contant values.

func (*ASTConstant) Bytecode

func (ast *ASTConstant) Bytecode(lib *Library) error

Bytecode implements AST.Bytecode.

func (*ASTConstant) Equal

func (ast *ASTConstant) Equal(o AST) bool

Equal implements AST.Equal.

func (*ASTConstant) Locator

func (ast *ASTConstant) Locator() Locator

Locator implements AST.Locator.

func (*ASTConstant) String

func (ast *ASTConstant) String() string

func (*ASTConstant) Type

func (ast *ASTConstant) Type(ctx types.Ctx) *types.Type

Type implements AST.Type.

func (*ASTConstant) Typecheck

func (ast *ASTConstant) Typecheck(lib *Library, round int) error

Typecheck implements AST.Typecheck.

type ASTDefine

type ASTDefine struct {
	From  Locator
	Name  *Identifier
	Flags Flags
	Value AST
}

ASTDefine implements (define name value).

func (*ASTDefine) Bytecode

func (ast *ASTDefine) Bytecode(lib *Library) error

Bytecode implements AST.Bytecode.

func (*ASTDefine) Equal

func (ast *ASTDefine) Equal(o AST) bool

Equal implements AST.Equal.

func (*ASTDefine) Locator

func (ast *ASTDefine) Locator() Locator

Locator implements AST.Locator.

func (*ASTDefine) Type

func (ast *ASTDefine) Type(ctx types.Ctx) *types.Type

Type implements AST.Type.

func (*ASTDefine) Typecheck

func (ast *ASTDefine) Typecheck(lib *Library, round int) error

Typecheck implements AST.Typecheck.

type ASTIdentifier

type ASTIdentifier struct {
	From    Locator
	Name    string
	Binding *EnvBinding
	Global  *Identifier
	Init    AST
}

ASTIdentifier implements identifer references.

func (*ASTIdentifier) Bytecode

func (ast *ASTIdentifier) Bytecode(lib *Library) error

Bytecode implements AST.Bytecode.

func (*ASTIdentifier) Equal

func (ast *ASTIdentifier) Equal(o AST) bool

Equal implements AST.Equal.

func (*ASTIdentifier) Locator

func (ast *ASTIdentifier) Locator() Locator

Locator implements AST.Locator.

func (*ASTIdentifier) String

func (ast *ASTIdentifier) String() string

func (*ASTIdentifier) Type

func (ast *ASTIdentifier) Type(ctx types.Ctx) *types.Type

Type implements AST.Type.

func (*ASTIdentifier) Typecheck

func (ast *ASTIdentifier) Typecheck(lib *Library, round int) error

Typecheck implements AST.Typecheck.

type ASTIf

type ASTIf struct {
	From  Locator
	Cond  AST
	True  AST
	False AST
}

ASTIf implements if syntax.

func (*ASTIf) Bytecode

func (ast *ASTIf) Bytecode(lib *Library) error

Bytecode implements AST.Bytecode.

func (*ASTIf) Equal

func (ast *ASTIf) Equal(o AST) bool

Equal implements AST.Equal.

func (*ASTIf) Locator

func (ast *ASTIf) Locator() Locator

Locator implements AST.Locator.

func (*ASTIf) Type

func (ast *ASTIf) Type(ctx types.Ctx) *types.Type

Type implements AST.Type.

func (*ASTIf) Typecheck

func (ast *ASTIf) Typecheck(lib *Library, round int) error

Typecheck implements AST.Typecheck.

type ASTLambda

type ASTLambda struct {
	From        Locator
	Name        *Identifier
	Args        Args
	ArgBindings []*EnvBinding
	Body        []AST
	Env         *Env
	Captures    bool
	Define      bool
	Flags       Flags
}

ASTLambda implements lambda syntax.

func (*ASTLambda) Bytecode

func (ast *ASTLambda) Bytecode(lib *Library) error

Bytecode implements AST.Bytecode.

func (*ASTLambda) Equal

func (ast *ASTLambda) Equal(o AST) bool

Equal implements AST.Equal.

func (*ASTLambda) Locator

func (ast *ASTLambda) Locator() Locator

Locator implements AST.Locator.

func (*ASTLambda) Parametrize

func (ast *ASTLambda) Parametrize(ctx types.Ctx,
	params []*types.Type) *types.Type

Parametrize implements types.Parametrizer.

func (*ASTLambda) Type

func (ast *ASTLambda) Type(ctx types.Ctx) *types.Type

Type implements AST.Type.

func (*ASTLambda) Typecheck

func (ast *ASTLambda) Typecheck(lib *Library, round int) error

Typecheck implements AST.Typecheck.

type ASTLet

type ASTLet struct {
	From     Locator
	Kind     Keyword
	Captures bool
	Tail     bool
	Bindings []*ASTLetBinding
	Body     []AST
}

ASTLet implements let syntaxes.

func (*ASTLet) Bytecode

func (ast *ASTLet) Bytecode(lib *Library) error

Bytecode implements AST.Bytecode.

func (*ASTLet) Equal

func (ast *ASTLet) Equal(o AST) bool

Equal implements AST.Equal.

func (*ASTLet) Locator

func (ast *ASTLet) Locator() Locator

Locator implements AST.Locator.

func (*ASTLet) Type

func (ast *ASTLet) Type(ctx types.Ctx) *types.Type

Type implements AST.Type.

func (*ASTLet) Typecheck

func (ast *ASTLet) Typecheck(lib *Library, round int) error

Typecheck implements AST.Typecheck.

type ASTLetBinding

type ASTLetBinding struct {
	From    Locator
	Binding *EnvBinding
	Init    AST
}

ASTLetBinding implements a let binding.

type ASTOr

type ASTOr struct {
	From  Locator
	Exprs []AST
}

ASTOr implements (or ...) syntax.

func (*ASTOr) Bytecode

func (ast *ASTOr) Bytecode(lib *Library) error

Bytecode implements AST.Bytecode.

func (*ASTOr) Equal

func (ast *ASTOr) Equal(o AST) bool

Equal implements AST.Equal.

func (*ASTOr) Locator

func (ast *ASTOr) Locator() Locator

Locator implements AST.Locator.

func (*ASTOr) Type

func (ast *ASTOr) Type(ctx types.Ctx) *types.Type

Type implements AST.Type.

func (*ASTOr) Typecheck

func (ast *ASTOr) Typecheck(lib *Library, round int) error

Typecheck implements AST.Typecheck.

type ASTPragma

type ASTPragma struct {
	From       Locator
	Directives [][]Value
}

ASTPragma implements compiler pragmas.

func (*ASTPragma) Bytecode

func (ast *ASTPragma) Bytecode(lib *Library) error

Bytecode implements AST.Bytecode.

func (*ASTPragma) Equal

func (ast *ASTPragma) Equal(o AST) bool

Equal implements AST.Equal.

func (*ASTPragma) Locator

func (ast *ASTPragma) Locator() Locator

Locator implements AST.Locator.

func (*ASTPragma) Type

func (ast *ASTPragma) Type(ctx types.Ctx) *types.Type

Type implements AST.Type.

func (*ASTPragma) Typecheck

func (ast *ASTPragma) Typecheck(lib *Library, round int) error

Typecheck implements AST.Typecheck.

type ASTSequence

type ASTSequence struct {
	From  Locator
	Items []AST
}

ASTSequence implements a (begin ...) sequence.

func (*ASTSequence) Add

func (ast *ASTSequence) Add(item AST)

Add adds an item to the sequence.

func (*ASTSequence) Bytecode

func (ast *ASTSequence) Bytecode(lib *Library) error

Bytecode implements AST.Bytecode.

func (*ASTSequence) Equal

func (ast *ASTSequence) Equal(o AST) bool

Equal implements AST.Equal.

func (*ASTSequence) Locator

func (ast *ASTSequence) Locator() Locator

Locator implements AST.Locator.

func (*ASTSequence) Type

func (ast *ASTSequence) Type(ctx types.Ctx) *types.Type

Type implements AST.Type.

func (*ASTSequence) Typecheck

func (ast *ASTSequence) Typecheck(lib *Library, round int) error

Typecheck implements AST.Typecheck.

type ASTSet

type ASTSet struct {
	From    Locator
	Name    string
	Binding *EnvBinding
	Value   AST
}

ASTSet implements (set name value).

func (*ASTSet) Bytecode

func (ast *ASTSet) Bytecode(lib *Library) error

Bytecode implements AST.Bytecode.

func (*ASTSet) Equal

func (ast *ASTSet) Equal(o AST) bool

Equal implements AST.Equal.

func (*ASTSet) Locator

func (ast *ASTSet) Locator() Locator

Locator implements AST.Locator.

func (*ASTSet) Type

func (ast *ASTSet) Type(ctx types.Ctx) *types.Type

Type implements AST.Type.

func (*ASTSet) Typecheck

func (ast *ASTSet) Typecheck(lib *Library, round int) error

Typecheck implements AST.Typecheck.

type Args

type Args struct {
	Min   int
	Max   int
	Fixed []*TypedName
	Rest  *TypedName
}

Args specify lambda arguments.

func (Args) Equal

func (args Args) Equal(o Args) bool

Equal tests if the arguments are equal.

func (*Args) Init

func (args *Args) Init()

Init initializes argument limits and checks that all argument names are unique.

func (Args) String

func (args Args) String() string

type BigFloat

type BigFloat struct {
	F *big.Float
}

BigFloat implements exact floating point numbers.

func (*BigFloat) Eq

func (v *BigFloat) Eq(o Value) bool

Eq implements Value.Eq.

func (*BigFloat) Equal

func (v *BigFloat) Equal(o Value) bool

Equal implements Value.Equal.

func (*BigFloat) Scheme

func (v *BigFloat) Scheme() string

Scheme implements Value.Scheme.

func (*BigFloat) String

func (v *BigFloat) String() string

func (*BigFloat) Type

func (v *BigFloat) Type() *types.Type

Type implements Value.Type.

type BigInt

type BigInt struct {
	I *big.Int
}

BigInt implements exact integer numbers.

func (*BigInt) Eq

func (v *BigInt) Eq(o Value) bool

Eq implements Value.Eq.

func (*BigInt) Equal

func (v *BigInt) Equal(o Value) bool

Equal implements Value.Equal.

func (*BigInt) Scheme

func (v *BigInt) Scheme() string

Scheme implements Value.Scheme.

func (*BigInt) String

func (v *BigInt) String() string

func (*BigInt) Type

func (v *BigInt) Type() *types.Type

Type implements Value.Type.

type Boolean

type Boolean bool

Boolean implements boolean values.

func (Boolean) Eq

func (v Boolean) Eq(o Value) bool

Eq tests if the argument value is eq? to this value.

func (Boolean) Equal

func (v Boolean) Equal(o Value) bool

Equal tests if the argument value is equal to this value.

func (Boolean) Scheme

func (v Boolean) Scheme() string

Scheme returns the value as a Scheme string.

func (Boolean) String

func (v Boolean) String() string

func (Boolean) Type

func (v Boolean) Type() *types.Type

Type implements the Value.Type().

type Builtin

type Builtin struct {
	Name    string
	Aliases []string
	Args    []string
	Return  *types.Type
	Flags   Flags
	Native  Native
}

Builtin defines a built-in native function.

type Bytevector

type Bytevector []byte

Bytevector implements bytevector values.

func (Bytevector) Eq

func (v Bytevector) Eq(o Value) bool

Eq tests if the argument value is eq? to this value.

func (Bytevector) Equal

func (v Bytevector) Equal(o Value) bool

Equal tests if the argument value is equal to this value.

func (Bytevector) Scheme

func (v Bytevector) Scheme() string

Scheme returns the value as a Scheme string.

func (Bytevector) String

func (v Bytevector) String() string

func (Bytevector) Type

func (v Bytevector) Type() *types.Type

Type implements Value.Type.

type Character

type Character rune

Character implements character values.

func (Character) Eq

func (v Character) Eq(o Value) bool

Eq tests if the argument value is eq? to this value.

func (Character) Equal

func (v Character) Equal(o Value) bool

Equal tests if the argument value is equal to this value.

func (Character) Scheme

func (v Character) Scheme() string

Scheme returns the value as a Scheme string.

func (Character) String

func (v Character) String() string

func (Character) Type

func (v Character) Type() *types.Type

Type implements the Value.Type().

type Code

type Code []*Instr

Code implements scheme bytecode.

func (Code) Print

func (code Code) Print(w io.Writer)

Print prints the code to standard output.

type Env

type Env struct {
	Stats  *EnvStats
	Frames []*EnvFrame
}

Env implements environment bindings.

func NewEnv

func NewEnv() *Env

NewEnv creates a new empty environment.

func (*Env) Copy

func (e *Env) Copy() *Env

Copy creates a new copy of the environment that shares the contents of all environment frames and statistics.

func (*Env) CopyEnvFrames

func (e *Env) CopyEnvFrames() *Env

CopyEnvFrames creates a new copy of the environment sharing TypeEnv frames and statistics.

func (*Env) Define

func (e *Env) Define(name string, t *types.Type) (*EnvBinding, error)

Define defines the named symbol in the environment.

func (*Env) Depth

func (e *Env) Depth() int

Depth returns the depth of the environment.

func (*Env) Lookup

func (e *Env) Lookup(name string) (*EnvBinding, bool)

Lookup finds the symbol from the environment.

func (*Env) PopFrame

func (e *Env) PopFrame()

PopFrame pops the topmost environment frame.

func (*Env) Print

func (e *Env) Print()

Print prints the environment to standard output.

func (*Env) PushCaptureFrame

func (e *Env) PushCaptureFrame(captures bool, usage FrameUsage,
	size int) *EnvFrame

PushCaptureFrame pushes a new stack frame. The capture argument specifies if the frame is an env or a stack frame.

func (*Env) PushFrame

func (e *Env) PushFrame(t FrameType, usage FrameUsage, size int) *EnvFrame

PushFrame pushes a new environment or stack frame based on frame type argument.

type EnvBinding

type EnvBinding struct {
	Frame    *EnvFrame
	Disabled bool
	Index    int
	Type     *types.Type
}

EnvBinding defines symbol's location in the environment.

type EnvFrame

type EnvFrame struct {
	Type     FrameType
	Usage    FrameUsage
	Index    int
	Size     int
	Bindings map[string]*EnvBinding
}

EnvFrame implements an environment frame.

type EnvStats

type EnvStats struct {
	MaxStack int
}

EnvStats define environment statistics.

type Flags

type Flags int

Flags define symbol flags.

const (
	FlagDefined Flags = 1 << iota
	FlagConst
)

Symbol flags.

func (Flags) String

func (f Flags) String() string

type Float

type Float float64

Float implements inexact floating point numbers.

func (Float) Eq

func (v Float) Eq(o Value) bool

Eq implements Value.Eq.

func (Float) Equal

func (v Float) Equal(o Value) bool

Equal implements Value.Equal.

func (Float) Scheme

func (v Float) Scheme() string

Scheme implements Value.Scheme.

func (Float) String

func (v Float) String() string

func (Float) Type

func (v Float) Type() *types.Type

Type implements Value.Type.

type Frame

type Frame struct {
	Index    int
	Next     int
	Toplevel bool

	Lambda *Lambda
	PC     int
	Code   Code
	Env    *VMEnvFrame
	// contains filtered or unexported fields
}

Frame implements a SCM call stack frame.

func (*Frame) Eq

func (f *Frame) Eq(o Value) bool

Eq tests if the argument value is eq? to this value.

func (*Frame) Equal

func (f *Frame) Equal(o Value) bool

Equal tests if the argument value is equal to this value.

func (*Frame) MapPC

func (f *Frame) MapPC(pc int) (source string, line int)

MapPC maps the program counter value to the source location.

func (*Frame) Scheme

func (f *Frame) Scheme() string

Scheme returns the value as a Scheme string.

func (*Frame) String

func (f *Frame) String() string

func (*Frame) Type

func (f *Frame) Type() *types.Type

Type implements Value.Type.

type FrameType

type FrameType int

FrameType defines the frame type.

const (
	TypeStack FrameType = iota
	TypeEnv
)

Frame types.

func (FrameType) String

func (ft FrameType) String() string

type FrameUsage

type FrameUsage int

FrameUsage defines how frame is used.

const (
	FUFrame FrameUsage = iota
	FUArgs
	FULet
	FUValue
)

Frame usages.

func (FrameUsage) String

func (fu FrameUsage) String() string

type Identifier

type Identifier struct {
	Name       string
	Point      Point
	GlobalType *types.Type
	Global     Value
	Flags      Flags
}

Identifier implements identifier values.

func (*Identifier) Eq

func (v *Identifier) Eq(o Value) bool

Eq tests if the argument value is eq? to this value.

func (*Identifier) Equal

func (v *Identifier) Equal(o Value) bool

Equal tests if the argument value is equal to this value.

func (*Identifier) Scheme

func (v *Identifier) Scheme() string

Scheme returns the value as a Scheme string.

func (*Identifier) String

func (v *Identifier) String() string

func (*Identifier) Type

func (v *Identifier) Type() *types.Type

Type implements Value.Type.

type Instr

type Instr struct {
	Op  Operand
	V   Value
	I   int
	J   int
	Sym *Identifier
}

Instr implements a Scheme bytecode instruction.

func (Instr) String

func (i Instr) String() string

type Int

type Int int64

Int implements inexact integer numbers.

func (Int) Eq

func (v Int) Eq(o Value) bool

Eq implements Value.Eq.

func (Int) Equal

func (v Int) Equal(o Value) bool

Equal implements Value.Equal.

func (Int) Scheme

func (v Int) Scheme() string

Scheme implements Value.Scheme.

func (Int) String

func (v Int) String() string

func (Int) Type

func (v Int) Type() *types.Type

Type implements Value.Type.

type Keyword

type Keyword int

Keyword defines a Scheme keyword.

const (
	KwElse Keyword = iota
	KwImplies
	KwDefine
	KwDefineConstant
	KwUnquote
	KwUnquoteSplicing
	KwQuote
	KwLambda
	KwIf
	KwSet
	KwBegin
	KwCond
	KwAnd
	KwOr
	KwCase
	KwLet
	KwLetStar
	KwLetrec
	KwDo
	KwDelay
	KwQuasiquote
	KwSchemeApply
	KwPragma
)

Scheme keywords.

func (Keyword) Eq

func (kw Keyword) Eq(o Value) bool

Eq tests if the argument value is eq? to this value.

func (Keyword) Equal

func (kw Keyword) Equal(o Value) bool

Equal tests if the argument value is equal to this value.

func (Keyword) Scheme

func (kw Keyword) Scheme() string

Scheme returns the value as a Scheme string.

func (Keyword) String

func (kw Keyword) String() string

func (Keyword) Type

func (kw Keyword) Type() *types.Type

Type implements the Value.Type().

type Lambda

type Lambda struct {
	Capture *VMEnvFrame
	Impl    *LambdaImpl
}

Lambda implements lambda values.

func (*Lambda) Eq

func (v *Lambda) Eq(o Value) bool

Eq tests if the argument value is eq? to this value.

func (*Lambda) Equal

func (v *Lambda) Equal(o Value) bool

Equal tests if the argument value is equal to this value.

func (*Lambda) MapPC

func (v *Lambda) MapPC(pc int) (source string, line int)

MapPC maps the program counter value to the source location.

func (*Lambda) Scheme

func (v *Lambda) Scheme() string

Scheme returns the value as a Scheme string.

func (*Lambda) String

func (v *Lambda) String() string

func (*Lambda) Type

func (v *Lambda) Type() *types.Type

Type implements the Value.Type().

type LambdaImpl

type LambdaImpl struct {
	Name     string
	Args     Args
	Return   *types.Type
	Captures bool
	Capture  *VMEnvFrame
	Native   Native
	Source   string
	Code     Code
	MaxStack int
	PCMap    PCMap
	Body     []AST
}

LambdaImpl implements lambda functions.

func (*LambdaImpl) Eq

func (v *LambdaImpl) Eq(o Value) bool

Eq implements the Value.Eq().

func (*LambdaImpl) Equal

func (v *LambdaImpl) Equal(o Value) bool

Equal implements the Value.Equal().

func (*LambdaImpl) Scheme

func (v *LambdaImpl) Scheme() string

Scheme implements the Value.Scheme().

func (*LambdaImpl) Signature

func (v *LambdaImpl) Signature(body bool) string

Signature prints the lambda signature with optional lambda body.

func (*LambdaImpl) Type

func (v *LambdaImpl) Type() *types.Type

Type implements the Value.Type().

type Lexer

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

Lexer implement lexical analyser.

func NewLexer

func NewLexer(source string, in io.Reader) *Lexer

NewLexer creates a new lexer for the input.

func (*Lexer) FlushEOL

func (l *Lexer) FlushEOL() error

FlushEOL discards all remaining input from the current source code line.

func (*Lexer) Get

func (l *Lexer) Get() (*Token, error)

Get gest the next token.

func (*Lexer) ReadRune

func (l *Lexer) ReadRune() (rune, int, error)

ReadRune reads the next input rune.

func (*Lexer) Token

func (l *Lexer) Token(t TokenType) *Token

Token returns a new token for the argument token type.

func (*Lexer) Unget

func (l *Lexer) Unget(t *Token)

Unget pushes the token back to the lexer input stream. The next call to Get will return it.

func (*Lexer) UnreadRune

func (l *Lexer) UnreadRune() error

UnreadRune unreads the last rune.

type Library

type Library struct {
	Source    string
	Name      Value
	Body      *ASTSequence
	Exports   Value
	ExportAll bool
	Imports   Value
	Init      Code
	PCMap     PCMap
	// contains filtered or unexported fields
}

Library implements a Scheme compilation unit.

func (*Library) Compile

func (lib *Library) Compile() (Value, error)

Compile compiles the library into bytecode.

func (*Library) Eq

func (lib *Library) Eq(o Value) bool

Eq implements Value.Eq.

func (*Library) Equal

func (lib *Library) Equal(o Value) bool

Equal implements Value.Equal.

func (*Library) MapPC

func (lib *Library) MapPC(pc int) (source string, line int)

MapPC maps the program counter value to the source location.

func (*Library) Scheme

func (lib *Library) Scheme() string

Scheme implements Value.Scheme.

func (*Library) Type

func (lib *Library) Type() *types.Type

Type implements Value.Type.

type LocationPair

type LocationPair struct {
	PlainPair
	// contains filtered or unexported fields
}

LocationPair implements a Scheme pair with location information.

func (*LocationPair) Eq

func (pair *LocationPair) Eq(o Value) bool

Eq tests if the argument value is eq? to this value.

func (*LocationPair) Errorf

func (pair *LocationPair) Errorf(format string, a ...interface{}) error

Errorf implements Locator.Errorf.

func (*LocationPair) From

func (pair *LocationPair) From() Point

From returns pair's start location.

func (*LocationPair) Infof

func (pair *LocationPair) Infof(format string, a ...interface{})

Infof implements Locator.Infof.

func (*LocationPair) SetTo

func (pair *LocationPair) SetTo(p Point)

SetTo sets pair's end location.

func (*LocationPair) String

func (pair *LocationPair) String() string

func (*LocationPair) To

func (pair *LocationPair) To() Point

To returns pair's end location.

type Locator

type Locator interface {
	From() Point
	To() Point
	SetTo(p Point)
	// Errorf returns an error with the location information.
	Errorf(format string, a ...interface{}) error
	// Infof prints information with the location information.
	Infof(format string, a ...interface{})
}

Locator interface a source location.

type Native

type Native func(scm *Scheme, args []Value) (Value, error)

Native implements native functions.

type Operand

type Operand int

Operand defines a Scheme bytecode instruction.

const (
	OpConst Operand = iota
	OpDefine
	OpLambda
	OpLabel
	OpLocal
	OpEnv
	OpGlobal
	OpLocalSet
	OpEnvSet
	OpGlobalSet
	OpPushF
	OpPushS
	OpPushE
	OpPopS
	OpPopE
	OpPushA
	OpCall
	OpIf
	OpIfNot
	OpJmp
	OpReturn
	OpPairp
	OpCons
	OpCar
	OpCdr
	OpNullp
	OpZerop
	OpNot
	OpAdd
	OpAddI64
	OpAddConst
	OpSub
	OpSubI64
	OpSubConst
	OpMul
	OpMulConst
	OpDiv
	OpEq
	OpLt
	OpGt
	OpLe
	OpGe
	OpCastNumber
	OpCastSymbol
)

Bytecode instructions.

func (Operand) String

func (op Operand) String() string

type PCLine

type PCLine struct {
	PC   int
	Line int
}

PCLine maps program counter values to line numbers.

type PCMap

type PCMap []PCLine

PCMap implements mapping from program counter values to source line numbers.

func (PCMap) MapPC

func (pcmap PCMap) MapPC(pc int) (line int)

MapPC maps the program counter value to the source line number.

type Pair

type Pair interface {
	Locator
	Car() Value
	Cdr() Value
	SetCar(v Value) error
	SetCdr(v Value) error
	Scheme() string
	Eq(o Value) bool
	Equal(o Value) bool
	Type() *types.Type
}

Pair implements a Scheme pair.

func ListPairs

func ListPairs(list Value) ([]Pair, bool)

ListPairs returns the list pairs as []Pair.

func NewLocationPair

func NewLocationPair(from, to Point, car, cdr Value) Pair

NewLocationPair creates a new pair with the car and cdr values and location information.

func NewPair

func NewPair(car, cdr Value) Pair

NewPair creates a new pair with the car and cdr values.

type Params

type Params struct {
	// Verbose output.
	Verbose bool

	// Quiet output.
	Quiet bool

	// NoRuntime specifies if the Scheme-implemented runtime is
	// initialized.
	NoRuntime bool

	// Do not warn when redefining global symbols.
	NoWarnDefine bool
}

Params define the configuration parameters for Scheme.

type Parser

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

Parser implements the byte-code compiler.

func NewParser

func NewParser(scm *Scheme) *Parser

NewParser creates a new bytecode compiler.

func (*Parser) Parse

func (p *Parser) Parse(source string, in io.Reader) (*Library, error)

Parse parses the source.

type PlainPair

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

PlainPair implements a Scheme pair with car and cdr values.

func (*PlainPair) Car

func (pair *PlainPair) Car() Value

Car returns the pair's car value.

func (*PlainPair) Cdr

func (pair *PlainPair) Cdr() Value

Cdr returns the pair's cdr value.

func (*PlainPair) Eq

func (pair *PlainPair) Eq(o Value) bool

Eq tests if the argument value is eq? to this value.

func (*PlainPair) Equal

func (pair *PlainPair) Equal(o Value) bool

Equal tests if the argument value is equal to this value.

func (*PlainPair) Errorf

func (pair *PlainPair) Errorf(format string, a ...interface{}) error

Errorf implements Locator.Errorf.

func (*PlainPair) From

func (pair *PlainPair) From() Point

From returns pair's start location.

func (*PlainPair) Infof

func (pair *PlainPair) Infof(format string, a ...interface{})

Infof implements Locator.Infof.

func (*PlainPair) Scheme

func (pair *PlainPair) Scheme() string

Scheme returns the value as a Scheme string.

func (*PlainPair) SetCar

func (pair *PlainPair) SetCar(v Value) error

SetCar sets the pair's car value.

func (*PlainPair) SetCdr

func (pair *PlainPair) SetCdr(v Value) error

SetCdr sets the pair's cdr value.

func (*PlainPair) SetTo

func (pair *PlainPair) SetTo(p Point)

SetTo sets pair's end location.

func (*PlainPair) String

func (pair *PlainPair) String() string

func (*PlainPair) To

func (pair *PlainPair) To() Point

To returns pair's end location.

func (*PlainPair) Type

func (pair *PlainPair) Type() *types.Type

Type implements the Value.Type().

type Point

type Point struct {
	Source string
	Line   int // 1-based
	Col    int // 0-based
}

Point defines a position in the input data.

func (Point) Errorf

func (p Point) Errorf(format string, a ...interface{}) error

Errorf implements Locator.Errorf.

func (Point) From

func (p Point) From() Point

From returns the point.

func (Point) Infof

func (p Point) Infof(format string, a ...interface{})

Infof implements Locator.Info.

func (Point) SetTo

func (p Point) SetTo(point Point)

SetTo does nothing on point.

func (Point) String

func (p Point) String() string

func (Point) To

func (p Point) To() Point

To returns the point.

func (Point) Undefined

func (p Point) Undefined() bool

Undefined tests if the point is undefined.

type Port

type Port struct {
	Native interface{}
}

Port implements Scheme ports.

func NewPort

func NewPort(native interface{}) *Port

NewPort creates a new port for the native I/O channel.

func (*Port) Eq

func (p *Port) Eq(o Value) bool

Eq tests if the argument value is eq? to this value.

func (*Port) Equal

func (p *Port) Equal(o Value) bool

Equal tests if the argument value is equal to this number.

func (*Port) Printf

func (p *Port) Printf(format string, a ...interface{}) (n int, err error)

Printf prints formatted output to the port.

func (*Port) Println

func (p *Port) Println(a ...interface{}) (n int, err error)

Println prints newline-terminated values to the port.

func (*Port) Scheme

func (p *Port) Scheme() string

Scheme returns the value as a Scheme string.

func (*Port) String

func (p *Port) String() string

func (*Port) Type

func (p *Port) Type() *types.Type

Type implements Value.Type.

type Scheme

type Scheme struct {
	Params  Params
	Stdout  *Port
	Stderr  *Port
	Parsing bool
	// contains filtered or unexported fields
}

Scheme implements Scheme interpreter and virtual machine.

func New

func New() (*Scheme, error)

New creates a new Scheme interpreter.

func NewWithParams

func NewWithParams(params Params) (*Scheme, error)

NewWithParams creates a new Scheme interpreter with the parameters.

func (*Scheme) Apply

func (scm *Scheme) Apply(lambda Value, args []Value) (Value, error)

Apply applies lambda for arguments. This function implements the virtual machine program execution.

The virtual machine is a stack machine with the following registers:

  • env - the current environment
  • fp - the current stack frame
  • pc - program counter
  • accu - holds the value of the latest operation

The virtual machine stack is as follows:

sp --->
        Value{n}
        ...
        Value{0}
        Arg{n}
        ...
        Arg{0}
fp ---> Next fp ---+
                   |
                   v

func (*Scheme) Breakf

func (scm *Scheme) Breakf(format string, a ...interface{}) error

Breakf breaks the program execution with the error.

func (*Scheme) DefineBuiltin

func (scm *Scheme) DefineBuiltin(builtin Builtin)

DefineBuiltin defines a built-in native function.

func (*Scheme) DefineBuiltins

func (scm *Scheme) DefineBuiltins(builtins []Builtin)

DefineBuiltins defines the built-in functions, defined in the argument array.

func (*Scheme) Eval

func (scm *Scheme) Eval(source string, in io.Reader) (Value, error)

Eval evaluates the scheme source.

func (*Scheme) EvalFile

func (scm *Scheme) EvalFile(file string) (Value, error)

EvalFile evaluates the scheme file.

func (*Scheme) Global

func (scm *Scheme) Global(name string) (Value, error)

Global returns the global value of the symbol.

func (*Scheme) Intern

func (scm *Scheme) Intern(name string) *Identifier

Intern interns the name and returns the interned symbol.

func (*Scheme) Load

func (scm *Scheme) Load(source string, in io.Reader) (Value, error)

Load loads and compiles the input.

func (*Scheme) LoadFile

func (scm *Scheme) LoadFile(file string) (Value, error)

LoadFile loads and compiles the file.

func (*Scheme) Location

func (scm *Scheme) Location() (source string, line int, err error)

Location returns the source file location of the current VM continuation.

func (*Scheme) PrintStack

func (scm *Scheme) PrintStack()

PrintStack prints the virtual machine stack.

func (*Scheme) SetGlobal

func (scm *Scheme) SetGlobal(name string, value Value) error

SetGlobal sets the value of the global symbol. The function returns an error if the symbols was defined to be a FlagFinal. The symbol will became defined if it was undefined before the call.

func (*Scheme) StackTrace

func (scm *Scheme) StackTrace() []StackFrame

StackTrace returns information about the virtual machine stack.

func (*Scheme) VMErrorf

func (scm *Scheme) VMErrorf(format string, a ...interface{}) error

VMErrorf creates a virtual machine error.

func (*Scheme) VMWarningf

func (scm *Scheme) VMWarningf(format string, a ...interface{})

VMWarningf prints a virtual machine warning.

type SexprParser

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

SexprParser implements S-expression parser.

func NewSexprParser

func NewSexprParser(source string, in io.Reader) *SexprParser

NewSexprParser creates a new parser for the input file.

func (*SexprParser) Errorf

func (p *SexprParser) Errorf(format string, a ...interface{}) error

Errorf implements Locator.Errorf.

func (*SexprParser) From

func (p *SexprParser) From() Point

From returns the parser's current location.

func (*SexprParser) Infof

func (p *SexprParser) Infof(format string, a ...interface{})

Infof implements Locator.Infof.

func (*SexprParser) Next

func (p *SexprParser) Next() (Value, error)

Next parses the next value.

func (*SexprParser) SetTo

func (p *SexprParser) SetTo(point Point)

SetTo does nothing on parser.

func (*SexprParser) To

func (p *SexprParser) To() Point

To returns the parser's current location.

type StackFrame

type StackFrame struct {
	Source string
	Line   int
}

StackFrame provides information about the virtual machine stack frame.

type String

type String string

String implements string values.

func (String) Eq

func (v String) Eq(o Value) bool

Eq tests if the argument value is eq? to this value.

func (String) Equal

func (v String) Equal(o Value) bool

Equal tests if the argument value is equal to this value.

func (String) Scheme

func (v String) Scheme() string

Scheme returns the value as a Scheme string.

func (String) String

func (v String) String() string

func (String) Type

func (v String) Type() *types.Type

Type implements the Value.Type().

type Token

type Token struct {
	Type       TokenType
	From       Point
	To         Point
	Identifier string
	Bool       bool
	Number     Value
	Char       rune
	Str        string
	Keyword    Keyword
}

Token specifies an input token.

func (*Token) Equal

func (t *Token) Equal(o *Token) bool

Equal tests if the argument token is equal to this token.

func (*Token) Errorf

func (t *Token) Errorf(format string, a ...interface{}) error

Errorf returns an error with the token location information.

func (*Token) String

func (t *Token) String() string

type TokenType

type TokenType int

TokenType specifies input token types.

const (
	TIdentifier TokenType = 256 + iota
	TBoolean
	TNumber
	TCharacter
	TString
	TKeyword
	THashLPar
	TVU8LPar
	TCommaAt
)

Input tokens.

func (TokenType) String

func (t TokenType) String() string

type TypedName

type TypedName struct {
	Name string
	Type *types.Type
}

TypedName defines name with type information.

func (*TypedName) String

func (tn *TypedName) String() string

type VMEnvFrame

type VMEnvFrame struct {
	Next   *VMEnvFrame
	Index  int
	Values []Value
}

VMEnvFrame implement a virtual machine environment frame.

type Value

type Value interface {
	Scheme() string
	Eq(o Value) bool
	Equal(o Value) bool
	Type() *types.Type
}

Value implements a Scheme value.

func Car

func Car(pair Value, ok bool) (Value, bool)

Car returns the car element of the pair.

func Cdr

func Cdr(pair Value, ok bool) (Value, bool)

Cdr returns the cdr element of the cons cell.

func ListValues

func ListValues(list Value) ([]Value, bool)

ListValues returns the list values as []Value.

func NewNumber

func NewNumber(value interface{}) Value

NewNumber creates a new numeric value.

type Vector

type Vector []Value

Vector implements vector values.

func (Vector) Eq

func (v Vector) Eq(o Value) bool

Eq tests if the argument value is eq? to this value.

func (Vector) Equal

func (v Vector) Equal(o Value) bool

Equal tests if the argument value is equal to this value.

func (Vector) Scheme

func (v Vector) Scheme() string

Scheme returns the value as a Scheme string.

func (Vector) String

func (v Vector) String() string

func (Vector) Type

func (v Vector) Type() *types.Type

Type implements the Value.Type().

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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