full

package
v0.0.0-...-a0d500a Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2025 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FuncValue

type FuncValue struct {
	types.Base
	V func(interfaces.Txn, []interfaces.Func) (interfaces.Func, error)
	T *types.Type // contains ordered field types, arg names are a bonus part
}

FuncValue represents a function value, for example a built-in or a lambda.

In most languages, we can simply call a function with a list of arguments and expect to receive a single value. In this language, however, a function might be something like datetime.now() or fn(n) {shell(Sprintf("seq %d", n))}, which might not produce a value immediately, and might then produce multiple values over time. Thus, in this language, a FuncValue does not receive Values, instead it receives input Func nodes. The FuncValue then adds more Func nodes and edges in order to arrange for output values to be sent to a particular output node, which the function returns so that the caller may connect that output node to more nodes down the line.

The function can also return an error which could represent that something went horribly wrong. (Think, an internal panic.)

func NewFunc

func NewFunc(t *types.Type) *FuncValue

NewFunc creates a new function with the specified type.

func (*FuncValue) Call

func (obj *FuncValue) Call(txn interfaces.Txn, args []interfaces.Func) (interfaces.Func, error)

Call calls the function with the provided txn and args.

func (*FuncValue) Cmp

func (obj *FuncValue) Cmp(val types.Value) error

Cmp returns an error if this value isn't the same as the arg passed in.

func (*FuncValue) Copy

func (obj *FuncValue) Copy() types.Value

Copy returns a copy of this value.

func (*FuncValue) Func

func (obj *FuncValue) Func() interface{}

Func represents the value of this type as a function if it is one. If this is not a function, then this panics.

func (*FuncValue) Less

func (obj *FuncValue) Less(v types.Value) bool

Less compares to value and returns true if we're smaller. This panics if the two types aren't the same.

func (*FuncValue) Set

func (obj *FuncValue) Set(fn func(interfaces.Txn, []interfaces.Func) (interfaces.Func, error)) error

Set sets the function value to be a new function.

func (*FuncValue) String

func (obj *FuncValue) String() string

String returns a visual representation of this value.

func (*FuncValue) Type

func (obj *FuncValue) Type() *types.Type

Type returns the type data structure that represents this type.

func (*FuncValue) Value

func (obj *FuncValue) Value() interface{}

Value returns the raw value of this type.

Jump to

Keyboard shortcuts

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