Documentation ¶
Index ¶
- type FuncValue
- func (obj *FuncValue) Call(txn interfaces.Txn, args []interfaces.Func) (interfaces.Func, error)
- func (obj *FuncValue) Cmp(val types.Value) error
- func (obj *FuncValue) Copy() types.Value
- func (obj *FuncValue) Func() interface{}
- func (obj *FuncValue) Less(v types.Value) bool
- func (obj *FuncValue) Set(fn func(interfaces.Txn, []interfaces.Func) (interfaces.Func, error)) error
- func (obj *FuncValue) String() string
- func (obj *FuncValue) Type() *types.Type
- func (obj *FuncValue) Value() interface{}
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 (*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) 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 ¶
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.