Documentation
¶
Index ¶
- Constants
- Variables
- func CloseScoped(c *Scope, timeout time.Duration)
- func DefaultCompare(a, b Value) (int, error)
- func FormatError(err error) string
- func HashValue(v Value) uint32
- func IsBigDecimal(v Value) bool
- func IsBigInt(v Value) bool
- func IsNumber(v Value) bool
- func IsRatio(v Value) bool
- func IsReduced(v Value) bool
- func IsTruthy(v Value) bool
- func Iter(v Value) iter.Seq[Value]
- func MapEntryKV(entry Value) (Value, Value, bool)
- func NumEq(a, b Value) bool
- func NumEquivalent(a, b Value) bool
- func NumGe(a, b Value) (bool, error)
- func NumGt(a, b Value) (bool, error)
- func NumLe(a, b Value) (bool, error)
- func NumLt(a, b Value) (bool, error)
- func OpcodeToString(op int32) string
- func RecordOpcode(prevOp, currOp uint8)
- func ReleaseFrame(f *Frame)
- func ResetProfile()
- func SeqIsEmpty(s Seq) bool
- func SeqValues(s Seq) iter.Seq[Value]
- func SetCoreNamespace(ns *Namespace)
- func SetNSLookup(fn func(string) *Namespace)
- func SetValueEquals(fn func(a, b Value) bool)
- func ToBigInt(v Value) (*big.Int, bool)
- func ToFloat(v Value) (float64, bool)
- func ToInt(v Value) (int, bool)
- func ToRat(v Value) (*big.Rat, bool)
- func ToStruct[T any](r *Record) (T, error)
- type ArrayChunk
- func (c *ArrayChunk) ChunkCount() int
- func (c *ArrayChunk) Count() Value
- func (c *ArrayChunk) DropFirst() IChunk
- func (c *ArrayChunk) Nth(i int) Value
- func (c *ArrayChunk) RawCount() int
- func (c *ArrayChunk) String() string
- func (c *ArrayChunk) Type() ValueType
- func (c *ArrayChunk) Unbox() any
- func (c *ArrayChunk) ValueAt(key Value) Value
- func (c *ArrayChunk) ValueAtOr(key Value, dflt Value) Value
- type ArrayKind
- type ArrayVector
- func (l ArrayVector) Arity() int
- func (l ArrayVector) Assoc(k Value, v Value) Associative
- func (l ArrayVector) Conj(val Value) Collection
- func (l ArrayVector) Cons(val Value) Seq
- func (l ArrayVector) Contains(value Value) Boolean
- func (l ArrayVector) Count() Value
- func (l ArrayVector) Dissoc(k Value) Associative
- func (l ArrayVector) Empty() Collection
- func (l ArrayVector) Equals(other Value) bool
- func (l ArrayVector) First() Value
- func (l ArrayVector) Hash() uint32
- func (l ArrayVector) Invoke(pargs []Value) (Value, error)
- func (l ArrayVector) Meta() Value
- func (l ArrayVector) More() Seq
- func (l ArrayVector) Next() Seq
- func (l ArrayVector) Nth(i int) Value
- func (l ArrayVector) RawCount() int
- func (l ArrayVector) Seq() Seq
- func (l ArrayVector) String() string
- func (l ArrayVector) Type() ValueType
- func (l ArrayVector) Unbox() any
- func (l ArrayVector) ValueAt(key Value) Value
- func (l ArrayVector) ValueAtOr(key Value, dflt Value) Value
- func (l ArrayVector) WithMeta(m Value) Value
- type ArrayVectorSeq
- func (s *ArrayVectorSeq) Conj(val Value) Collection
- func (s *ArrayVectorSeq) Cons(val Value) Seq
- func (s *ArrayVectorSeq) Count() Value
- func (s *ArrayVectorSeq) Empty() Collection
- func (s *ArrayVectorSeq) First() Value
- func (s *ArrayVectorSeq) More() Seq
- func (s *ArrayVectorSeq) Next() Seq
- func (s *ArrayVectorSeq) Nth(i int) Value
- func (s *ArrayVectorSeq) RawCount() int
- func (s *ArrayVectorSeq) Seq() Seq
- func (s *ArrayVectorSeq) String() string
- func (s *ArrayVectorSeq) Type() ValueType
- func (s *ArrayVectorSeq) Unbox() any
- func (s *ArrayVectorSeq) ValueAt(key Value) Value
- func (s *ArrayVectorSeq) ValueAtOr(key Value, dflt Value) Value
- type Associative
- type Atom
- func (a *Atom) AddWatch(key Value, fn Fn)
- func (a *Atom) AlterMeta(fn Fn, args []Value) (Value, error)
- func (a *Atom) CompareAndSet(oldVal, newVal Value) (bool, error)
- func (a *Atom) Deref() Value
- func (a *Atom) Hash() uint32
- func (a *Atom) Meta() Value
- func (a *Atom) RemoveWatch(key Value)
- func (a *Atom) Reset(newVal Value) (Value, error)
- func (a *Atom) String() string
- func (a *Atom) Swap(fn Fn, args []Value) (Value, error)
- func (a *Atom) Type() ValueType
- func (a *Atom) Unbox() any
- func (a *Atom) Validator() Value
- func (a *Atom) WithMeta(m Value) Value
- type BigDecimal
- func (b *BigDecimal) Equals(other Value) bool
- func (b *BigDecimal) GoString() string
- func (b *BigDecimal) Hash() uint32
- func (b *BigDecimal) String() string
- func (b *BigDecimal) ToFloat64() float64
- func (b *BigDecimal) Type() ValueType
- func (b *BigDecimal) Unbox() any
- func (b *BigDecimal) Val() *big.Float
- type BigInt
- type BindingSnapshot
- type BlockingDeref
- type Boolean
- type Boxed
- type Chan
- type Char
- type ChunkBuffer
- type ChunkedCons
- func (c *ChunkedCons) ChunkedFirst() IChunk
- func (c *ChunkedCons) ChunkedMore() Seq
- func (c *ChunkedCons) ChunkedNext() Seq
- func (c *ChunkedCons) Cons(val Value) Seq
- func (c *ChunkedCons) First() Value
- func (c *ChunkedCons) Hash() uint32
- func (c *ChunkedCons) More() Seq
- func (c *ChunkedCons) Next() Seq
- func (c *ChunkedCons) Seq() Seq
- func (c *ChunkedCons) String() string
- func (c *ChunkedCons) Type() ValueType
- func (c *ChunkedCons) Unbox() any
- type Closure
- type CodeChunk
- func (c *CodeChunk) AddLocalVar(slot int, name string)
- func (c *CodeChunk) AddSourceInfo(info SourceInfo)
- func (c *CodeChunk) Append(insts ...int32)
- func (c *CodeChunk) Append32(val int)
- func (c *CodeChunk) AppendChunk(o *CodeChunk)
- func (c *CodeChunk) Code() []int32
- func (c *CodeChunk) Consts() *Consts
- func (c *CodeChunk) Debug()
- func (c *CodeChunk) Get(idx int) (int32, error)
- func (c *CodeChunk) Get32(idx int) (int, error)
- func (c *CodeChunk) GetSourceMap() *SourceMap
- func (c *CodeChunk) Length() int
- func (c *CodeChunk) LocalVars() []LocalVar
- func (c *CodeChunk) LookupSource(ip int) *SourceInfo
- func (c *CodeChunk) MaxStack() int
- func (c *CodeChunk) SetMaxStack(max int)
- func (c *CodeChunk) Update32(address int, value int32)
- type Collection
- type Comparator
- type Cons
- func (c *Cons) Conj(val Value) Collection
- func (c *Cons) Cons(val Value) Seq
- func (c *Cons) Count() Value
- func (c *Cons) Empty() Collection
- func (c *Cons) First() Value
- func (c *Cons) Hash() uint32
- func (c *Cons) More() Seq
- func (c *Cons) Next() Seq
- func (c *Cons) RawCount() int
- func (c *Cons) Seq() Seq
- func (c *Cons) String() string
- func (c *Cons) Type() ValueType
- func (c *Cons) Unbox() any
- type Consts
- type Counted
- type DType
- type DTypeInstance
- func (d *DTypeInstance) DType() *DType
- func (d *DTypeInstance) Equals(other Value) bool
- func (d *DTypeInstance) Fields() []Value
- func (d *DTypeInstance) Hash() uint32
- func (d *DTypeInstance) InvokeMethod(name Symbol, args []Value) (Value, error)
- func (d *DTypeInstance) Meta() Value
- func (d *DTypeInstance) SetField(name Symbol, val Value) error
- func (d *DTypeInstance) String() string
- func (d *DTypeInstance) Type() ValueType
- func (d *DTypeInstance) Unbox() any
- func (d *DTypeInstance) WithMeta(m Value) Value
- type Delay
- type ExInfo
- func (e *ExInfo) Cause() error
- func (e *ExInfo) Data() *PersistentMap
- func (e *ExInfo) Error() string
- func (e *ExInfo) InvokeMethod(name Symbol, args []Value) (Value, error)
- func (e *ExInfo) Message() string
- func (e *ExInfo) Meta() Value
- func (e *ExInfo) String() string
- func (e *ExInfo) Type() ValueType
- func (e *ExInfo) Unbox() any
- func (e *ExInfo) WithMeta(m Value) Value
- type ExecContext
- func (ec *ExecContext) Bind(fn Fn) Fn
- func (ec *ExecContext) BindingSnapshot() BindingSnapshot
- func (ec *ExecContext) Child() *ExecContext
- func (ec *ExecContext) Context() context.Context
- func (ec *ExecContext) Deref(v *Var) Value
- func (ec *ExecContext) Invoke(fn Fn, args []Value) (Value, error)
- func (ec *ExecContext) PopBinding(v *Var)
- func (ec *ExecContext) PushBinding(v *Var, val Value)
- func (ec *ExecContext) Scope() *Scope
- func (ec *ExecContext) SetBinding(v *Var, val Value) bool
- func (ec *ExecContext) SetScope(s *Scope)
- type ExecutionError
- type Float
- type Float32
- type Fn
- type Frame
- type Func
- func (l *Func) Arity() int
- func (l *Func) Chunk() *CodeChunk
- func (l *Func) FuncName() string
- func (l *Func) Invoke(pargs []Value) (result Value, err error)
- func (l *Func) IsVariadic() bool
- func (l *Func) MakeClosure() Fn
- func (l *Func) SetName(n string)
- func (l *Func) String() string
- func (l *Func) Type() ValueType
- func (l *Func) Unbox() any
- type FuncInterface
- type GoPanicError
- type Hashable
- type IChunk
- type IChunkedSeq
- type IMeta
- type Indexed
- type InfiniteRange
- func (r *InfiniteRange) ChunkedFirst() IChunk
- func (r *InfiniteRange) ChunkedMore() Seq
- func (r *InfiniteRange) ChunkedNext() Seq
- func (r *InfiniteRange) Cons(val Value) Seq
- func (r *InfiniteRange) First() Value
- func (r *InfiniteRange) More() Seq
- func (r *InfiniteRange) Next() Seq
- func (r *InfiniteRange) Seq() Seq
- func (r *InfiniteRange) String() string
- func (r *InfiniteRange) Type() ValueType
- func (r *InfiniteRange) Unbox() any
- type Instant
- type Int
- type Iterate
- type Keyed
- type Keyword
- func (l Keyword) Arity() int
- func (l Keyword) Hash() uint32
- func (l Keyword) Invoke(pargs []Value) (Value, error)
- func (l Keyword) Name() Value
- func (l Keyword) Namespace() Value
- func (l Keyword) Namespaced() (Value, Value)
- func (l Keyword) String() string
- func (l Keyword) Type() ValueType
- func (l Keyword) Unbox() any
- type LazySeq
- func (l *LazySeq) Conj(val Value) Collection
- func (l *LazySeq) Cons(val Value) Seq
- func (l *LazySeq) Count() Value
- func (l *LazySeq) Empty() Collection
- func (l *LazySeq) First() Value
- func (l *LazySeq) Hash() uint32
- func (l *LazySeq) IsRealized() bool
- func (l *LazySeq) More() Seq
- func (l *LazySeq) Next() Seq
- func (l *LazySeq) RawCount() int
- func (l *LazySeq) Resolve() Seq
- func (l *LazySeq) Seq() Seq
- func (l *LazySeq) String() string
- func (l *LazySeq) Type() ValueType
- func (l *LazySeq) Unbox() any
- func (l *LazySeq) ValueAt(key Value) Value
- func (l *LazySeq) ValueAtOr(key Value, notFound Value) Value
- type List
- func (l *List) Conj(value Value) Collection
- func (l *List) Cons(val Value) Seq
- func (l *List) Count() Value
- func (l *List) Empty() Collection
- func (l *List) First() Value
- func (l *List) Hash() uint32
- func (l *List) Meta() Value
- func (l *List) More() Seq
- func (l *List) Next() Seq
- func (l *List) RawCount() int
- func (l *List) Seq() Seq
- func (l *List) String() string
- func (l *List) Type() ValueType
- func (l *List) Unbox() any
- func (l *List) ValueAt(key Value) Value
- func (l *List) ValueAtOr(key Value, dflt Value) Value
- func (l *List) WithMeta(m Value) Value
- type LocalVar
- type Lookup
- type Map
- func (l Map) Arity() int
- func (l Map) Assoc(k Value, v Value) Associative
- func (l Map) Conj(value Value) Collection
- func (l Map) Cons(val Value) Seq
- func (l Map) Contains(value Value) Boolean
- func (l Map) Count() Value
- func (l Map) Dissoc(k Value) Associative
- func (l Map) Empty() Collection
- func (l Map) First() Value
- func (l Map) Invoke(pargs []Value) (Value, error)
- func (l Map) More() Seq
- func (l Map) Next() Seq
- func (l Map) RawCount() int
- func (l Map) Seq() Seq
- func (l Map) String() string
- func (l Map) Type() ValueType
- func (l Map) Unbox() any
- func (l Map) ValueAt(key Value) Value
- func (l Map) ValueAtOr(key Value, dflt Value) Value
- type MapEntry
- func (e MapEntry) Conj(v Value) Collection
- func (e MapEntry) Cons(v Value) Seq
- func (e MapEntry) Count() Value
- func (e MapEntry) Empty() Collection
- func (e MapEntry) Equals(other Value) bool
- func (e MapEntry) First() Value
- func (e MapEntry) Hash() uint32
- func (e MapEntry) More() Seq
- func (e MapEntry) Next() Seq
- func (e MapEntry) RawCount() int
- func (e MapEntry) Seq() Seq
- func (e MapEntry) String() string
- func (e MapEntry) Type() ValueType
- func (e MapEntry) Unbox() any
- func (e MapEntry) ValueAt(k Value) Value
- func (e MapEntry) ValueAtOr(k Value, dflt Value) Value
- type MapSeq
- func (s *MapSeq) Conj(val Value) Collection
- func (s *MapSeq) Cons(val Value) Seq
- func (s *MapSeq) Count() Value
- func (s *MapSeq) Empty() Collection
- func (s *MapSeq) First() Value
- func (s *MapSeq) More() Seq
- func (s *MapSeq) Next() Seq
- func (s *MapSeq) RawCount() int
- func (s *MapSeq) Seq() Seq
- func (s *MapSeq) String() string
- func (s *MapSeq) Type() ValueType
- func (s *MapSeq) Unbox() any
- type MultiArityFn
- type MultiFn
- func (m *MultiFn) AddMethod(dispatchVal Value, method Fn) *MultiFn
- func (m *MultiFn) Arity() int
- func (m *MultiFn) FreezeNative()
- func (m *MultiFn) Invoke(args []Value) (Value, error)
- func (m *MultiFn) IsNativeFrozen() bool
- func (m *MultiFn) Methods() *PersistentMap
- func (m *MultiFn) RemoveMethod(dispatchVal Value) *MultiFn
- func (m *MultiFn) String() string
- func (m *MultiFn) Type() ValueType
- func (m *MultiFn) Unbox() any
- type Named
- type Namespace
- func (n *Namespace) Alias(alias Symbol, target *Namespace)
- func (n *Namespace) Def(name string, val Value) *Var
- func (n *Namespace) DefStub(name string) *Var
- func (n *Namespace) Exclude(name string)
- func (n *Namespace) ImportVar(from *Namespace, name Symbol, alias Symbol) bool
- func (n *Namespace) IsExcluded(name Symbol) bool
- func (n *Namespace) Lookup(symbol Symbol) Value
- func (n *Namespace) LookupLocal(symbol Symbol) *Var
- func (n *Namespace) LookupOrAdd(symbol Symbol) Value
- func (n *Namespace) Name() string
- func (n *Namespace) Refer(ns *Namespace, alias string, all bool)
- func (n *Namespace) ReferList(ns *Namespace, symbols []Symbol)
- func (n *Namespace) RegistrySize() int
- func (n *Namespace) ResolveAlias(alias Symbol) *Namespace
- func (n *Namespace) String() string
- func (n *Namespace) Type() ValueType
- func (n *Namespace) Unbox() any
- type NativeFn
- func (l *NativeFn) Arity() int
- func (l *NativeFn) HasCtx() bool
- func (l *NativeFn) Invoke(args []Value) (ret Value, err error)
- func (l *NativeFn) SetName(n string)
- func (l *NativeFn) String() string
- func (l *NativeFn) Type() ValueType
- func (l *NativeFn) Unbox() any
- func (l *NativeFn) WithArity(arity int, variadric bool) *NativeFn
- type Nil
- func (n *Nil) Assoc(k Value, v Value) Associative
- func (n *Nil) Conj(value Value) Collection
- func (n *Nil) Cons(value Value) Seq
- func (n *Nil) Count() Value
- func (n *Nil) Dissoc(k Value) Associative
- func (n *Nil) Empty() Collection
- func (n *Nil) First() Value
- func (n *Nil) More() Seq
- func (n *Nil) Next() Seq
- func (n *Nil) RawCount() int
- func (n *Nil) Seq() Seq
- func (n *Nil) String() string
- func (n *Nil) Type() ValueType
- func (n *Nil) Unbox() any
- type PairSample
- type PersistentMap
- func (m *PersistentMap) Arity() int
- func (m *PersistentMap) Assoc(key Value, val Value) Associative
- func (m *PersistentMap) Conj(value Value) Collection
- func (m *PersistentMap) Contains(key Value) Boolean
- func (m *PersistentMap) Count() Value
- func (m *PersistentMap) Dissoc(key Value) Associative
- func (m *PersistentMap) Empty() Collection
- func (m *PersistentMap) Equals(other Value) bool
- func (m *PersistentMap) Hash() uint32
- func (m *PersistentMap) Invoke(pargs []Value) (Value, error)
- func (m *PersistentMap) Meta() Value
- func (m *PersistentMap) RawCount() int
- func (m *PersistentMap) Seq() Seq
- func (m *PersistentMap) String() string
- func (m *PersistentMap) Type() ValueType
- func (m *PersistentMap) Unbox() any
- func (m *PersistentMap) ValueAt(key Value) Value
- func (m *PersistentMap) ValueAtOr(key Value, dflt Value) Value
- func (m *PersistentMap) WithMeta(meta Value) Value
- type PersistentSet
- func (s *PersistentSet) Arity() int
- func (s *PersistentSet) Conj(value Value) Collection
- func (s *PersistentSet) Cons(val Value) Seq
- func (s *PersistentSet) Contains(value Value) Boolean
- func (s *PersistentSet) Count() Value
- func (s *PersistentSet) Disj(value Value) *PersistentSet
- func (s *PersistentSet) Empty() Collection
- func (s *PersistentSet) First() Value
- func (s *PersistentSet) Hash() uint32
- func (s *PersistentSet) Invoke(pargs []Value) (Value, error)
- func (s *PersistentSet) Meta() Value
- func (s *PersistentSet) More() Seq
- func (s *PersistentSet) Next() Seq
- func (s *PersistentSet) RawCount() int
- func (s *PersistentSet) Seq() Seq
- func (s *PersistentSet) String() string
- func (s *PersistentSet) Type() ValueType
- func (s *PersistentSet) Unbox() any
- func (s *PersistentSet) ValueAt(key Value) Value
- func (s *PersistentSet) ValueAtOr(key Value, dflt Value) Value
- func (s *PersistentSet) WithMeta(m Value) Value
- type PersistentVector
- func (v PersistentVector) Arity() int
- func (v PersistentVector) Assoc(key Value, val Value) Associative
- func (v PersistentVector) Conj(val Value) Collection
- func (v PersistentVector) Contains(key Value) Boolean
- func (v PersistentVector) Count() Value
- func (v PersistentVector) Dissoc(key Value) Associative
- func (v PersistentVector) Empty() Collection
- func (v PersistentVector) Equals(other Value) bool
- func (v PersistentVector) Hash() uint32
- func (v PersistentVector) Invoke(args []Value) (Value, error)
- func (v PersistentVector) Meta() Value
- func (v PersistentVector) Nth(i int) Value
- func (v PersistentVector) Pop() PersistentVector
- func (v PersistentVector) RawCount() int
- func (v PersistentVector) Seq() Seq
- func (v PersistentVector) String() string
- func (v PersistentVector) Type() ValueType
- func (v PersistentVector) Unbox() any
- func (v PersistentVector) ValueAt(key Value) Value
- func (v PersistentVector) ValueAtOr(key Value, dflt Value) Value
- func (v PersistentVector) WithMeta(m Value) Value
- type PersistentVectorSeq
- func (s *PersistentVectorSeq) ChunkedFirst() IChunk
- func (s *PersistentVectorSeq) ChunkedMore() Seq
- func (s *PersistentVectorSeq) ChunkedNext() Seq
- func (s *PersistentVectorSeq) Conj(val Value) Collection
- func (s *PersistentVectorSeq) Cons(val Value) Seq
- func (s *PersistentVectorSeq) Count() Value
- func (s *PersistentVectorSeq) Empty() Collection
- func (s *PersistentVectorSeq) First() Value
- func (s *PersistentVectorSeq) More() Seq
- func (s *PersistentVectorSeq) Next() Seq
- func (s *PersistentVectorSeq) Nth(i int) Value
- func (s *PersistentVectorSeq) RawCount() int
- func (s *PersistentVectorSeq) String() string
- func (s *PersistentVectorSeq) Type() ValueType
- func (s *PersistentVectorSeq) Unbox() any
- func (s *PersistentVectorSeq) ValueAt(key Value) Value
- func (s *PersistentVectorSeq) ValueAtOr(key Value, dflt Value) Value
- type ProfileSample
- type Promise
- type Protocol
- func (p *Protocol) Extend(vt ValueType, implMap *PersistentMap)
- func (p *Protocol) ExtendNil(implMap *PersistentMap)
- func (p *Protocol) Lookup(methodName Symbol, target Value) (Fn, bool)
- func (p *Protocol) Meta() Value
- func (p *Protocol) Methods() []Symbol
- func (p *Protocol) Name() string
- func (p *Protocol) Satisfies(target Value) bool
- func (p *Protocol) String() string
- func (p *Protocol) Type() ValueType
- func (p *Protocol) Unbox() any
- func (p *Protocol) WithMeta(m Value) Value
- type ProtocolFn
- type Range
- func (l *Range) ChunkedFirst() IChunk
- func (l *Range) ChunkedMore() Seq
- func (l *Range) ChunkedNext() Seq
- func (l *Range) Conj(val Value) Collection
- func (l *Range) Cons(val Value) Seq
- func (l *Range) Count() Value
- func (l *Range) Empty() Collection
- func (l *Range) First() Value
- func (l *Range) More() Seq
- func (l *Range) Next() Seq
- func (l *Range) Nth(i int) Value
- func (l *Range) RawCount() int
- func (l *Range) Seq() Seq
- func (l *Range) String() string
- func (l *Range) Type() ValueType
- func (l *Range) Unbox() any
- func (l *Range) ValueAt(key Value) Value
- func (l *Range) ValueAtOr(key Value, dflt Value) Value
- type Ratio
- type Receiver
- type Record
- func (r *Record) Arity() int
- func (r *Record) Assoc(key Value, val Value) Associative
- func (r *Record) Conj(value Value) Collection
- func (r *Record) Contains(key Value) Boolean
- func (r *Record) Count() Value
- func (r *Record) Dissoc(key Value) Associative
- func (r *Record) Empty() Collection
- func (r *Record) Equals(other Value) bool
- func (r *Record) Extra() *PersistentMap
- func (r *Record) FixedFields() []Value
- func (r *Record) Hash() uint32
- func (r *Record) Invoke(args []Value) (Value, error)
- func (r *Record) InvokeMethod(name Symbol, args []Value) (Value, error)
- func (r *Record) Meta() Value
- func (r *Record) Origin() any
- func (r *Record) RawCount() int
- func (r *Record) RecordType() *RecordType
- func (r *Record) Seq() Seq
- func (r *Record) String() string
- func (r *Record) Type() ValueType
- func (r *Record) Unbox() any
- func (r *Record) ValueAt(key Value) Value
- func (r *Record) ValueAtOr(key Value, notFound Value) Value
- func (r *Record) WithMeta(m Value) Value
- type RecordBase
- type RecordType
- type Reduced
- type Refer
- type Reference
- type Regex
- func (l *Regex) FindAllString(s string, n int) []string
- func (l *Regex) FindAllStringSubmatch(s string, n int) [][]string
- func (l *Regex) FindStringSubmatch(s string) []string
- func (l *Regex) Pattern() string
- func (l *Regex) ReplaceAll(s string, replacement string) string
- func (l *Regex) ReplaceAllFunc(s string, f func(groups []string, present []bool) (string, error)) (string, error)
- func (l *Regex) ReplaceFirst(s string, replacement string) string
- func (l *Regex) ReplaceFirstFunc(s string, f func(groups []string, present []bool) (string, error)) (string, error)
- func (l *Regex) Split(s string, n int) []string
- func (l *Regex) String() string
- func (l *Regex) Type() ValueType
- func (l *Regex) Unbox() any
- type Repeat
- func (n *Repeat) Cons(value Value) Seq
- func (n *Repeat) Count() Value
- func (n *Repeat) First() Value
- func (n *Repeat) More() Seq
- func (n *Repeat) Next() Seq
- func (n *Repeat) RawCount() int
- func (n *Repeat) Seq() Seq
- func (n *Repeat) String() string
- func (n *Repeat) Type() ValueType
- func (n *Repeat) Unbox() any
- type Scope
- func (s *Scope) Await(timeout time.Duration) bool
- func (s *Scope) Cancel()
- func (s *Scope) CancelAll()
- func (s *Scope) Child() *Scope
- func (s *Scope) Context() context.Context
- func (s *Scope) Drain(timeout time.Duration) bool
- func (s *Scope) Go(fn func(ctx context.Context))
- func (s *Scope) Live() int
- func (s *Scope) LiveTree() int
- func (s *Scope) Shutdown(timeout time.Duration) bool
- func (s *Scope) String() string
- func (s *Scope) Type() ValueType
- func (s *Scope) Unbox() any
- type Seq
- type Sequable
- type Set
- func (l Set) Arity() int
- func (l Set) Conj(value Value) Collection
- func (l Set) Cons(val Value) Seq
- func (l Set) Contains(value Value) Boolean
- func (l Set) Count() Value
- func (l Set) Disj(value Value) Set
- func (l Set) Empty() Collection
- func (l Set) First() Value
- func (l Set) Hash() uint32
- func (l Set) Invoke(pargs []Value) (Value, error)
- func (l Set) Meta() Value
- func (l Set) More() Seq
- func (l Set) Next() Seq
- func (l Set) RawCount() int
- func (l Set) Seq() Seq
- func (l Set) String() string
- func (l Set) Type() ValueType
- func (l Set) Unbox() any
- func (l Set) WithMeta(m Value) Value
- type SetSeq
- func (s *SetSeq) Conj(val Value) Collection
- func (s *SetSeq) Cons(val Value) Seq
- func (s *SetSeq) Count() Value
- func (s *SetSeq) Empty() Collection
- func (s *SetSeq) First() Value
- func (s *SetSeq) More() Seq
- func (s *SetSeq) Next() Seq
- func (s *SetSeq) RawCount() int
- func (s *SetSeq) Seq() Seq
- func (s *SetSeq) String() string
- func (s *SetSeq) Type() ValueType
- func (s *SetSeq) Unbox() any
- type SetWithMeta
- type SortedMap
- func (m *SortedMap) Arity() int
- func (m *SortedMap) Assoc(key, val Value) Associative
- func (m *SortedMap) Conj(value Value) Collection
- func (m *SortedMap) Contains(key Value) Boolean
- func (m *SortedMap) Count() Value
- func (m *SortedMap) Dissoc(key Value) Associative
- func (m *SortedMap) Empty() Collection
- func (m *SortedMap) Hash() uint32
- func (m *SortedMap) Invoke(args []Value) (Value, error)
- func (m *SortedMap) Meta() Value
- func (m *SortedMap) RSeq() Seq
- func (m *SortedMap) RawCount() int
- func (m *SortedMap) Seq() Seq
- func (m *SortedMap) String() string
- func (m *SortedMap) Type() ValueType
- func (m *SortedMap) Unbox() any
- func (m *SortedMap) ValueAt(key Value) Value
- func (m *SortedMap) ValueAtOr(key, dflt Value) Value
- func (m *SortedMap) WithMeta(meta Value) Value
- type SortedMapSeq
- func (s *SortedMapSeq) Cons(val Value) Seq
- func (s *SortedMapSeq) Count() Value
- func (s *SortedMapSeq) First() Value
- func (s *SortedMapSeq) More() Seq
- func (s *SortedMapSeq) Next() Seq
- func (s *SortedMapSeq) RawCount() int
- func (s *SortedMapSeq) String() string
- func (s *SortedMapSeq) Type() ValueType
- func (s *SortedMapSeq) Unbox() any
- type SortedSet
- func (s *SortedSet) Arity() int
- func (s *SortedSet) Conj(value Value) Collection
- func (s *SortedSet) Cons(val Value) Seq
- func (s *SortedSet) Contains(value Value) Boolean
- func (s *SortedSet) Count() Value
- func (s *SortedSet) Disj(value Value) *SortedSet
- func (s *SortedSet) Empty() Collection
- func (s *SortedSet) First() Value
- func (s *SortedSet) Hash() uint32
- func (s *SortedSet) Invoke(pargs []Value) (Value, error)
- func (s *SortedSet) Meta() Value
- func (s *SortedSet) More() Seq
- func (s *SortedSet) Next() Seq
- func (s *SortedSet) RSeq() Seq
- func (s *SortedSet) RawCount() int
- func (s *SortedSet) Seq() Seq
- func (s *SortedSet) String() string
- func (s *SortedSet) Type() ValueType
- func (s *SortedSet) Unbox() any
- func (s *SortedSet) ValueAt(key Value) Value
- func (s *SortedSet) ValueAtOr(key Value, dflt Value) Value
- func (s *SortedSet) WithMeta(m Value) Value
- type SortedSetSeq
- func (s *SortedSetSeq) Cons(val Value) Seq
- func (s *SortedSetSeq) Count() Value
- func (s *SortedSetSeq) First() Value
- func (s *SortedSetSeq) More() Seq
- func (s *SortedSetSeq) Next() Seq
- func (s *SortedSetSeq) RawCount() int
- func (s *SortedSetSeq) String() string
- func (s *SortedSetSeq) Type() ValueType
- func (s *SortedSetSeq) Unbox() any
- type SourceInfo
- type SourceMap
- type SourceMapEntry
- type String
- func (l String) Conj(value Value) Collection
- func (l String) Cons(val Value) Seq
- func (l String) Count() Value
- func (l String) Empty() Collection
- func (l String) First() Value
- func (l String) Hash() uint32
- func (l String) InvokeMethod(name Symbol, args []Value) (Value, error)
- func (l String) More() Seq
- func (l String) Next() Seq
- func (l String) Nth(i int) Value
- func (l String) RawCount() int
- func (l String) Seq() Seq
- func (l String) String() string
- func (l String) Type() ValueType
- func (l String) Unbox() any
- func (l String) ValueAt(key Value) Value
- func (l String) ValueAtOr(key Value, dflt Value) Value
- type StructMapping
- type Symbol
- type ThrownError
- type TransientMap
- func (t *TransientMap) Arity() int
- func (t *TransientMap) Assoc(key Value, val Value) (*TransientMap, error)
- func (t *TransientMap) Conj(value Value) (*TransientMap, error)
- func (t *TransientMap) Contains(key Value) Boolean
- func (t *TransientMap) Count() Value
- func (t *TransientMap) Dissoc(key Value) (*TransientMap, error)
- func (t *TransientMap) Invoke(args []Value) (Value, error)
- func (t *TransientMap) Persistent() (*PersistentMap, error)
- func (t *TransientMap) RawCount() int
- func (t *TransientMap) String() string
- func (t *TransientMap) Type() ValueType
- func (t *TransientMap) Unbox() any
- func (t *TransientMap) ValueAt(key Value) Value
- func (t *TransientMap) ValueAtOr(key Value, notFound Value) Value
- type TransientSet
- func (t *TransientSet) Arity() int
- func (t *TransientSet) Conj(value Value) (*TransientSet, error)
- func (t *TransientSet) Contains(key Value) Boolean
- func (t *TransientSet) Count() Value
- func (t *TransientSet) Disj(value Value) (*TransientSet, error)
- func (t *TransientSet) Invoke(args []Value) (Value, error)
- func (t *TransientSet) Persistent() (*PersistentSet, error)
- func (t *TransientSet) RawCount() int
- func (t *TransientSet) String() string
- func (t *TransientSet) Type() ValueType
- func (t *TransientSet) Unbox() any
- func (t *TransientSet) ValueAt(key Value) Value
- func (t *TransientSet) ValueAtOr(key Value, notFound Value) Value
- type TransientVector
- func (t *TransientVector) Arity() int
- func (t *TransientVector) Assoc(key Value, val Value) (*TransientVector, error)
- func (t *TransientVector) Conj(value Value) (*TransientVector, error)
- func (t *TransientVector) Contains(key Value) Boolean
- func (t *TransientVector) Count() Value
- func (t *TransientVector) Invoke(args []Value) (Value, error)
- func (t *TransientVector) Nth(i int) Value
- func (t *TransientVector) Persistent() (Value, error)
- func (t *TransientVector) Pop() (*TransientVector, error)
- func (t *TransientVector) RawCount() int
- func (t *TransientVector) String() string
- func (t *TransientVector) Type() ValueType
- func (t *TransientVector) Unbox() any
- func (t *TransientVector) ValueAt(key Value) Value
- func (t *TransientVector) ValueAtOr(key Value, notFound Value) Value
- type TypeError
- type TypedArray
- func NewByteArray(size int) *TypedArray
- func NewByteArrayFrom(data []byte) *TypedArray
- func NewFloatArray(size int) *TypedArray
- func NewFloatArrayFrom(data []float64) *TypedArray
- func NewIntArray(size int) *TypedArray
- func NewIntArrayFrom(data []int64) *TypedArray
- func NewObjectArray(size int) *TypedArray
- func NewObjectArrayFrom(data []Value) *TypedArray
- func (a *TypedArray) Arity() int
- func (a *TypedArray) Clone() *TypedArray
- func (a *TypedArray) Conj(v Value) Collection
- func (a *TypedArray) Count() Value
- func (a *TypedArray) Empty() Collection
- func (a *TypedArray) Get(i int) Value
- func (a *TypedArray) Invoke(args []Value) (Value, error)
- func (a *TypedArray) Kind() ArrayKind
- func (a *TypedArray) Len() int
- func (a *TypedArray) Meta() Value
- func (a *TypedArray) Nth(i int) Value
- func (a *TypedArray) RawCount() int
- func (a *TypedArray) Seq() Seq
- func (a *TypedArray) Set(i int, v Value) error
- func (a *TypedArray) String() string
- func (a *TypedArray) Type() ValueType
- func (a *TypedArray) Unbox() any
- func (a *TypedArray) ValueAt(key Value) Value
- func (a *TypedArray) ValueAtOr(key Value, dflt Value) Value
- func (a *TypedArray) WithMeta(_ Value) Value
- type TypedArraySeq
- func (s *TypedArraySeq) Conj(val Value) Collection
- func (s *TypedArraySeq) Cons(val Value) Seq
- func (s *TypedArraySeq) Count() Value
- func (s *TypedArraySeq) Empty() Collection
- func (s *TypedArraySeq) First() Value
- func (s *TypedArraySeq) Meta() Value
- func (s *TypedArraySeq) More() Seq
- func (s *TypedArraySeq) Next() Seq
- func (s *TypedArraySeq) Nth(i int) Value
- func (s *TypedArraySeq) RawCount() int
- func (s *TypedArraySeq) Seq() Seq
- func (s *TypedArraySeq) String() string
- func (s *TypedArraySeq) Type() ValueType
- func (s *TypedArraySeq) Unbox() any
- func (s *TypedArraySeq) ValueAt(key Value) Value
- func (s *TypedArraySeq) ValueAtOr(key Value, dflt Value) Value
- func (s *TypedArraySeq) WithMeta(_ Value) Value
- type UUID
- type Value
- func BoxValue(v reflect.Value) (Value, error)
- func ErrorToValue(err error) Value
- func MakeFloat(v float64) Value
- func MakeInt(v int) Value
- func MaybeDowngrade(b *big.Int) Value
- func MaybeSimplifyRatio(r *big.Rat) Value
- func MustBox(v any) Value
- func NewArrayVector(v []Value) Value
- func NewList(vs []Value) Value
- func NewMap(v []Value) Value
- func NewPersistentVector(values []Value) Value
- func NewRange(start, end, step Int) Value
- func NewRegex(s string) (Value, error)
- func NewSet(v []Value) Value
- func NumAbs(a Value) (Value, error)
- func NumAdd(a, b Value) (Value, error)
- func NumAddP(a, b Value) (Value, error)
- func NumDiv(a, b Value) (Value, error)
- func NumMod(a, b Value) (Value, error)
- func NumMul(a, b Value) (Value, error)
- func NumMulP(a, b Value) (Value, error)
- func NumNeg(a Value) (Value, error)
- func NumNegP(a Value) (Value, error)
- func NumQuot(a, b Value) (Value, error)
- func NumRem(a, b Value) (Value, error)
- func NumSub(a, b Value) (Value, error)
- func NumSubP(a, b Value) (Value, error)
- func RunWithBindings(snap BindingSnapshot, fn func() (Value, error)) (Value, error)
- func SeqToSlice(v Value) ([]Value, error)
- func ToLetGo(v any) (Value, error)
- type ValueType
- type Var
- func (v *Var) AddWatch(key Value, fn Fn)
- func (v *Var) AlterMeta(fn Fn, args []Value) (Value, error)
- func (v *Var) AlterRoot(fn Fn) (Value, error)
- func (v *Var) AlterRootArgs(fn Fn, args []Value) (Value, error)
- func (v *Var) Arity() int
- func (v *Var) Deref() Value
- func (v *Var) Invoke(values []Value) (Value, error)
- func (v *Var) IsBound() bool
- func (v *Var) IsDynamic() bool
- func (v *Var) IsMacro() bool
- func (v *Var) IsPrivate() bool
- func (v *Var) Meta() Value
- func (v *Var) NS() string
- func (v *Var) PopBinding()
- func (v *Var) PushBinding(val Value)
- func (v *Var) RemoveWatch(key Value)
- func (v *Var) Root() Value
- func (v *Var) SetDynamic()
- func (v *Var) SetMacro()
- func (v *Var) SetMeta(meta Value)
- func (v *Var) SetPrivate()
- func (v *Var) SetRoot(val Value) *Var
- func (v *Var) String() string
- func (v *Var) Type() ValueType
- func (v *Var) Unbox() any
- func (v *Var) VarName() string
- type Void
- type Volatile
Constants ¶
const ( OP_NOOP int32 = iota // do nothing OP_LOAD_CONST // load constant LDC (index int32) OP_LOAD_ARG // load argument LDA (index int32) OP_INVOKE // invoke function OP_RETURN // return from function OP_BRANCH_TRUE // branch if truthy BRANCH_TRUE (offset int32) OP_BRANCH_FALSE // branch if falsy BRF (offset int32) OP_JUMP // jump by offset JMP (offset int32) OP_POP // pop value from the stack and discard it OP_POP_N // save top and pop n elements from the stack POP_N (n int32) OP_DUP_NTH // duplicate nth value from the stack OPN (n int32) OP_SET_VAR // set var OP_LOAD_VAR // push var root OP_MAKE_CLOSURE // make a closure out of fn OP_LOAD_CLOSEDOVER // load closed over LDK (index int32) OP_PUSH_CLOSEDOVER // push closed over value to a closure OP_RECUR // loop recurse RECUR (offset int32, argc int32) OP_RECUR_FN // function recurse REF (argc int32) OP_TRACE_ENABLE // enable tracing OP_TRACE_DISABLE // disable tracing OP_MAKE_MULTI_ARITY // make multi-arity function (n int32) OP_TAIL_CALL // like OP_INVOKE but re-uses the frame OP_TRY_PUSH // push exception handler (catchOffset int32, finallyOffset int32) OP_TRY_POP // pop exception handler (normal completion) OP_THROW // throw top-of-stack value // Specialized arithmetic/comparison opcodes (binary, stack: [a b] -> [result]) // These inline the common int64 fast path and fall back to generic NumXxx for other types. OP_ADD // + (2 args) OP_SUB // - (2 args) OP_MUL // * (2 args) OP_LT // < (2 args) OP_LTE // <= (2 args) OP_GT // > (2 args) OP_GTE // >= (2 args) OP_EQ // = (2 args) OP_INC // inc (1 arg) OP_DEC // dec (1 arg) OP_QUOT // quot — integer quotient, truncated toward zero (2 args) OP_DIV // / — true division; int/int yields a Ratio (or Int when exact), any float yields Float (2 args) )
Opcodes
const BigDecimalPrecConst = bigDecimalPrec
Variables ¶
var ( IFnProtocol *Protocol IFnInvoke Fn // IDerefProtocol / IDerefDeref wire "derefable values": any value whose type // satisfies IDeref can be used with @ / deref, dispatched to its -deref // method. Set once by the runtime after core defines the IDeref protocol. IDerefProtocol *Protocol IDerefDeref Fn )
IFnProtocol and IFnInvoke wire up "invokable values": any value whose type satisfies IFnProtocol can be called like a function, with the call dispatched to its -invoke method (the IFnInvoke protocol fn). They are set once by the runtime after core defines the IFn protocol; until then invoking a non-Fn value is a plain type error, as before.
var AnyType *theAnyType = &theAnyType{}
var ArrayVectorType *theArrayVectorType = &theArrayVectorType{}
ArrayVectorType is the type of ArrayVectors
var AtomType *theAtomType = &theAtomType{}
var BigDecimalType *theBigDecimalType = &theBigDecimalType{}
var BigIntType *theBigIntType = &theBigIntType{}
var BooleanType *theBooleanType = &theBooleanType{zero: FALSE}
BooleanType is the type of Boolean
var BoxedTypes map[string]*aBoxedType = map[string]*aBoxedType{}
BoxedType is the type of NilValues
var ChanType *theChanType = &theChanType{}
ChanType is the type of Chan
var CharType *theCharType = &theCharType{zero: utf8.RuneError}
CharType is the type of CharValues
var ComparableFallback func(a, b Value) (int, bool, error)
ComparableFallback, when set, is consulted by DefaultCompare for values it cannot order natively. It dispatches on a's type only (mirroring Clojure's compare, which calls a.compareTo(b)) and returns (result, handled, err): handled is false when a's type has no Comparable implementation, in which case DefaultCompare reports its usual error. The runtime (package rt) wires this at init to route through the Comparable protocol; it lives here as a hook to avoid a vm->rt import cycle. Because compare, sort, and sorted-set all funnel through DefaultCompare, registering once makes all three respect Comparable — matching Clojure, where sort/sorted-set use compare.
var DelayType *theDelayType = &theDelayType{}
var EmptyPersistentMap = &PersistentMap{count: 0, root: nil}
EmptyPersistentMap is the canonical empty persistent map.
var EmptyPersistentSet = &PersistentSet{impl: EmptyPersistentMap}
EmptyPersistentSet is the canonical empty set.
var EmptySortedMap = &SortedMap{cmp: DefaultCompare}
var EmptySortedSet = &SortedSet{impl: EmptySortedMap}
var ExInfoType *theExInfoType = &theExInfoType{}
var FloatType *theFloatType = &theFloatType{zero: 0}
FloatType is the type of Float values
var FormSource = &formSourceMap{m: map[any]*SourceInfo{}}
FormSource maps form values to their source locations. Used by the compiler to attach source info to bytecode. Only pointer-based types (like *List) can be tracked; slice/value types are not hashable and are silently ignored.
var FuncType *theFuncType = &theFuncType{}
var Goroutines = newRootScope()
Goroutines is the process-wide root scope. Every VM spawn goes through a scope; blocking ops consult its Context for cancellation.
var InstantType *theInstantType = &theInstantType{}
InstantType is the type of Instant values.
var IntType *theIntType = &theIntType{zero: 0}
IntType is the type of IntValues
var IterateType *theIterateType = &theIterateType{zero: nil}
IterateType is the type of IterateValues
var KeywordType *theKeywordType = &theKeywordType{zero: "????BADKeyword????"}
KeywordType is the type of KeywordValues
var ListType *theListType = &theListType{}
ListType is the type of Lists
var MapType *theMapType = &theMapType{}
ArrayVectorType is the type of ArrayVectors
var MultiFnType *theMultiFnType = &theMultiFnType{}
var NamespaceType *theNamespaceType = &theNamespaceType{}
var NativeFnType *theNativeFnType = &theNativeFnType{}
var NilType *theNilType = &theNilType{zero: nil}
NilType is the type of NilValues
var PersistentMapType *thePersistentMapType = &thePersistentMapType{}
PersistentMapType is the type of PersistentMap values.
var PersistentVectorType *thePersistentVectorType = &thePersistentVectorType{}
PersistentVectorType is the type of PersistentVectors
var ProfilingEnabled atomic.Bool
ProfilingEnabled gates the per-opcode increments in Frame.Run. Read on every opcode dispatch when true; a single atomic Load.
var PromiseType *thePromiseType = &thePromiseType{}
var ProtocolType *theProtocolType = &theProtocolType{}
var RangeType *theRangeType = &theRangeType{}
RangeType is the type of Lists
var RatioType *theRatioType = &theRatioType{}
var ReducedType *theReducedType = &theReducedType{}
var RegexType *theRegexType = &theRegexType{}
RegexType is the type of RegexValues
var RepeatType *theRepeatType = &theRepeatType{zero: nil}
RepeatType is the type of RepeatValues
var RootExecContext = &ExecContext{bindings: globalBindingStack}
RootExecContext is the always-available default context. Frames with no more specific context resolve against it.
var ScopeType *theScopeType = &theScopeType{}
ScopeType is the Value type of a Scope handle.
var SequenceType *theSequenceType = &theSequenceType{}
SequenceType is the type of Sequences
var SetType *theSetType = &theSetType{}
ArrayVectorType is the type of ArrayVectors
var SortedMapType *theSortedMapType = &theSortedMapType{}
var SortedSetType *theSortedSetType = &theSortedSetType{}
var SourceRegistry = &sourceRegistry{sources: map[string]string{}}
SourceRegistry stores source text for error display. Maps file names to their full source text.
var StringType *theStringType = &theStringType{zero: ""}
StringType is the type of StringValues
var SymbolType *theSymbolType = &theSymbolType{zero: "????BADSYMBOL????"}
SymbolType is the type of Symbol values
var TransientMapType *theTransientMapType = &theTransientMapType{}
var TransientSetType *theTransientSetType = &theTransientSetType{}
var TransientVectorType *theTransientVectorType = &theTransientVectorType{}
var TypeType *theTypeType = &theTypeType{}
var TypedArrayType *theTypedArrayType = &theTypedArrayType{}
TypedArrayType is the singleton type for all typed arrays.
var UUIDType *theUUIDType = &theUUIDType{}
UUIDType is the type of UUID values
var ValueEquals func(a, b Value) bool
ValueEquals performs deep structural equality comparison. Used by the = operator and OP_EQ opcode.
var VoidType *theVoidType = &theVoidType{zero: &Void{}}
VoidType is the type of VoidValues
var VolatileType *theVolatileType = &theVolatileType{}
Functions ¶
func CloseScoped ¶ added in v1.9.0
CloseScoped tears a with-scope child down: cancel the subtree, drain up to timeout (warn on a straggler), restore the caller's previous current scope via the restore closure OpenChildEC installed, and unparent the child so it is not retained.
func DefaultCompare ¶ added in v1.5.0
DefaultCompare is the default comparator used by sorted collections. It handles nil, numbers, strings, keywords, symbols, booleans, and chars.
func FormatError ¶
FormatError produces a user-friendly error display with source snippets, inspired by Rust/Elm-style error reporting.
func HashValue ¶ added in v1.3.1
HashValue computes a 32-bit hash for any Value type (exported for builtins).
func IsBigDecimal ¶ added in v1.5.0
IsBigDecimal returns true if v is a *BigDecimal.
func Iter ¶ added in v1.8.0
Iter returns a Go-1.23+ iter.Seq[Value] over any let-go sequence value. Yields nothing if v is nil/NIL or isn't a sequence.
Preserves laziness: the underlying LazySeq thunks are realized one step at a time as the consumer pulls values, and an early break stops realization.
Idiomatic use:
for v := range vm.Iter(result) {
// process v
}
Composes with slices.Collect, slices.Filter, etc.
func NumEq ¶
NumEq tests Clojure = numeric equality. Exact integers compare across fixed/big integer representations, floating values compare by value, and BigDecimal only compares with BigDecimal.
func NumEquivalent ¶ added in v1.8.0
NumEquivalent tests broad numeric equivalence for == and numeric predicates.
func OpcodeToString ¶
func RecordOpcode ¶ added in v1.9.0
func RecordOpcode(prevOp, currOp uint8)
RecordOpcode is called from Frame.Run on every dispatch when ProfilingEnabled is true. prevOp is the previous opcode byte (or 0 at frame start).
func ReleaseFrame ¶
func ReleaseFrame(f *Frame)
ReleaseFrame returns a frame to the pool. We don't clear stack slots — they'll be overwritten on reuse. We only nil out the large reference fields to avoid pinning code/const objects.
func SeqIsEmpty ¶ added in v1.8.0
SeqIsEmpty reports whether a Seq is exhausted. Encapsulates the two sentinels — Go nil and the EmptyList singleton — that let-go uses interchangeably to signal end-of-sequence.
Use this to avoid the common `for s != nil && s != EmptyList` pattern.
func SeqValues ¶ added in v1.8.0
SeqValues returns an iter.Seq[Value] that walks a Seq from a known Seq starting point. Use when you already have a Seq; use Iter when you have a Value (which may be Sequable or non-seq).
func SetCoreNamespace ¶ added in v1.8.0
func SetCoreNamespace(ns *Namespace)
SetCoreNamespace registers clojure.core for the warn-on-shadow check. Called once during rt initialization.
func SetNSLookup ¶
SetNSLookup sets the global namespace lookup function.
func SetValueEquals ¶ added in v1.2.0
SetValueEquals sets the equality function (called by rt package during init).
Types ¶
type ArrayChunk ¶ added in v1.9.0
type ArrayChunk struct {
// contains filtered or unexported fields
}
ArrayChunk is a slice-backed IChunk. It uses an off/end window over a shared backing array so DropFirst is allocation-free.
func NewArrayChunk ¶ added in v1.9.0
func NewArrayChunk(vs []Value, off, end int) *ArrayChunk
NewArrayChunk wraps vs[off:end] as an IChunk. The slice is shared; callers must treat it as immutable from this point.
func NewArrayChunkFromValues ¶ added in v1.9.0
func NewArrayChunkFromValues(vs []Value) *ArrayChunk
NewArrayChunkFromValues copies vs into a fresh chunk. Convenience for callers that don't already have a stable backing slice.
func (*ArrayChunk) ChunkCount ¶ added in v1.9.0
func (c *ArrayChunk) ChunkCount() int
func (*ArrayChunk) Count ¶ added in v1.9.0
func (c *ArrayChunk) Count() Value
Counted lets Lisp `(count chunk)` work on a chunk directly.
func (*ArrayChunk) DropFirst ¶ added in v1.9.0
func (c *ArrayChunk) DropFirst() IChunk
func (*ArrayChunk) Nth ¶ added in v1.9.0
func (c *ArrayChunk) Nth(i int) Value
func (*ArrayChunk) RawCount ¶ added in v1.9.0
func (c *ArrayChunk) RawCount() int
func (*ArrayChunk) String ¶ added in v1.9.0
func (c *ArrayChunk) String() string
func (*ArrayChunk) Type ¶ added in v1.9.0
func (c *ArrayChunk) Type() ValueType
func (*ArrayChunk) Unbox ¶ added in v1.9.0
func (c *ArrayChunk) Unbox() any
func (*ArrayChunk) ValueAt ¶ added in v1.9.0
func (c *ArrayChunk) ValueAt(key Value) Value
Lookup so `(nth chunk i)` and `(get chunk i)` work.
type ArrayKind ¶ added in v1.3.1
type ArrayKind int
ArrayKind discriminates the element type of a TypedArray.
type ArrayVector ¶
type ArrayVector []Value
ArrayVector is boxed singly linked list that can hold other Values.
func (ArrayVector) Arity ¶
func (l ArrayVector) Arity() int
func (ArrayVector) Assoc ¶
func (l ArrayVector) Assoc(k Value, v Value) Associative
func (ArrayVector) Conj ¶
func (l ArrayVector) Conj(val Value) Collection
func (ArrayVector) Contains ¶
func (l ArrayVector) Contains(value Value) Boolean
func (ArrayVector) Dissoc ¶
func (l ArrayVector) Dissoc(k Value) Associative
func (ArrayVector) Equals ¶
func (l ArrayVector) Equals(other Value) bool
Equals implements value equality for ArrayVector
func (ArrayVector) Hash ¶
func (l ArrayVector) Hash() uint32
Type implements Value Hash implements Hashable. Computed from elements.
func (ArrayVector) Meta ¶
func (l ArrayVector) Meta() Value
Meta implements IMeta. ArrayVector doesn't store meta, always returns NIL.
func (ArrayVector) Nth ¶ added in v1.11.0
func (l ArrayVector) Nth(i int) Value
func (ArrayVector) RawCount ¶
func (l ArrayVector) RawCount() int
func (ArrayVector) Seq ¶
func (l ArrayVector) Seq() Seq
func (ArrayVector) String ¶
func (l ArrayVector) String() string
func (ArrayVector) Type ¶
func (l ArrayVector) Type() ValueType
func (ArrayVector) ValueAt ¶
func (l ArrayVector) ValueAt(key Value) Value
func (ArrayVector) WithMeta ¶
func (l ArrayVector) WithMeta(m Value) Value
WithMeta implements IMeta. Promotes to PersistentVector to carry meta.
type ArrayVectorSeq ¶
type ArrayVectorSeq struct {
// contains filtered or unexported fields
}
ArrayVectorSeq is a lightweight seq view over an ArrayVector
func (*ArrayVectorSeq) Conj ¶
func (s *ArrayVectorSeq) Conj(val Value) Collection
func (*ArrayVectorSeq) Cons ¶
func (s *ArrayVectorSeq) Cons(val Value) Seq
func (*ArrayVectorSeq) Count ¶
func (s *ArrayVectorSeq) Count() Value
func (*ArrayVectorSeq) Empty ¶
func (s *ArrayVectorSeq) Empty() Collection
func (*ArrayVectorSeq) First ¶
func (s *ArrayVectorSeq) First() Value
func (*ArrayVectorSeq) More ¶
func (s *ArrayVectorSeq) More() Seq
func (*ArrayVectorSeq) Next ¶
func (s *ArrayVectorSeq) Next() Seq
func (*ArrayVectorSeq) Nth ¶ added in v1.11.0
func (s *ArrayVectorSeq) Nth(i int) Value
Nth implements Indexed: positional access by integer index.
func (*ArrayVectorSeq) RawCount ¶
func (s *ArrayVectorSeq) RawCount() int
func (*ArrayVectorSeq) Seq ¶
func (s *ArrayVectorSeq) Seq() Seq
func (*ArrayVectorSeq) String ¶
func (s *ArrayVectorSeq) String() string
func (*ArrayVectorSeq) Type ¶
func (s *ArrayVectorSeq) Type() ValueType
func (*ArrayVectorSeq) Unbox ¶
func (s *ArrayVectorSeq) Unbox() any
func (*ArrayVectorSeq) ValueAt ¶
func (s *ArrayVectorSeq) ValueAt(key Value) Value
ValueAt implements Lookup for ArrayVectorSeq so that `get` works on seq views.
type Associative ¶
type Associative interface {
Value
Assoc(Value, Value) Associative
Dissoc(Value) Associative
}
type Atom ¶
type Atom struct {
// contains filtered or unexported fields
}
Atom is a thread-safe mutable reference. Swap uses optimistic concurrency with a generation counter — no value comparison needed. The function may be called multiple times under contention.
func NewAtomWithMetaValidator ¶ added in v1.8.0
func (*Atom) CompareAndSet ¶ added in v1.10.0
CompareAndSet atomically sets the value to newVal only if the current value is identical to oldVal, returning true on success. Identity comparison (==), matching Clojure's compare-and-set!.
func (*Atom) RemoveWatch ¶
type BigDecimal ¶ added in v1.5.0
type BigDecimal struct {
// contains filtered or unexported fields
}
BigDecimal wraps *math/big.Float as a VM value with arbitrary precision.
func MustBigDecimalFromString ¶ added in v1.11.0
func MustBigDecimalFromString(s string) *BigDecimal
MustBigDecimalFromString builds a BigDecimal from a string, panicking on an unparseable input. Intended for gogen-emitted constant literals, whose source strings were already validated at read time, so the panic is unreachable in generated code — it exists only to give a single-value expression form (the (value, ok) signature of NewBigDecimalFromString can't be used inline).
func NewBigDecimal ¶ added in v1.5.0
func NewBigDecimal(v *big.Float) *BigDecimal
func NewBigDecimalFromFloat64 ¶ added in v1.5.0
func NewBigDecimalFromFloat64(f float64) *BigDecimal
func NewBigDecimalFromInt64 ¶ added in v1.5.0
func NewBigDecimalFromInt64(n int64) *BigDecimal
func NewBigDecimalFromString ¶ added in v1.5.0
func NewBigDecimalFromString(s string) (*BigDecimal, bool)
func (*BigDecimal) Equals ¶ added in v1.5.0
func (b *BigDecimal) Equals(other Value) bool
Equals compares BigDecimals.
func (*BigDecimal) GoString ¶ added in v1.5.0
func (b *BigDecimal) GoString() string
func (*BigDecimal) Hash ¶ added in v1.5.0
func (b *BigDecimal) Hash() uint32
Hash implements Hashable.
func (*BigDecimal) String ¶ added in v1.5.0
func (b *BigDecimal) String() string
func (*BigDecimal) ToFloat64 ¶ added in v1.5.0
func (b *BigDecimal) ToFloat64() float64
ToFloat64 converts to float64.
func (*BigDecimal) Type ¶ added in v1.5.0
func (b *BigDecimal) Type() ValueType
func (*BigDecimal) Unbox ¶ added in v1.5.0
func (b *BigDecimal) Unbox() any
func (*BigDecimal) Val ¶ added in v1.5.0
func (b *BigDecimal) Val() *big.Float
type BigInt ¶
type BigInt struct {
// contains filtered or unexported fields
}
BigInt wraps *math/big.Int as a VM value.
func MustBigIntFromString ¶ added in v1.11.0
MustBigIntFromString builds a BigInt from its base-10 string form, panicking on an unparseable input. Intended for gogen-emitted constant literals (the source was validated at read time, so the panic is unreachable in generated code); gives a single-value expression form the (value, ok) constructor can't.
func NewBigIntFromInt64 ¶
func NewBigIntFromString ¶
func (*BigInt) Hash ¶
Hash implements Hashable — consistent with Int.Hash() for values that fit in int64.
type BindingSnapshot ¶ added in v1.8.0
func SnapshotBindings ¶ added in v1.8.0
func SnapshotBindings() BindingSnapshot
SnapshotBindings captures the root context's dynamic bindings — the explicit-propagation primitive a goroutine spawn hands to its child.
type BlockingDeref ¶ added in v1.10.0
BlockingDeref is a reference whose value may not be available yet (promise, future). DerefTimeout blocks up to timeoutMs for the value, returning timeoutVal on timeout. Backs Clojure's 3-arg deref.
type Boxed ¶
type Boxed struct {
// contains filtered or unexported fields
}
func (*Boxed) Hash ¶ added in v1.11.0
Hash implements Hashable. Without it, hashValue falls back to computeHash -> hashBytes(String()), which formats the boxed value via fmt.Sprintf("%v") on EVERY hash — catastrophic when boxed values (e.g. SourceInfo) are embedded in IR vectors that get hashed repeatedly during lowering (= comparisons, CSE, map/set keys). *Boxed is an immutable pointer, so we compute the String-based hash once and cache it. The value is identical to the old computeHash fallback, so map/set semantics are unchanged — only the repeated Sprintf is eliminated.
func (*Boxed) InvokeMethod ¶
type ChunkBuffer ¶ added in v1.9.0
type ChunkBuffer struct {
// contains filtered or unexported fields
}
ChunkBuffer is a mutable builder for an ArrayChunk. Use Append to fill, then Chunk() to finalize — the returned IChunk takes ownership of the buffer.
func NewChunkBuffer ¶ added in v1.9.0
func NewChunkBuffer(cap int) *ChunkBuffer
NewChunkBuffer returns a buffer pre-sized for cap elements. Append grows beyond cap if needed.
func (*ChunkBuffer) Append ¶ added in v1.9.0
func (b *ChunkBuffer) Append(v Value)
func (*ChunkBuffer) Chunk ¶ added in v1.9.0
func (b *ChunkBuffer) Chunk() IChunk
Chunk finalizes the buffer into an IChunk and clears the buffer so further Append calls operate on a fresh backing slice.
func (*ChunkBuffer) Count ¶ added in v1.9.0
func (b *ChunkBuffer) Count() Value
Counted: lets `(count buf)` return the number of elements buffered so far.
func (*ChunkBuffer) RawCount ¶ added in v1.9.0
func (b *ChunkBuffer) RawCount() int
func (*ChunkBuffer) String ¶ added in v1.9.0
func (b *ChunkBuffer) String() string
func (*ChunkBuffer) Type ¶ added in v1.9.0
func (b *ChunkBuffer) Type() ValueType
ChunkBuffer satisfies Value so it can be threaded through Lisp.
func (*ChunkBuffer) Unbox ¶ added in v1.9.0
func (b *ChunkBuffer) Unbox() any
type ChunkedCons ¶ added in v1.9.0
type ChunkedCons struct {
// contains filtered or unexported fields
}
ChunkedCons pairs a non-empty IChunk with a tail seq. It is itself both a Seq and an IChunkedSeq: the chunk is the head batch, `more` is whatever comes after.
func NewChunkedCons ¶ added in v1.9.0
func NewChunkedCons(chunk IChunk, more Seq) *ChunkedCons
NewChunkedCons returns a ChunkedCons. The chunk must be non-empty; callers that may have an empty chunk should use ConsChunk which folds the empty case down to `more`.
func (*ChunkedCons) ChunkedFirst ¶ added in v1.9.0
func (c *ChunkedCons) ChunkedFirst() IChunk
func (*ChunkedCons) ChunkedMore ¶ added in v1.9.0
func (c *ChunkedCons) ChunkedMore() Seq
func (*ChunkedCons) ChunkedNext ¶ added in v1.9.0
func (c *ChunkedCons) ChunkedNext() Seq
func (*ChunkedCons) Cons ¶ added in v1.9.0
func (c *ChunkedCons) Cons(val Value) Seq
func (*ChunkedCons) First ¶ added in v1.9.0
func (c *ChunkedCons) First() Value
func (*ChunkedCons) Hash ¶ added in v1.9.0
func (c *ChunkedCons) Hash() uint32
Hash implements Hashable, mirroring Cons/List ordered hashing so the three seq surfaces equate in sets and maps.
func (*ChunkedCons) More ¶ added in v1.9.0
func (c *ChunkedCons) More() Seq
func (*ChunkedCons) Next ¶ added in v1.9.0
func (c *ChunkedCons) Next() Seq
func (*ChunkedCons) Seq ¶ added in v1.9.0
func (c *ChunkedCons) Seq() Seq
func (*ChunkedCons) String ¶ added in v1.9.0
func (c *ChunkedCons) String() string
func (*ChunkedCons) Type ¶ added in v1.9.0
func (c *ChunkedCons) Type() ValueType
func (*ChunkedCons) Unbox ¶ added in v1.9.0
func (c *ChunkedCons) Unbox() any
type CodeChunk ¶
type CodeChunk struct {
// contains filtered or unexported fields
}
func NewCodeChunk ¶
func (*CodeChunk) AddLocalVar ¶ added in v1.10.0
AddLocalVar records the source name bound to a stack slot (debug info).
func (*CodeChunk) AddSourceInfo ¶
func (c *CodeChunk) AddSourceInfo(info SourceInfo)
AddSourceInfo records the source location for the current bytecode offset.
func (*CodeChunk) AppendChunk ¶
func (*CodeChunk) GetSourceMap ¶ added in v1.3.0
GetSourceMap returns the source map, may be nil.
func (*CodeChunk) LocalVars ¶ added in v1.10.0
LocalVars returns the chunk's local-variable debug table (may be nil).
func (*CodeChunk) LookupSource ¶
func (c *CodeChunk) LookupSource(ip int) *SourceInfo
LookupSource finds the source location for a given instruction pointer.
func (*CodeChunk) SetMaxStack ¶
type Collection ¶
type Collection interface {
Value
Counted
Empty() Collection
Conj(Value) Collection
}
Collection is implemented by all collections
type Comparator ¶ added in v1.5.0
Comparator is a function that compares two Values, returning -1, 0, or 1.
type Cons ¶
type Cons struct {
// contains filtered or unexported fields
}
Cons is a cons cell - a pair of (first, rest) where rest is a seq. This is the fundamental building block for consing onto any seq.
func (*Cons) Conj ¶
func (c *Cons) Conj(val Value) Collection
func (*Cons) Empty ¶
func (c *Cons) Empty() Collection
type Consts ¶
type Consts struct {
// contains filtered or unexported fields
}
Consts is a constant pool with O(1) indexed access and O(1) amortized interning. Uses a custom open-addressing hash map (not Go's built-in map) so that all Value types — including slices like ArrayVector — can be interned without panicking.
Supports optional layering: a child pool references a parent. Indices 0..base-1 are in the parent, base.. are in the child. Only child entries are returned by Values() for serialization.
func NewChildConsts ¶ added in v1.3.0
NewChildConsts creates a child pool layered on top of parent. Parent values are accessible by index but not serialized with this pool.
func (*Consts) Append ¶ added in v1.3.0
Append adds a value at the next index without deduplication. Used when loading pre-compiled bytecode where indices must match the original.
func (*Consts) Intern ¶
Intern returns the index for v, adding it if not already present. Checks parent pool first (if any) to reuse existing indices.
type DType ¶ added in v1.5.0
type DType struct {
// contains filtered or unexported fields
}
DType is a dynamically-created ValueType for a deftype. Unlike RecordType, instances of a DType do NOT implement map behavior (no Associative, Lookup, Seqable, or Collection interfaces).
type DTypeInstance ¶ added in v1.5.0
type DTypeInstance struct {
// contains filtered or unexported fields
}
DTypeInstance is a value created by a deftype constructor. Fields are stored in a flat array, accessed by symbol name via Receiver.
func NewDTypeInstance ¶ added in v1.5.0
func NewDTypeInstance(dt *DType, fields []Value) *DTypeInstance
func (*DTypeInstance) DType ¶ added in v1.5.0
func (d *DTypeInstance) DType() *DType
DType returns the type.
func (*DTypeInstance) Equals ¶ added in v1.5.0
func (d *DTypeInstance) Equals(other Value) bool
Equals: reference identity, matching JVM deftype semantics.
func (*DTypeInstance) Fields ¶ added in v1.5.0
func (d *DTypeInstance) Fields() []Value
Fields returns the field values.
func (*DTypeInstance) Hash ¶ added in v1.5.0
func (d *DTypeInstance) Hash() uint32
Hash: identity-based (matches JVM default hashCode).
func (*DTypeInstance) InvokeMethod ¶ added in v1.5.0
func (d *DTypeInstance) InvokeMethod(name Symbol, args []Value) (Value, error)
InvokeMethod implements Receiver so (.fieldname instance) returns the field. Both (.field x) and the explicit field-access form (.-field x) are accepted: the reader hands the latter through as the member symbol "-field", so a leading "-" is stripped before the field lookup (Clojure's .-field syntax).
func (*DTypeInstance) Meta ¶ added in v1.10.0
func (d *DTypeInstance) Meta() Value
Meta implements IMeta.
func (*DTypeInstance) SetField ¶ added in v1.10.0
func (d *DTypeInstance) SetField(name Symbol, val Value) error
SetField mutates a field in place by name. Backs cljs-style ^:mutable deftype fields. UNSYNCHRONIZED: not safe for concurrent access; callers must ensure exclusive access (single-threaded use, atoms, or explicit locks). A Go nil is normalized to NIL to preserve the field-value invariant.
func (*DTypeInstance) String ¶ added in v1.5.0
func (d *DTypeInstance) String() string
func (*DTypeInstance) Type ¶ added in v1.5.0
func (d *DTypeInstance) Type() ValueType
func (*DTypeInstance) Unbox ¶ added in v1.5.0
func (d *DTypeInstance) Unbox() any
func (*DTypeInstance) WithMeta ¶ added in v1.10.0
func (d *DTypeInstance) WithMeta(m Value) Value
WithMeta implements IMeta. Returns a copy carrying m; field storage is shared with the original (metadata does not affect fields).
type Delay ¶
type Delay struct {
// contains filtered or unexported fields
}
Delay wraps a thunk (zero-arg function) that is evaluated at most once. The result is cached after the first call to Force().
func (*Delay) IsRealized ¶
type ExInfo ¶
type ExInfo struct {
// contains filtered or unexported fields
}
ExInfo is an exception value carrying a message and data map. Equivalent to Clojure's ExceptionInfo.
func (*ExInfo) Data ¶
func (e *ExInfo) Data() *PersistentMap
func (*ExInfo) InvokeMethod ¶ added in v1.10.0
InvokeMethod implements Receiver so the JVM-interop method forms (.getMessage ex) / (.getCause ex) dispatch to an ex-info value. This lets libraries that branch on (instance? Throwable ex) and then call .getMessage — e.g. medley's ex-message/ex-cause on their :clj branch — work against let-go ex-info values. Mirrors the semantics of core's ex-message/ex-cause.
func (*ExInfo) Meta ¶ added in v1.10.0
Meta / WithMeta implement IMeta. Type hints compile to runtime metadata in let-go, so medley's (.getMessage ^Throwable ex) reaches (with-meta ex ...); supporting metadata lets that hinted call work. WithMeta returns a copy that is still *ExInfo, preserving Type()==ExInfoType (so (instance? Throwable ex) stays true) and InvokeMethod (so .getMessage/.getCause still dispatch).
type ExecContext ¶ added in v1.11.0
type ExecContext struct {
// contains filtered or unexported fields
}
ExecContext is the single object that resolves an execution's dynamic state — both the dynamic-var binding stack and the structured-concurrency Scope (see docs/design/exec-context-threading.md). It is the *implementer* of invocation and of dynamic resolution: the eval loop, builtins, and goroutine spawn all go through an ExecContext rather than looking state up by goroutine id.
There is always an ExecContext in play. RootExecContext is the process default — its binding stack is the shared global one and its scope is the root Goroutines scope, so code that never asks for isolation behaves exactly as it always has. Per-goroutine isolation is explicit: a spawn hands the child a fresh ExecContext seeded from a snapshot of the parent's (ec.Child()) — carrying the parent's bindings and scope — so goroutines cannot interleave each other's dynamic state, with no goroutine-id lookup and no reuse hazard.
func NewExecContext ¶ added in v1.11.0
func NewExecContext() *ExecContext
NewExecContext returns a context with a fresh, empty binding stack.
func NewExecContextFrom ¶ added in v1.11.0
func NewExecContextFrom(snap BindingSnapshot) *ExecContext
NewExecContextFrom returns a fresh context whose binding stack is seeded from snap. It is the per-call isolation primitive: bound-fn* captures a snapshot once and builds a fresh context from it on every invocation, so the wrapped function always re-establishes exactly the captured bindings and never leaks pushes between calls or across goroutines.
func (*ExecContext) Bind ¶ added in v1.11.0
func (ec *ExecContext) Bind(fn Fn) Fn
Bind pins fn to this context: the returned Fn routes every later call through ec.Invoke, so a callback handed to context-free machinery (Atom retry loops, sort comparators, stored transducer steps) still resolves dynamic vars against the caller's context. At the root this is the identity — plain Invoke already resolves there — so root-context callers pay nothing.
func (*ExecContext) BindingSnapshot ¶ added in v1.11.0
func (ec *ExecContext) BindingSnapshot() BindingSnapshot
BindingSnapshot returns a snapshot of this context's current bindings, suitable for passing to NewExecContextFrom to isolate a child context. A nil receiver uses the root context.
func (*ExecContext) Child ¶ added in v1.11.0
func (ec *ExecContext) Child() *ExecContext
Child returns a fresh ExecContext seeded from a snapshot of this one's bindings — the explicit-propagation primitive used at goroutine boundaries. A nil receiver seeds from the root context.
func (*ExecContext) Context ¶ added in v1.11.0
func (ec *ExecContext) Context() context.Context
Context returns the cancellation context blocking native ops (channel take/put, alts!) select on — the scope's context.
func (*ExecContext) Deref ¶ added in v1.11.0
func (ec *ExecContext) Deref(v *Var) Value
func (*ExecContext) Invoke ¶ added in v1.11.0
func (ec *ExecContext) Invoke(fn Fn, args []Value) (Value, error)
Invoke runs fn with args in this context. Closures propagate the context to their child frame; context-aware natives receive it; pure functions are invoked unchanged. This is the single dispatch site the eval loop uses.
func (*ExecContext) PopBinding ¶ added in v1.11.0
func (ec *ExecContext) PopBinding(v *Var)
func (*ExecContext) PushBinding ¶ added in v1.11.0
func (ec *ExecContext) PushBinding(v *Var, val Value)
Exported entry points for runtime builtins (pkg/rt) that resolve dynamic vars against an ExecContext handed to them by ec.Invoke.
func (*ExecContext) Scope ¶ added in v1.11.0
func (ec *ExecContext) Scope() *Scope
Scope returns the structured-concurrency scope this context runs under, normalising the nil (root) context to the process-wide Goroutines scope. A nil receiver also resolves to the root.
func (*ExecContext) SetBinding ¶ added in v1.11.0
func (ec *ExecContext) SetBinding(v *Var, val Value) bool
SetBinding mutates v's top dynamic binding in this context (thread-local set!), returning false if v has no active binding here so the caller can fall back to the root. Exported for runtime builtins like in-ns.
func (*ExecContext) SetScope ¶ added in v1.11.0
func (ec *ExecContext) SetScope(s *Scope)
SetScope installs s as this context's scope. Used by with-scope to open a child scope for a dynamic extent and to restore the previous one on close.
type ExecutionError ¶
type ExecutionError struct {
// contains filtered or unexported fields
}
func NewExecutionError ¶
func NewExecutionError(m string) *ExecutionError
func (*ExecutionError) Error ¶
func (ve *ExecutionError) Error() string
func (*ExecutionError) GetCause ¶
func (ve *ExecutionError) GetCause() error
func (*ExecutionError) WithSource ¶
func (ve *ExecutionError) WithSource(info *SourceInfo) *ExecutionError
type Frame ¶
type Frame struct {
// contains filtered or unexported fields
}
Frame is a single interpreter context
func NewDebugFrame ¶
func (*Frame) RunProtected ¶
RunProtected runs the frame with panic recovery for thrownPanic. Use at top-level entry points (REPL, file eval). Internal calls use Run() directly.
type Func ¶
type Func struct {
// contains filtered or unexported fields
}
func (*Func) IsVariadic ¶ added in v1.3.0
IsVariadic returns whether the function is variadic.
func (*Func) MakeClosure ¶
type FuncInterface ¶
type FuncInterface func(any)
type GoPanicError ¶ added in v1.9.0
type GoPanicError struct {
// contains filtered or unexported fields
}
GoPanicError wraps an unexpected Go panic (one that is NOT a let-go thrown error) together with the Go stack captured at the recover site. Native-fn crashes — e.g. a `syscall/js: Value.Int on undefined` under WASM, or a nil dereference in a Go builtin — have no let-go source location, so without this the only traceback was an unhelpful `at <fn> (<unknown>)`. The captured Go stack pins the actual crash site (the .go file:line) and FormatError surfaces the let-go-relevant frames.
func (*GoPanicError) Error ¶ added in v1.9.0
func (e *GoPanicError) Error() string
func (*GoPanicError) GoStack ¶ added in v1.9.0
func (e *GoPanicError) GoStack() string
GoStack returns the raw Go stack trace captured when the panic was recovered.
type Hashable ¶
type Hashable interface {
Hash() uint32
}
Hashable is implemented by types that cache their hash for fast map lookups.
type IChunk ¶ added in v1.9.0
IChunk is a fixed-size, indexable, sliceable batch of Values. Implementations may share backing storage; DropFirst must never mutate.
Note: the per-chunk size is exposed as ChunkCount() rather than Count() because concrete chunks (ArrayChunk, ChunkBuffer) also satisfy the Counted protocol — which requires Count() Value and RawCount() int — and Go interfaces cannot disambiguate two methods with the same name and different return types.
type IChunkedSeq ¶ added in v1.9.0
type IChunkedSeq interface {
Seq
ChunkedFirst() IChunk
ChunkedNext() Seq // nil at end
ChunkedMore() Seq // EmptyList at end
}
IChunkedSeq is a Seq that can yield a whole chunk at a time. Consumers may dispatch on this interface to amortize per-element overhead; the Seq methods (First/Next/More) must remain consistent with the chunked view: First() == ChunkedFirst().Nth(0), Next() walks within the chunk before moving to ChunkedNext().
func AsChunkedSeq ¶ added in v1.9.0
func AsChunkedSeq(s Seq) (IChunkedSeq, bool)
AsChunkedSeq returns the chunked view of s if available, resolving through LazySeq wrappers. Returns (cs, true) if s ultimately resolves to a non-empty IChunkedSeq, (nil, false) otherwise (including for empty seqs).
Callers use this to choose a chunked fast path:
if cs, ok := AsChunkedSeq(s); ok {
// process cs.ChunkedFirst() in bulk, recurse on cs.ChunkedMore()
}
// fallback: one-at-a-time
type IMeta ¶
type IMeta interface {
Meta() Value // returns the metadata map, or NIL
WithMeta(Value) Value // returns a copy of this value with the given metadata
}
IMeta is implemented by values that support metadata.
type Indexed ¶ added in v1.11.0
Indexed marks positional collections — those whose elements are addressed by a 0-based integer index, as opposed to maps/sets (key-addressable) and lazy seqs (sequential-only). `nth` dispatches on this to use an O(1)-ish indexed access without seq traversal. Implementations must satisfy: Nth(i) is valid for 0 <= i < RawCount(); callers bounds-check via RawCount() before calling.
Crucially this excludes maps/sets (which are Lookup+Counted but NOT positional) and transient/chunk types that aren't seqable — so adding a new positional type is a matter of implementing this interface, not editing a type switch.
type InfiniteRange ¶ added in v1.2.0
type InfiniteRange struct {
// contains filtered or unexported fields
}
InfiniteRange is a lazy infinite integer sequence.
func NewInfiniteRange ¶ added in v1.2.0
func NewInfiniteRange(start, step int) *InfiniteRange
func (*InfiniteRange) ChunkedFirst ¶ added in v1.9.0
func (r *InfiniteRange) ChunkedFirst() IChunk
InfiniteRange's chunked view emits a full rangeChunkSize chunk every time and never returns nil from ChunkedNext/More — consumers must short-circuit.
func (*InfiniteRange) ChunkedMore ¶ added in v1.9.0
func (r *InfiniteRange) ChunkedMore() Seq
func (*InfiniteRange) ChunkedNext ¶ added in v1.9.0
func (r *InfiniteRange) ChunkedNext() Seq
func (*InfiniteRange) Cons ¶ added in v1.2.0
func (r *InfiniteRange) Cons(val Value) Seq
func (*InfiniteRange) First ¶ added in v1.2.0
func (r *InfiniteRange) First() Value
func (*InfiniteRange) More ¶ added in v1.2.0
func (r *InfiniteRange) More() Seq
func (*InfiniteRange) Next ¶ added in v1.2.0
func (r *InfiniteRange) Next() Seq
func (*InfiniteRange) Seq ¶ added in v1.2.0
func (r *InfiniteRange) Seq() Seq
func (*InfiniteRange) String ¶ added in v1.2.0
func (r *InfiniteRange) String() string
func (*InfiniteRange) Type ¶ added in v1.2.0
func (r *InfiniteRange) Type() ValueType
func (*InfiniteRange) Unbox ¶ added in v1.2.0
func (r *InfiniteRange) Unbox() any
type Instant ¶ added in v1.8.0
type Instant struct {
// contains filtered or unexported fields
}
Instant wraps a time.Time, normalised to UTC at millisecond precision.
Precision is millisecond to match Clojure JVM (java.util.Date) and ClojureScript (js/Date), so values round-trip cleanly through any Clojure tool reading the same RFC3339 string.
func NewInstant ¶ added in v1.8.0
NewInstant constructs an Instant from a time.Time, normalising to UTC at millisecond precision.
The caller is responsible for ensuring the year is in 0..9999 — values outside that range will not round-trip through Val()/ParseInstant and will silently break AOT bytecode serialisation. The only value-system entry point that takes a host time.Time is InstantType.Box, which enforces this bound; direct Go callers must do the same.
func ParseInstant ¶ added in v1.8.0
ParseInstant parses an RFC3339 (or RFC3339Nano) timestamp. Returns nil if invalid. Sub-millisecond precision in the input is truncated.
func (*Instant) Equals ¶ added in v1.8.0
Equals compares by epoch milliseconds. After UTC+millis normalisation in the constructors this matches t.Equal, but expressing it directly in terms of UnixMilli decouples value identity from time.Time internals (e.g. any monotonic clock reading).
func (*Instant) Hash ¶ added in v1.8.0
Hash implements Hashable. Grounded in epoch milliseconds (the actual value) rather than the formatted string so hash identity is independent of presentation choices (RFC3339Nano trims trailing zeros, etc.).
type Iterate ¶
type Iterate struct {
// contains filtered or unexported fields
}
Iterate is a Value whose only value is Iterate
func NewIterate ¶
type LazySeq ¶
type LazySeq struct {
// contains filtered or unexported fields
}
LazySeq delays computation of a sequence until first/next is called. This is the foundation for lazy operations like map, filter, etc.
func NewLazySeq ¶
func (*LazySeq) Conj ¶
func (l *LazySeq) Conj(val Value) Collection
func (*LazySeq) Empty ¶
func (l *LazySeq) Empty() Collection
func (*LazySeq) Hash ¶ added in v1.8.0
Hash implements Hashable. Resolves the lazy chain and hashes as an ordered collection, matching *List/*Cons so the three sequence representations equate in sets/maps. An empty resolution (Go nil from a (lazy-seq nil)) must hash the same as EmptyList — Resolve() returns nil but EmptyList.Hash iterates once over its sentinel element, so we substitute EmptyList here.
func (*LazySeq) IsRealized ¶ added in v1.8.0
type List ¶
type List struct {
// contains filtered or unexported fields
}
List is boxed singly linked list that can hold other Values.
func (*List) Conj ¶
func (l *List) Conj(value Value) Collection
type LocalVar ¶ added in v1.10.0
CodeChunk holds bytecode and provides facilities for reading and writing it LocalVar is a debug-info entry mapping a stack slot to the original source name of a local binding (let/loop binding, fn parameter, catch binding). Carried so crash traces from bundle-loaded code (e.g. under WASM) can name local variables, not just slots.
type Map ¶
Map is boxed singly linked list that can hold other Values.
func (Map) Conj ¶
func (l Map) Conj(value Value) Collection
func (Map) Dissoc ¶
func (l Map) Dissoc(k Value) Associative
type MapEntry ¶
MapEntry is a key-value pair.
func (MapEntry) Conj ¶ added in v1.6.0
func (e MapEntry) Conj(v Value) Collection
func (MapEntry) Empty ¶ added in v1.6.0
func (e MapEntry) Empty() Collection
type MapSeq ¶
type MapSeq struct {
// contains filtered or unexported fields
}
MapSeq is a lightweight seq view over a Map's entries
func (*MapSeq) Conj ¶
func (s *MapSeq) Conj(val Value) Collection
func (*MapSeq) Empty ¶
func (s *MapSeq) Empty() Collection
type MultiArityFn ¶
type MultiArityFn struct {
// contains filtered or unexported fields
}
func MakeMultiArity ¶ added in v1.9.0
func MakeMultiArity(fns []Value) (*MultiArityFn, error)
func (*MultiArityFn) Arity ¶
func (l *MultiArityFn) Arity() int
func (*MultiArityFn) MakeClosure ¶ added in v1.9.0
func (l *MultiArityFn) MakeClosure() Fn
func (*MultiArityFn) String ¶
func (l *MultiArityFn) String() string
func (*MultiArityFn) Type ¶
func (l *MultiArityFn) Type() ValueType
type MultiFn ¶
type MultiFn struct {
// contains filtered or unexported fields
}
MultiFn implements Clojure-style multimethods. It holds a dispatch function and a map of dispatch-value → method.
func (*MultiFn) FreezeNative ¶ added in v1.11.0
func (m *MultiFn) FreezeNative()
FreezeNative marks this MultiFn as the captured baseline for generated native dispatch arms. Done once, in place, at namespace-load completion (rt.ApplyGoOverrides) — the var still points at this exact pointer, and any later AddMethod/RemoveMethod yields a fresh, unfrozen MultiFn.
func (*MultiFn) IsNativeFrozen ¶ added in v1.11.0
IsNativeFrozen reports whether this MultiFn is still the native baseline (no defmethod has replaced it since FreezeNative). The generated type-switch only trusts its baked arms while this holds.
func (*MultiFn) Methods ¶
func (m *MultiFn) Methods() *PersistentMap
Methods returns the method map.
func (*MultiFn) RemoveMethod ¶
RemoveMethod unregisters an implementation.
type Namespace ¶
type Namespace struct {
// contains filtered or unexported fields
}
func NewNamespace ¶
func (*Namespace) Alias ¶
Alias creates a symbol alias to another namespace in this namespace.
Collision guard: re-pointing an existing alias at a DIFFERENT namespace is almost always a bug — either two `:as` clauses in one ns picking the same short name for different libs, or (historically) cross-namespace alias-table contamination during dependency loading. Rather than letting the last writer silently win, warn so the conflict is visible. Re-aliasing to the SAME target (idempotent ns reload) and first-time aliasing are silent.
func (*Namespace) DefStub ¶ added in v1.8.0
DefStub interns an UNBOUND var (no root) without triggering the warn-on-shadow check. Intended for bundle decoders that pre-populate var references before the namespace's own chunk runs (which Defs the ones that have an init). Leaving the root unset is load-bearing: a no-init (def x) / (declare x) emits only OP_LOAD_CONST, so the stub is the var that survives into the namespace, and it must report (bound? (var x)) == false to match the source-compiled path (LookupOrAdd). A NIL root would make precompiled / LGB-loaded code wrongly appear bound, breaking def/declare promise semantics. Do NOT use DefStub to intentionally suppress warnings for new code; use Namespace.Exclude (via :refer-clojure :exclude) instead.
func (*Namespace) Exclude ¶ added in v1.8.0
Exclude marks a symbol as excluded from clojure.core auto-refer. Called from the ns macro for :refer-clojure :exclude [...].
func (*Namespace) ImportVar ¶
ImportVar links a var from another namespace into this namespace under the given alias. Returns true when the var exists and is not private.
func (*Namespace) IsExcluded ¶ added in v1.8.0
IsExcluded reports whether the symbol is in the exclude set.
func (*Namespace) LookupLocal ¶ added in v1.3.0
LookupLocal checks only the namespace's own registry, not refers or aliases.
func (*Namespace) LookupOrAdd ¶
func (*Namespace) ReferList ¶
ReferList refers only selected symbols from the given namespace into this namespace.
func (*Namespace) RegistrySize ¶
func (*Namespace) ResolveAlias ¶
ResolveAlias returns the namespace for the given alias, or nil.
type NativeFn ¶
type NativeFn struct {
// contains filtered or unexported fields
}
func NewCtxNativeFn ¶ added in v1.11.0
NewCtxNativeFn builds a context-aware native builtin. Its plain Invoke resolves against the root context (host/reflection callers); ec.Invoke routes the real context in.
type Nil ¶
type Nil struct{}
Nil is a Value whose only value is Nil
func (*Nil) Conj ¶
func (n *Nil) Conj(value Value) Collection
func (*Nil) Dissoc ¶
func (n *Nil) Dissoc(k Value) Associative
func (*Nil) Empty ¶
func (n *Nil) Empty() Collection
type PairSample ¶ added in v1.9.0
PairSample is one entry in a pair-count snapshot.
func PairSnapshot ¶ added in v1.9.0
func PairSnapshot() []PairSample
PairSnapshot returns the current per-pair counts, sorted desc. Only entries with non-zero counts are returned.
type PersistentMap ¶
type PersistentMap struct {
// contains filtered or unexported fields
}
PersistentMap is an immutable hash-array mapped trie (HAMT).
func MapFromGoMap ¶
func MapFromGoMap(m map[Value]Value) *PersistentMap
MapFromGoMap converts a Go map[Value]Value to a *PersistentMap.
func NewArrayMap ¶ added in v1.8.0
func NewArrayMap(kvs []Value) *PersistentMap
NewArrayMap creates a PersistentMap that preserves insertion order for seq.
func NewPersistentMap ¶
func NewPersistentMap(kvs []Value) *PersistentMap
NewPersistentMap creates a PersistentMap from an alternating key-value slice.
func (*PersistentMap) Arity ¶
func (m *PersistentMap) Arity() int
func (*PersistentMap) Assoc ¶
func (m *PersistentMap) Assoc(key Value, val Value) Associative
func (*PersistentMap) Conj ¶
func (m *PersistentMap) Conj(value Value) Collection
func (*PersistentMap) Contains ¶
func (m *PersistentMap) Contains(key Value) Boolean
func (*PersistentMap) Count ¶
func (m *PersistentMap) Count() Value
func (*PersistentMap) Dissoc ¶
func (m *PersistentMap) Dissoc(key Value) Associative
func (*PersistentMap) Empty ¶
func (m *PersistentMap) Empty() Collection
func (*PersistentMap) Equals ¶
func (m *PersistentMap) Equals(other Value) bool
func (*PersistentMap) Hash ¶
func (m *PersistentMap) Hash() uint32
Hash implements Hashable. Cached after first computation. Uses unordered hashing (order-independent) since maps are unordered.
func (*PersistentMap) RawCount ¶
func (m *PersistentMap) RawCount() int
func (*PersistentMap) Seq ¶
func (m *PersistentMap) Seq() Seq
func (*PersistentMap) String ¶
func (m *PersistentMap) String() string
func (*PersistentMap) Type ¶
func (m *PersistentMap) Type() ValueType
func (*PersistentMap) Unbox ¶
func (m *PersistentMap) Unbox() any
func (*PersistentMap) ValueAt ¶
func (m *PersistentMap) ValueAt(key Value) Value
func (*PersistentMap) WithMeta ¶
func (m *PersistentMap) WithMeta(meta Value) Value
WithMeta implements IMeta.
type PersistentSet ¶
type PersistentSet struct {
// contains filtered or unexported fields
}
PersistentSet is an immutable set backed by a PersistentMap. Each element is stored as a key mapping to itself (like Clojure's PersistentHashSet).
func NewPersistentSet ¶
func NewPersistentSet(vals []Value) *PersistentSet
func (*PersistentSet) Arity ¶
func (s *PersistentSet) Arity() int
func (*PersistentSet) Conj ¶
func (s *PersistentSet) Conj(value Value) Collection
func (*PersistentSet) Cons ¶
func (s *PersistentSet) Cons(val Value) Seq
func (*PersistentSet) Contains ¶
func (s *PersistentSet) Contains(value Value) Boolean
func (*PersistentSet) Count ¶
func (s *PersistentSet) Count() Value
func (*PersistentSet) Disj ¶
func (s *PersistentSet) Disj(value Value) *PersistentSet
func (*PersistentSet) Empty ¶
func (s *PersistentSet) Empty() Collection
func (*PersistentSet) First ¶
func (s *PersistentSet) First() Value
func (*PersistentSet) Hash ¶
func (s *PersistentSet) Hash() uint32
func (*PersistentSet) Meta ¶
func (s *PersistentSet) Meta() Value
func (*PersistentSet) More ¶
func (s *PersistentSet) More() Seq
func (*PersistentSet) Next ¶
func (s *PersistentSet) Next() Seq
func (*PersistentSet) RawCount ¶
func (s *PersistentSet) RawCount() int
func (*PersistentSet) Seq ¶
func (s *PersistentSet) Seq() Seq
func (*PersistentSet) String ¶
func (s *PersistentSet) String() string
func (*PersistentSet) Type ¶
func (s *PersistentSet) Type() ValueType
func (*PersistentSet) Unbox ¶
func (s *PersistentSet) Unbox() any
func (*PersistentSet) ValueAt ¶ added in v1.5.0
func (s *PersistentSet) ValueAt(key Value) Value
func (*PersistentSet) ValueAtOr ¶ added in v1.5.0
func (s *PersistentSet) ValueAtOr(key Value, dflt Value) Value
func (*PersistentSet) WithMeta ¶
func (s *PersistentSet) WithMeta(m Value) Value
type PersistentVector ¶
type PersistentVector struct {
// contains filtered or unexported fields
}
PersistentVector is a persistent vector implementation using a bit-partitioned trie
func (PersistentVector) Assoc ¶
func (v PersistentVector) Assoc(key Value, val Value) Associative
Assoc implements Associative
func (PersistentVector) Conj ¶
func (v PersistentVector) Conj(val Value) Collection
Conj implements Collection
func (PersistentVector) Contains ¶
func (v PersistentVector) Contains(key Value) Boolean
Contains implements Associative
func (PersistentVector) Dissoc ¶
func (v PersistentVector) Dissoc(key Value) Associative
Dissoc implements Associative
func (PersistentVector) Empty ¶
func (v PersistentVector) Empty() Collection
Empty implements Collection
func (PersistentVector) Equals ¶
func (v PersistentVector) Equals(other Value) bool
Equals implements value equality for PersistentVector
func (PersistentVector) Hash ¶
func (v PersistentVector) Hash() uint32
Hash implements Hashable. Computed from elements.
func (PersistentVector) Invoke ¶
func (v PersistentVector) Invoke(args []Value) (Value, error)
Invoke implements IFn
func (PersistentVector) Nth ¶ added in v1.11.0
func (v PersistentVector) Nth(i int) Value
Nth implements Indexed: positional access by integer index.
func (PersistentVector) Pop ¶ added in v1.11.0
func (v PersistentVector) Pop() PersistentVector
Pop returns a new vector with the last element removed, in O(1) amortized time (mirrors Clojure's PersistentVector.pop). The previous behavior — the `pop` builtin doing Unbox()+NewPersistentVector(all-but-last) — was O(n) per call, which made vector-as-stack uses (e.g. the typeinfer worklist drain via peek/pop) O(n^2) and a major allocation source. Returns the empty vector for count <= 1; callers that must reject popping an empty vector check count first.
func (PersistentVector) RawCount ¶
func (v PersistentVector) RawCount() int
func (PersistentVector) Seq ¶
func (v PersistentVector) Seq() Seq
Modify PersistentVector's Seq method:
func (PersistentVector) ValueAt ¶
func (v PersistentVector) ValueAt(key Value) Value
ValueAt implements Associative
func (PersistentVector) ValueAtOr ¶
func (v PersistentVector) ValueAtOr(key Value, dflt Value) Value
ValueAtOr implements Associative
func (PersistentVector) WithMeta ¶
func (v PersistentVector) WithMeta(m Value) Value
WithMeta implements IMeta.
type PersistentVectorSeq ¶
type PersistentVectorSeq struct {
// contains filtered or unexported fields
}
PersistentVectorSeq represents a sequence view of a PersistentVector
func (*PersistentVectorSeq) ChunkedFirst ¶ added in v1.9.0
func (s *PersistentVectorSeq) ChunkedFirst() IChunk
ChunkedFirst returns the chunk starting at the current position.
func (*PersistentVectorSeq) ChunkedMore ¶ added in v1.9.0
func (s *PersistentVectorSeq) ChunkedMore() Seq
ChunkedMore is like ChunkedNext but returns EmptyList instead of nil at the end, matching Clojure's IChunkedSeq.chunkedMore.
func (*PersistentVectorSeq) ChunkedNext ¶ added in v1.9.0
func (s *PersistentVectorSeq) ChunkedNext() Seq
ChunkedNext advances by one whole chunk, returning the seq positioned at the start of the following chunk, or nil at the end.
func (*PersistentVectorSeq) Conj ¶
func (s *PersistentVectorSeq) Conj(val Value) Collection
Conj implements Collection
func (*PersistentVectorSeq) Cons ¶
func (s *PersistentVectorSeq) Cons(val Value) Seq
Cons implements Seq
func (*PersistentVectorSeq) Count ¶
func (s *PersistentVectorSeq) Count() Value
Count implements Collection
func (*PersistentVectorSeq) Empty ¶
func (s *PersistentVectorSeq) Empty() Collection
Empty implements Collection
func (*PersistentVectorSeq) First ¶
func (s *PersistentVectorSeq) First() Value
First implements Seq
func (*PersistentVectorSeq) Nth ¶ added in v1.11.0
func (s *PersistentVectorSeq) Nth(i int) Value
Nth implements Indexed: positional access by integer index.
func (*PersistentVectorSeq) RawCount ¶
func (s *PersistentVectorSeq) RawCount() int
func (*PersistentVectorSeq) String ¶
func (s *PersistentVectorSeq) String() string
String implements Value
func (*PersistentVectorSeq) Type ¶
func (s *PersistentVectorSeq) Type() ValueType
Type implements Value
func (*PersistentVectorSeq) Unbox ¶
func (s *PersistentVectorSeq) Unbox() any
Unbox implements Value
func (*PersistentVectorSeq) ValueAt ¶
func (s *PersistentVectorSeq) ValueAt(key Value) Value
ValueAt implements Lookup for PersistentVectorSeq so that `get` works on seq views.
type ProfileSample ¶ added in v1.9.0
ProfileSample is one entry in a profile snapshot.
func ProfileSnapshot ¶ added in v1.9.0
func ProfileSnapshot() []ProfileSample
ProfileSnapshot returns the current per-opcode counts, sorted desc. Only entries with non-zero counts are returned.
type Promise ¶
type Promise struct {
// contains filtered or unexported fields
}
Promise is a write-once, read-many synchronization primitive. Created with (promise), written with (deliver p val), read with (deref p). Deref blocks until delivered.
func NewPromise ¶
func NewPromise() *Promise
func (*Promise) DerefTimeout ¶ added in v1.10.0
DerefTimeout blocks until the promise is delivered or timeoutMs elapses, returning timeoutVal on timeout. Backs Clojure's 3-arg deref for blocking refs (promises/futures).
func (*Promise) IsRealized ¶
type Protocol ¶
type Protocol struct {
// contains filtered or unexported fields
}
Protocol defines a named set of methods with type-based dispatch.
func NewProtocol ¶
func (*Protocol) Extend ¶
func (p *Protocol) Extend(vt ValueType, implMap *PersistentMap)
Extend adds implementations for a type. implMap is a PersistentMap of {method-keyword → fn}.
func (*Protocol) ExtendNil ¶
func (p *Protocol) ExtendNil(implMap *PersistentMap)
ExtendNil adds implementations for nil.
type ProtocolFn ¶
type ProtocolFn struct {
// contains filtered or unexported fields
}
ProtocolFn is a function that dispatches on the first arg's type via a protocol.
func NewProtocolFn ¶
func NewProtocolFn(protocol *Protocol, methodName Symbol) *ProtocolFn
func (*ProtocolFn) Arity ¶
func (f *ProtocolFn) Arity() int
func (*ProtocolFn) String ¶
func (f *ProtocolFn) String() string
func (*ProtocolFn) Type ¶
func (f *ProtocolFn) Type() ValueType
func (*ProtocolFn) Unbox ¶
func (f *ProtocolFn) Unbox() any
type Range ¶
type Range struct {
// contains filtered or unexported fields
}
Range is a lazy integer sequence with start, end, and step.
func (*Range) ChunkedFirst ¶ added in v1.9.0
ChunkedFirst returns up to rangeChunkSize values starting from l.start, stopping at the range's end. The chunk holds materialized Int values; this is one O(chunkSize) allocation per chunk in exchange for amortizing the element-wise allocation overhead of l.Next().
func (*Range) ChunkedMore ¶ added in v1.9.0
func (*Range) ChunkedNext ¶ added in v1.9.0
ChunkedNext returns the range positioned at the element after the current chunk, or nil if the current chunk consumes the whole range.
func (*Range) Conj ¶
func (l *Range) Conj(val Value) Collection
type Ratio ¶ added in v1.5.0
type Ratio struct {
// contains filtered or unexported fields
}
Ratio wraps *math/big.Rat as a VM value.
func MustRatioFromString ¶ added in v1.11.0
MustRatioFromString builds a Ratio from its "num/den" string form, panicking on an unparseable input. Intended for gogen-emitted constant literals: the source was already validated at read time (and reduced past integer form, so the value is genuinely a Ratio), making the panic unreachable in generated code. Gives a single-value expression form keyed off the value's own String().
func NewRatioFromInts ¶ added in v1.5.0
type Record ¶
type Record struct {
// contains filtered or unexported fields
}
Record is a value created by defrecord. Fixed fields are stored in a flat array for O(1) access. Extra keys (from assoc) go into an overflow map. All map operations work — seq, keys, count include both fixed and extra fields.
func NewRecord ¶
func NewRecord(rtype *RecordType, data *PersistentMap) *Record
func ToRecord ¶
ToRecord converts a Go struct to a Record using its registered mapping. Panics if the struct type is not registered.
func (*Record) Conj ¶
func (r *Record) Conj(value Value) Collection
func (*Record) Dissoc ¶
func (r *Record) Dissoc(key Value) Associative
func (*Record) Empty ¶
func (r *Record) Empty() Collection
func (*Record) Extra ¶ added in v1.3.0
func (r *Record) Extra() *PersistentMap
Extra returns the overflow map.
func (*Record) FixedFields ¶ added in v1.3.0
FixedFields returns the fixed field values.
func (*Record) InvokeMethod ¶
func (*Record) Origin ¶
Origin returns the original Go struct if this Record was created from one, or nil.
func (*Record) RecordType ¶
func (r *Record) RecordType() *RecordType
type RecordBase ¶ added in v1.11.0
type RecordBase struct {
TypeName string
// contains filtered or unexported fields
}
RecordBase is embedded by gogen-generated record/op structs so they satisfy vm.Value without per-type boilerplate. Field-specific behavior (field access, equality over fields) is added by the generated struct; this covers the type-identity and stringification contract.
Usage in generated code:
type MyRecord struct {
RecordBase
fieldOne Value
fieldTwo Value
}
The embedding struct automatically satisfies the Value interface.
func (*RecordBase) String ¶ added in v1.11.0
func (r *RecordBase) String() string
String returns the TypeName. Required by fmt.Stringer (part of Value interface).
func (*RecordBase) Type ¶ added in v1.11.0
func (r *RecordBase) Type() ValueType
Type returns a ValueType representing this record's type. The ValueType is lazily created and cached.
func (*RecordBase) Unbox ¶ added in v1.11.0
func (r *RecordBase) Unbox() any
Unbox returns the embedded *RecordBase, NOT the outer embedding struct. Because Unbox is a method on RecordBase promoted onto the embedding type, its receiver is always *RecordBase — Go method promotion cannot recover the outer value. Callers that need the concrete record (e.g. *Square) must hold a typed reference; they cannot recover it through this Value-level Unbox. This is sufficient for the type-identity/stringification contract RecordBase covers; field access on native records goes through the generated struct directly.
type RecordType ¶
type RecordType struct {
// contains filtered or unexported fields
}
RecordType is a dynamically-created ValueType for a defrecord. Each defrecord call creates a unique RecordType instance.
func NewRecordType ¶
func NewRecordType(name string, fields []Keyword) *RecordType
func (*RecordType) Fields ¶
func (t *RecordType) Fields() []Keyword
func (*RecordType) Name ¶
func (t *RecordType) Name() string
func (*RecordType) String ¶
func (t *RecordType) String() string
func (*RecordType) Type ¶
func (t *RecordType) Type() ValueType
func (*RecordType) TypeName ¶ added in v1.3.0
func (t *RecordType) TypeName() string
TypeName returns the record type name.
func (*RecordType) Unbox ¶
func (t *RecordType) Unbox() any
type Reduced ¶
type Reduced struct {
// contains filtered or unexported fields
}
Reduced wraps a value to signal early termination in reduce/transduce.
func NewReduced ¶
type Refer ¶
type Refer struct {
// contains filtered or unexported fields
}
Refer entries are immutable once constructed and inserted, so their fields (ns, all, only) may be read without holding the owning namespace's lock — only the refers MAP itself is mutex-guarded.
type Regex ¶
type Regex struct {
// contains filtered or unexported fields
}
Regex is boxed int
func (*Regex) FindAllStringSubmatch ¶
func (*Regex) FindStringSubmatch ¶
func (*Regex) ReplaceAllFunc ¶ added in v1.11.0
func (l *Regex) ReplaceAllFunc(s string, f func(groups []string, present []bool) (string, error)) (string, error)
ReplaceAllFunc replaces every non-overlapping match using f, matching clojure.string/replace with a function replacement. For each match, f receives the submatch groups: groups[0] is the whole match, groups[i] the i-th capture group; present[i] is false for a group that did not participate (so the caller can pass nil, as Clojure's re-groups does).
func (*Regex) ReplaceFirst ¶ added in v1.10.0
ReplaceFirst replaces only the first match, expanding $-group references in the replacement (as ReplaceAll does), matching clojure.string/replace-first.
type Repeat ¶
type Repeat struct {
// contains filtered or unexported fields
}
Repeat is a Value whose only value is Repeat
type Scope ¶ added in v1.9.0
type Scope struct {
// contains filtered or unexported fields
}
func OpenChildEC ¶ added in v1.11.0
func OpenChildEC(ec *ExecContext) *Scope
OpenChildEC opens a child of ec's current scope and installs it on ec for a synchronous dynamic extent (the with-scope body, which runs in the same frame, hence the same ec). It returns the child; pair with CloseScoped, which runs the restore that reinstates the previous scope. This is the explicit-context replacement for the old goroutine-id-keyed OpenChild.
func (*Scope) Await ¶ added in v1.9.0
Await blocks until every goroutine in this scope AND its subtree has exited, or timeout elapses. Returns true if fully drained, false on timeout. A non-positive timeout waits indefinitely.
func (*Scope) Cancel ¶ added in v1.9.0
func (s *Scope) Cancel()
Cancel cancels this scope's context — and, by context inheritance, its whole subtree — without installing a fresh one. Terminal: the scope stops accepting new cancellable work. Siblings are unaffected. Does not wait; pair with Await (or use Shutdown).
func (*Scope) CancelAll ¶ added in v1.9.0
func (s *Scope) CancelAll()
CancelAll cancels the current context generation and installs a fresh one derived from the parent, so the scope can keep accepting spawns after a drain. This is the "drain and continue" form used by the root between benchmark iterations / at soft shutdown points. Lock-free: the fresh generation is swapped in atomically and we cancel whatever we displaced, so concurrent CancelAlls are safe.
func (*Scope) Child ¶ added in v1.9.0
Child creates a sub-scope whose context is derived from this scope's current context. Cancelling this scope (or any ancestor) cancels the child; cancelling the child leaves this scope and its siblings running.
func (*Scope) Context ¶ added in v1.9.0
Context returns the scope's current cancellation context. Blocking native ops (sleep, channel send/recv, alts!) select on its Done() so they unblock when the scope is cancelled. Lock-free (one atomic load), cheap to call on every channel op.
func (*Scope) Drain ¶ added in v1.9.0
Drain cancels the scope's current generation and reinstalls a fresh one (so the scope keeps working), then waits for the displaced work to exit. Used by the root between bench iterations and at soft shutdown.
func (*Scope) Go ¶ added in v1.9.0
Go runs fn in a tracked goroutine of THIS scope. fn receives the scope's current context; long-running work should select on ctx.Done() so Cancel/Shutdown/Drain can stop it.
func (*Scope) Live ¶ added in v1.9.0
Live reports how many goroutines are running directly in this scope (not counting sub-scopes). Use LiveTree for the whole subtree.
func (*Scope) LiveTree ¶ added in v1.9.0
LiveTree reports the live goroutine count of this scope and all descendants.
func (*Scope) Shutdown ¶ added in v1.9.0
Shutdown cancels this scope (terminal, cascades to the subtree) and waits up to timeout for it to drain. The structured-shutdown form for a sub-scope; for the root's drain-and-continue use Drain.
type Set ¶
type Set map[Value]struct{}
Set is boxed singly linked list that can hold other Values.
func (Set) Conj ¶
func (l Set) Conj(value Value) Collection
type SetSeq ¶
type SetSeq struct {
// contains filtered or unexported fields
}
SetSeq is a lightweight seq view over a Set's keys
func (*SetSeq) Conj ¶
func (s *SetSeq) Conj(val Value) Collection
func (*SetSeq) Empty ¶
func (s *SetSeq) Empty() Collection
type SetWithMeta ¶
type SetWithMeta struct {
Set
// contains filtered or unexported fields
}
SetWithMeta wraps a Set to carry metadata.
func (*SetWithMeta) Conj ¶ added in v1.8.0
func (s *SetWithMeta) Conj(value Value) Collection
func (*SetWithMeta) Meta ¶
func (s *SetWithMeta) Meta() Value
func (*SetWithMeta) WithMeta ¶
func (s *SetWithMeta) WithMeta(m Value) Value
type SortedMap ¶ added in v1.5.0
type SortedMap struct {
// contains filtered or unexported fields
}
func NewSortedMap ¶ added in v1.5.0
func NewSortedMap(cmp Comparator, kvs []Value) *SortedMap
func (*SortedMap) Assoc ¶ added in v1.5.0
func (m *SortedMap) Assoc(key, val Value) Associative
func (*SortedMap) Conj ¶ added in v1.5.0
func (m *SortedMap) Conj(value Value) Collection
func (*SortedMap) Dissoc ¶ added in v1.5.0
func (m *SortedMap) Dissoc(key Value) Associative
func (*SortedMap) Empty ¶ added in v1.5.0
func (m *SortedMap) Empty() Collection
type SortedMapSeq ¶ added in v1.5.0
type SortedMapSeq struct {
// contains filtered or unexported fields
}
SortedMapSeq implements Seq over sorted map entries.
func (*SortedMapSeq) Cons ¶ added in v1.5.0
func (s *SortedMapSeq) Cons(val Value) Seq
func (*SortedMapSeq) Count ¶ added in v1.5.0
func (s *SortedMapSeq) Count() Value
func (*SortedMapSeq) First ¶ added in v1.5.0
func (s *SortedMapSeq) First() Value
func (*SortedMapSeq) More ¶ added in v1.5.0
func (s *SortedMapSeq) More() Seq
func (*SortedMapSeq) Next ¶ added in v1.5.0
func (s *SortedMapSeq) Next() Seq
func (*SortedMapSeq) RawCount ¶ added in v1.5.0
func (s *SortedMapSeq) RawCount() int
func (*SortedMapSeq) String ¶ added in v1.5.0
func (s *SortedMapSeq) String() string
func (*SortedMapSeq) Type ¶ added in v1.5.0
func (s *SortedMapSeq) Type() ValueType
func (*SortedMapSeq) Unbox ¶ added in v1.5.0
func (s *SortedMapSeq) Unbox() any
type SortedSet ¶ added in v1.5.0
type SortedSet struct {
// contains filtered or unexported fields
}
func NewSortedSet ¶ added in v1.5.0
func NewSortedSet(cmp Comparator, vals []Value) *SortedSet
func (*SortedSet) Conj ¶ added in v1.5.0
func (s *SortedSet) Conj(value Value) Collection
func (*SortedSet) Empty ¶ added in v1.5.0
func (s *SortedSet) Empty() Collection
type SortedSetSeq ¶ added in v1.5.0
type SortedSetSeq struct {
// contains filtered or unexported fields
}
func (*SortedSetSeq) Cons ¶ added in v1.5.0
func (s *SortedSetSeq) Cons(val Value) Seq
func (*SortedSetSeq) Count ¶ added in v1.5.0
func (s *SortedSetSeq) Count() Value
func (*SortedSetSeq) First ¶ added in v1.5.0
func (s *SortedSetSeq) First() Value
func (*SortedSetSeq) More ¶ added in v1.5.0
func (s *SortedSetSeq) More() Seq
func (*SortedSetSeq) Next ¶ added in v1.5.0
func (s *SortedSetSeq) Next() Seq
func (*SortedSetSeq) RawCount ¶ added in v1.5.0
func (s *SortedSetSeq) RawCount() int
func (*SortedSetSeq) String ¶ added in v1.5.0
func (s *SortedSetSeq) String() string
func (*SortedSetSeq) Type ¶ added in v1.5.0
func (s *SortedSetSeq) Type() ValueType
func (*SortedSetSeq) Unbox ¶ added in v1.5.0
func (s *SortedSetSeq) Unbox() any
type SourceInfo ¶
type SourceInfo struct {
File string
Line int // 0-based
Column int // 0-based
EndLine int
EndColumn int
Symbol string
}
SourceInfo tracks the source location of a form.
Symbol is an optional user-visible name for the value the form binds (e.g. a let-binding or parameter name). It is empty for SourceInfos attached purely for line/column tracking, and populated by the IR builder when a value flows through a `bind-local!` site so downstream passes (notably lower-go) can emit human-readable identifiers.
func (*SourceInfo) String ¶
func (s *SourceInfo) String() string
type SourceMap ¶
type SourceMap struct {
// contains filtered or unexported fields
}
SourceMap maps bytecode IP offsets to source locations.
func (*SourceMap) Add ¶
func (sm *SourceMap) Add(ip int, info SourceInfo)
Add records a source location for the given instruction pointer offset.
func (*SourceMap) Entries ¶ added in v1.3.0
func (sm *SourceMap) Entries() []SourceMapEntry
Entries returns the source map entries.
func (*SourceMap) Lookup ¶
func (sm *SourceMap) Lookup(ip int) *SourceInfo
Lookup finds the SourceInfo for a given instruction pointer. Uses the last entry whose startIP <= ip.
type SourceMapEntry ¶ added in v1.3.0
type SourceMapEntry struct {
StartIP int
Info SourceInfo
}
SourceMapEntry is the exported version of sourceMapEntry.
type String ¶
type String string
String is boxed int
func (String) Conj ¶
func (l String) Conj(value Value) Collection
func (String) Empty ¶
func (l String) Empty() Collection
func (String) InvokeMethod ¶ added in v1.8.0
func (String) String ¶
String returns the EDN/Clojure-readable form: surrounded by double quotes with EDN-conformant escapes. NOTE: Go's %q emits \xNN / \a / \v for control chars, which the reader rejects ("unknown escape sequence \x") and which are not valid EDN — so %q did not round-trip its own output (e.g. ANSI-colored strings like "\x1b[32m..."). Escapes here match the reader's accepted set (reader.go): \" \\ \t \r \n \b \f, and \uXXXX for everything else below 0x20 plus DEL; printable Unicode passes through as raw UTF-8.
type StructMapping ¶
type StructMapping struct {
RecType *RecordType
GoType reflect.Type
// contains filtered or unexported fields
}
StructMapping holds the bidirectional mapping between a Go struct type and a RecordType.
func LookupStructMapping ¶
func LookupStructMapping(goType reflect.Type) *StructMapping
LookupStructMapping returns the mapping for a Go type, or nil if not registered.
func LookupStructMappingByRecord ¶
func LookupStructMappingByRecord(rt *RecordType) *StructMapping
LookupStructMappingByRecord returns the mapping for a RecordType, or nil.
func RegisterStruct ¶
func RegisterStruct[T any](name string) *StructMapping
RegisterStruct registers a Go struct type T and returns its StructMapping. Usage: mapping := vm.RegisterStruct[MyStruct]("my-ns/MyStruct")
func RegisterStructType ¶
func RegisterStructType(goType reflect.Type, name string) *StructMapping
RegisterStructType registers a Go struct type and creates a corresponding RecordType. The name parameter sets the record type name. Field names are derived from exported struct fields: use `letgo:"name"` struct tag for custom names, otherwise fields are converted from CamelCase to kebab-case (e.g. FirstName → first-name). Fields tagged `letgo:"-"` are skipped.
func (*StructMapping) RecordToStruct ¶
func (m *StructMapping) RecordToStruct(r *Record, target any) error
RecordToStruct populates a Go struct from a Record's fields. If the Record has an origin of the same type, returns it directly (fast path).
func (*StructMapping) StructToRecord ¶
func (m *StructMapping) StructToRecord(v any) *Record
StructToRecord converts a Go struct value to a Record. The original value is stored for fast roundtrip back to Go. Uses cached per-field converters to avoid BoxValue dispatch overhead.
type Symbol ¶
type Symbol string
Symbol is a string
func FuzzySymbolLookup ¶
func (Symbol) Namespaced ¶
type ThrownError ¶
type ThrownError struct {
Value Value // the thrown value (ExInfo or any Value)
}
ThrownError wraps a Value that was explicitly thrown. It propagates through the normal error return path.
func NewThrownError ¶
func NewThrownError(v Value) *ThrownError
func (*ThrownError) Error ¶
func (e *ThrownError) Error() string
type TransientMap ¶
type TransientMap struct {
// contains filtered or unexported fields
}
TransientMap is a mutable version of PersistentMap for batch operations. Mutations modify nodes in place instead of path-copying. Call persistent! to freeze back to an immutable PersistentMap.
func NewTransientMap ¶
func NewTransientMap(m *PersistentMap) *TransientMap
func (*TransientMap) Arity ¶ added in v1.6.0
func (t *TransientMap) Arity() int
func (*TransientMap) Assoc ¶
func (t *TransientMap) Assoc(key Value, val Value) (*TransientMap, error)
Assoc mutates the transient map in place.
func (*TransientMap) Conj ¶
func (t *TransientMap) Conj(value Value) (*TransientMap, error)
Conj adds a [key val] pair.
func (*TransientMap) Contains ¶ added in v1.6.0
func (t *TransientMap) Contains(key Value) Boolean
func (*TransientMap) Count ¶
func (t *TransientMap) Count() Value
func (*TransientMap) Dissoc ¶
func (t *TransientMap) Dissoc(key Value) (*TransientMap, error)
Dissoc mutates the transient map in place.
func (*TransientMap) Invoke ¶ added in v1.6.0
func (t *TransientMap) Invoke(args []Value) (Value, error)
func (*TransientMap) Persistent ¶
func (t *TransientMap) Persistent() (*PersistentMap, error)
Persistent freezes the transient and returns an immutable PersistentMap.
func (*TransientMap) RawCount ¶
func (t *TransientMap) RawCount() int
func (*TransientMap) String ¶
func (t *TransientMap) String() string
func (*TransientMap) Type ¶
func (t *TransientMap) Type() ValueType
func (*TransientMap) Unbox ¶
func (t *TransientMap) Unbox() any
func (*TransientMap) ValueAt ¶
func (t *TransientMap) ValueAt(key Value) Value
ValueAt for lookups during construction.
type TransientSet ¶ added in v1.6.0
type TransientSet struct {
// contains filtered or unexported fields
}
TransientSet is a mutable version of PersistentSet for batch ops.
func NewTransientSet ¶ added in v1.6.0
func NewTransientSet(s *PersistentSet) *TransientSet
func (*TransientSet) Arity ¶ added in v1.6.0
func (t *TransientSet) Arity() int
func (*TransientSet) Conj ¶ added in v1.6.0
func (t *TransientSet) Conj(value Value) (*TransientSet, error)
func (*TransientSet) Contains ¶ added in v1.6.0
func (t *TransientSet) Contains(key Value) Boolean
func (*TransientSet) Count ¶ added in v1.6.0
func (t *TransientSet) Count() Value
func (*TransientSet) Disj ¶ added in v1.6.0
func (t *TransientSet) Disj(value Value) (*TransientSet, error)
func (*TransientSet) Invoke ¶ added in v1.6.0
func (t *TransientSet) Invoke(args []Value) (Value, error)
func (*TransientSet) Persistent ¶ added in v1.6.0
func (t *TransientSet) Persistent() (*PersistentSet, error)
func (*TransientSet) RawCount ¶ added in v1.6.0
func (t *TransientSet) RawCount() int
func (*TransientSet) String ¶ added in v1.6.0
func (t *TransientSet) String() string
func (*TransientSet) Type ¶ added in v1.6.0
func (t *TransientSet) Type() ValueType
func (*TransientSet) Unbox ¶ added in v1.6.0
func (t *TransientSet) Unbox() any
func (*TransientSet) ValueAt ¶ added in v1.6.0
func (t *TransientSet) ValueAt(key Value) Value
type TransientVector ¶
type TransientVector struct {
// contains filtered or unexported fields
}
TransientVector is a mutable version of ArrayVector/PersistentVector.
func NewTransientVector ¶
func NewTransientVector(v []Value) *TransientVector
func (*TransientVector) Arity ¶ added in v1.6.0
func (t *TransientVector) Arity() int
func (*TransientVector) Assoc ¶
func (t *TransientVector) Assoc(key Value, val Value) (*TransientVector, error)
Assoc sets index to value.
func (*TransientVector) Conj ¶
func (t *TransientVector) Conj(value Value) (*TransientVector, error)
Conj appends to the transient vector in place.
func (*TransientVector) Contains ¶ added in v1.6.0
func (t *TransientVector) Contains(key Value) Boolean
func (*TransientVector) Count ¶
func (t *TransientVector) Count() Value
func (*TransientVector) Invoke ¶ added in v1.6.0
func (t *TransientVector) Invoke(args []Value) (Value, error)
func (*TransientVector) Nth ¶ added in v1.11.0
func (t *TransientVector) Nth(i int) Value
Nth implements Indexed: positional access by integer index. TransientVector is positional but not seqable, so `nth` must reach it through this rather than seq traversal.
func (*TransientVector) Persistent ¶
func (t *TransientVector) Persistent() (Value, error)
Persistent freezes the transient and returns an immutable vector.
func (*TransientVector) Pop ¶ added in v1.5.0
func (t *TransientVector) Pop() (*TransientVector, error)
Pop removes the last element from the transient vector.
func (*TransientVector) RawCount ¶
func (t *TransientVector) RawCount() int
func (*TransientVector) String ¶
func (t *TransientVector) String() string
func (*TransientVector) Type ¶
func (t *TransientVector) Type() ValueType
func (*TransientVector) Unbox ¶
func (t *TransientVector) Unbox() any
func (*TransientVector) ValueAt ¶
func (t *TransientVector) ValueAt(key Value) Value
type TypeError ¶
type TypeError struct {
// contains filtered or unexported fields
}
TypeError is a LETGO type error which mostly happens when there is a type mismatch between either LETGO values or LETGO values and Go values. These errors print as:
TypeError: (encountered type name) ... message ... (expected type name)
func NewTypeError ¶
NewTypeError creates a new type error. This error will print the problematic value's (either interface{} or Value) type name, a message, and expected type name.
type TypedArray ¶ added in v1.3.1
type TypedArray struct {
// contains filtered or unexported fields
}
TypedArray is a mutable, typed array backed by a native Go slice. Unlike persistent collections, arrays support in-place mutation via Set.
func NewByteArray ¶ added in v1.3.1
func NewByteArray(size int) *TypedArray
func NewByteArrayFrom ¶ added in v1.3.1
func NewByteArrayFrom(data []byte) *TypedArray
func NewFloatArray ¶ added in v1.3.1
func NewFloatArray(size int) *TypedArray
func NewFloatArrayFrom ¶ added in v1.3.1
func NewFloatArrayFrom(data []float64) *TypedArray
func NewIntArray ¶ added in v1.3.1
func NewIntArray(size int) *TypedArray
func NewIntArrayFrom ¶ added in v1.3.1
func NewIntArrayFrom(data []int64) *TypedArray
func NewObjectArray ¶ added in v1.3.1
func NewObjectArray(size int) *TypedArray
func NewObjectArrayFrom ¶ added in v1.3.1
func NewObjectArrayFrom(data []Value) *TypedArray
func (*TypedArray) Arity ¶ added in v1.3.1
func (a *TypedArray) Arity() int
func (*TypedArray) Clone ¶ added in v1.3.1
func (a *TypedArray) Clone() *TypedArray
Clone returns a shallow copy.
func (*TypedArray) Conj ¶ added in v1.3.1
func (a *TypedArray) Conj(v Value) Collection
func (*TypedArray) Count ¶ added in v1.3.1
func (a *TypedArray) Count() Value
func (*TypedArray) Empty ¶ added in v1.3.1
func (a *TypedArray) Empty() Collection
func (*TypedArray) Get ¶ added in v1.3.1
func (a *TypedArray) Get(i int) Value
Get returns the element at index i as a boxed Value.
func (*TypedArray) Invoke ¶ added in v1.3.1
func (a *TypedArray) Invoke(args []Value) (Value, error)
func (*TypedArray) Kind ¶ added in v1.3.1
func (a *TypedArray) Kind() ArrayKind
Kind returns the element kind.
func (*TypedArray) Len ¶ added in v1.3.1
func (a *TypedArray) Len() int
func (*TypedArray) Meta ¶ added in v1.3.1
func (a *TypedArray) Meta() Value
Meta implements IMeta — arrays don't carry metadata.
func (*TypedArray) Nth ¶ added in v1.11.0
func (a *TypedArray) Nth(i int) Value
Nth implements Indexed: positional access by integer index.
func (*TypedArray) RawCount ¶ added in v1.3.1
func (a *TypedArray) RawCount() int
func (*TypedArray) Seq ¶ added in v1.3.1
func (a *TypedArray) Seq() Seq
func (*TypedArray) Set ¶ added in v1.3.1
func (a *TypedArray) Set(i int, v Value) error
Set sets the element at index i, coercing v to the element type.
func (*TypedArray) String ¶ added in v1.3.1
func (a *TypedArray) String() string
func (*TypedArray) Type ¶ added in v1.3.1
func (a *TypedArray) Type() ValueType
func (*TypedArray) Unbox ¶ added in v1.3.1
func (a *TypedArray) Unbox() any
Unbox returns the underlying Go slice directly for interop.
func (*TypedArray) ValueAt ¶ added in v1.3.1
func (a *TypedArray) ValueAt(key Value) Value
func (*TypedArray) ValueAtOr ¶ added in v1.3.1
func (a *TypedArray) ValueAtOr(key Value, dflt Value) Value
func (*TypedArray) WithMeta ¶ added in v1.3.1
func (a *TypedArray) WithMeta(_ Value) Value
WithMeta implements IMeta — returns self (arrays don't support metadata).
type TypedArraySeq ¶ added in v1.3.1
type TypedArraySeq struct {
// contains filtered or unexported fields
}
func (*TypedArraySeq) Conj ¶ added in v1.3.1
func (s *TypedArraySeq) Conj(val Value) Collection
func (*TypedArraySeq) Cons ¶ added in v1.3.1
func (s *TypedArraySeq) Cons(val Value) Seq
func (*TypedArraySeq) Count ¶ added in v1.3.1
func (s *TypedArraySeq) Count() Value
func (*TypedArraySeq) Empty ¶ added in v1.3.1
func (s *TypedArraySeq) Empty() Collection
func (*TypedArraySeq) First ¶ added in v1.3.1
func (s *TypedArraySeq) First() Value
func (*TypedArraySeq) Meta ¶ added in v1.3.1
func (s *TypedArraySeq) Meta() Value
func (*TypedArraySeq) More ¶ added in v1.3.1
func (s *TypedArraySeq) More() Seq
func (*TypedArraySeq) Next ¶ added in v1.3.1
func (s *TypedArraySeq) Next() Seq
func (*TypedArraySeq) Nth ¶ added in v1.11.0
func (s *TypedArraySeq) Nth(i int) Value
Nth implements Indexed: positional access by integer index.
func (*TypedArraySeq) RawCount ¶ added in v1.3.1
func (s *TypedArraySeq) RawCount() int
func (*TypedArraySeq) Seq ¶ added in v1.3.1
func (s *TypedArraySeq) Seq() Seq
func (*TypedArraySeq) String ¶ added in v1.3.1
func (s *TypedArraySeq) String() string
func (*TypedArraySeq) Type ¶ added in v1.3.1
func (s *TypedArraySeq) Type() ValueType
func (*TypedArraySeq) Unbox ¶ added in v1.3.1
func (s *TypedArraySeq) Unbox() any
func (*TypedArraySeq) ValueAt ¶ added in v1.3.1
func (s *TypedArraySeq) ValueAt(key Value) Value
func (*TypedArraySeq) ValueAtOr ¶ added in v1.3.1
func (s *TypedArraySeq) ValueAtOr(key Value, dflt Value) Value
func (*TypedArraySeq) WithMeta ¶ added in v1.3.1
func (s *TypedArraySeq) WithMeta(_ Value) Value
type UUID ¶ added in v1.5.0
type UUID struct {
// contains filtered or unexported fields
}
UUID holds a UUID string in canonical lowercase form.
type Value ¶
Value is implemented by all LETGO values
func ErrorToValue ¶ added in v1.11.0
ErrorToValue is the exported entry point used by gogen_ir-lowered Go code to convert a Go error returned by an invoked try body/handler into the catchable Value that a (catch e ...) handler binds. Mirrors the bytecode VM's handler path (vm.go handleError), so AOT-lowered try/catch sees the same caught value.
func MaybeDowngrade ¶
MaybeDowngrade returns an Int if the BigInt fits in int64, otherwise BigInt.
func MaybeSimplifyRatio ¶ added in v1.5.0
MaybeSimplifyRatio returns an Int/BigInt if denominator is 1, otherwise Ratio.
func MustBox ¶ added in v1.9.0
MustBox boxes a Go value via BoxValue and panics on error. Intended for use at init time (e.g. namespace install functions) where boxing failure is a programmer error, not a runtime condition.
func NewArrayVector ¶
func NewPersistentVector ¶
func NumAddP ¶ added in v1.8.0
NumAddP is `+` with overflow promotion for Int+Int. All other type combinations match NumAdd exactly. Delegating to NumAdd for the non-Int/Int paths is safe because NumAdd's BigInt branches return NewBigInt(...) directly (no MaybeDowngrade), preserving BigInt identity through `+'`. The same invariant is relied on by NumSubP and NumMulP below — if you change MaybeDowngrade usage in NumAdd/Sub/Mul, re-check the eval tests `(bigint? (+' 1 1N))` etc. NumNeg DOES downgrade *BigInt, hence the explicit branch in NumNegP. Naming mirrors Clojure JVM's `addP`/`multiplyP` precedent.
func NumMod ¶
NumMod computes the floored modulus (like Clojure's mod). Sign follows the divisor: (mod -10 3) => 2
func NumNegP ¶ added in v1.8.0
NumNegP is unary `-` with overflow promotion at math.MinInt. For *BigInt we negate directly without downgrading — `(-' 1N)` must return `-1N`, not `Int -1` (Clojure preserves BigInt identity through promoting ops). NumNeg in pkg/vm/numbers.go does downgrade, hence the explicit BigInt branch here.
func NumRem ¶ added in v1.3.1
NumRem computes the remainder of truncated division (like Java's %). Sign follows the dividend: (rem -10 3) => -1
func RunWithBindings ¶ added in v1.8.0
func RunWithBindings(snap BindingSnapshot, fn func() (Value, error)) (Value, error)
RunWithBindings runs fn with snap installed as the root context's dynamic bindings, restoring the prior state afterwards. This is the legacy process-global bracketing used by spawn sites that have not yet moved to a child ExecContext; true per-goroutine isolation comes from running fn under ec.Child() instead (see docs/design/exec-context-threading.md).
func SeqToSlice ¶ added in v1.8.0
SeqToSlice realizes a let-go sequence value into a []Value. Useful when a Go caller has a vm.Value and explicitly wants a slice. Returns nil for nil/NIL/empty input. Returns an error if v isn't a sequence.
For infinite sequences this will not terminate — use Iter and break instead.
type Var ¶
type Var struct {
// contains filtered or unexported fields
}
func (*Var) AlterRootArgs ¶ added in v1.8.0
func (*Var) Deref ¶
Deref returns the current value in the root execution context: the dynamic top binding if one is active, else the root. Host and lowered callers that hold no ExecContext resolve here; the interpreter resolves against its frame's context (which is the root context unless a child was installed).
func (*Var) IsBound ¶ added in v1.10.0
IsBound reports whether the var has any bound value — a root binding OR an active dynamic binding — matching Clojure's bound?. A var interned by the compiler for a forward `(def x v)` (before it runs) has neither yet, which distinguishes "declared but unset" from "set", as `defonce` needs.
func (*Var) PopBinding ¶
func (v *Var) PopBinding()
PopBinding removes the most recent dynamic binding in the root context.
func (*Var) PushBinding ¶
PushBinding pushes a dynamic binding value in the root execution context.
func (*Var) RemoveWatch ¶ added in v1.8.0
func (*Var) Root ¶ added in v1.8.0
Root returns the var's root binding directly, bypassing any current dynamic binding on the stack. Use this where Clojure semantics require the root (e.g. alter-var-root) rather than the currently visible deref value.
func (*Var) SetDynamic ¶
func (v *Var) SetDynamic()
func (*Var) SetPrivate ¶
func (v *Var) SetPrivate()
type Volatile ¶
type Volatile struct {
// contains filtered or unexported fields
}
Volatile is a mutable container with no synchronization. Useful for transducers and other single-threaded mutation contexts.
func NewVolatile ¶
Source Files
¶
- ansi.go
- atom.go
- bigdecimal.go
- bigint.go
- binding_stack.go
- bool.go
- boxed.go
- chan.go
- char.go
- chunk.go
- chunked_seq.go
- compare.go
- cons.go
- constpool.go
- deftype.go
- delay.go
- equals.go
- errfmt.go
- errors.go
- exec_context.go
- exinfo.go
- float.go
- func.go
- hash.go
- instant.go
- int.go
- invokable.go
- iter.go
- iterate.go
- keyword.go
- lazy_seq.go
- list.go
- map.go
- multifn.go
- namespace.go
- native_func.go
- nil.go
- numbers.go
- numbers_promote.go
- numcache.go
- persistent_map.go
- persistent_set.go
- persistent_vector.go
- persistent_vector_chunked.go
- profile.go
- promise.go
- protocol.go
- range.go
- range_chunked.go
- ratio.go
- record.go
- record_base.go
- reduced.go
- regex.go
- repeat.go
- scope.go
- set.go
- sorted_map.go
- sorted_set.go
- source.go
- string.go
- struct_interop.go
- struct_mapping.go
- symbol.go
- transient.go
- typed_array.go
- uuid.go
- value.go
- var.go
- vector.go
- vm.go
- void.go
- volatile.go