Documentation ¶
Overview ¶
Package vartypes contains basic types for manipulating Elvish variables.
Index ¶
- func DelElement(variable Variable, indicies []interface{}) error
- func GetElementErrorLevel(err error) int
- func IsBlackhole(v Variable) bool
- type Variable
- func GetHeadOfElement(v Variable) Variable
- func MakeElement(v Variable, indicies []interface{}) (Variable, error)
- func NewAny(v interface{}) Variable
- func NewBlackhole() Variable
- func NewCallback(set func(interface{}) error, get func() interface{}) Variable
- func NewElement(v Variable, a []interface{}, i []interface{}) Variable
- func NewEnv(name string) Variable
- func NewRo(v interface{}) Variable
- func NewRoCallback(get func() interface{}) Variable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DelElement ¶
DelElement deletes an element. It uses a similar process to MakeElement, except that the last level of container needs to be Dissoc-able instead of Assoc-able.
func GetElementErrorLevel ¶
GetElementErrorLevel returns the level of an error returned by MakeElement or DelElement. Level 0 represents that the error is about the variable itself. If the argument was not returned from MakeVariable, -1 is returned.
func IsBlackhole ¶
IsBlackhole returns whether the variable is a blackhole variable.
Types ¶
type Variable ¶
type Variable interface { Set(v interface{}) error Get() interface{} }
Variable represents an Elvish variable.
func GetHeadOfElement ¶
GetHeadOfElement gets the underlying head variable of an element variable, or nil if the argument is not an element variable.
func MakeElement ¶
MakeElement returns a variable, that when set, simulates the mutation of an element.
func NewAny ¶
func NewAny(v interface{}) Variable
NewAny creates a variable with an initial value. The variable created can be assigned values of any type.
func NewBlackhole ¶
func NewBlackhole() Variable
NewBlackhole returns a blackhole variable. Assignments to a blackhole variable will be discarded, and getting a blackhole variable always returns an empty string.
func NewCallback ¶
NewCallback makes a variable from a set callback and a get callback.
func NewElement ¶
NewElement returns an ephemeral variable used for assigning variable element.
func NewRoCallback ¶
func NewRoCallback(get func() interface{}) Variable
NewRoCallback makes a read-only variable from a get callback.