package full
import "github.com/purpleidea/mgmt/lang/types/full"
Index ¶
- type FuncValue
- func NewFunc(t *types.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{}
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 ¶
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 ¶
Cmp returns an error if this value isn't the same as the arg passed in.
func (*FuncValue) Copy ¶
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 ¶
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 ¶
String returns a visual representation of this value.
func (*FuncValue) 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.
Source Files ¶
- Version
- v0.0.0-20250322185616-c50a578426f1 (latest)
- Published
- Mar 22, 2025
- Platform
- linux/amd64
- Imports
- 4 packages
- Last checked
- 4 days ago –
Tools for package owners.