vartypes

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2018 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package vartypes contains basic types for manipulating Elvish variables.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DelElement

func DelElement(variable Variable, indicies []types.Value) error

DelElement deletes an element. It uses a similar process to MakeElement, except that the last level of container needs to be a Dissocer instead of an Assocer.

func GetElementErrorLevel

func GetElementErrorLevel(err error) int

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

func IsBlackhole(v Variable) bool

IsBlackhole returns whether the variable is a blackhole variable.

func ShouldBeBool

func ShouldBeBool(v types.Value) error

func ShouldBeList

func ShouldBeList(v types.Value) error

func ShouldBeMap

func ShouldBeMap(v types.Value) error

func ShouldBeNumber

func ShouldBeNumber(v types.Value) error

Types

type Variable

type Variable interface {
	Set(v types.Value) error
	Get() types.Value
}

Variable represents an Elvish variable.

func GetHeadOfElement

func GetHeadOfElement(v Variable) Variable

GetHeadOfElement gets the underlying head variable of an element variable, or nil if the argument is not an element variable.

func MakeElement

func MakeElement(v Variable, indicies []types.Value) (Variable, error)

MakeElement returns a variable, that when set, simulates the mutation of an element.

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 NewBool

func NewBool(ptr *bool) Variable

func NewCallback

func NewCallback(set func(types.Value) error, get func() types.Value) Variable

NewCallback makes a variable from a set callback and a get callback.

func NewElement

func NewElement(v Variable, a []types.Assocer, i []types.Value) Variable

NewElement returns an ephemeral variable used for assigning variable element.

func NewEnv

func NewEnv(name string) Variable

NewEnv returns an environment variable.

func NewNumber

func NewNumber(ptr *float64) Variable

func NewPtr

func NewPtr(v types.Value) Variable

func NewRo

func NewRo(v types.Value) Variable

func NewRoCallback

func NewRoCallback(get func() types.Value) Variable

NewRoCallback makes a read-only variable from a get callback.

func NewString

func NewString(ps *string) Variable

NewString creates a variable from a string pointer. The Variable can only be set to a String value, and modifications are reflected in the passed string.

func NewValidatedPtr

func NewValidatedPtr(v types.Value, vld func(types.Value) error) Variable

Jump to

Keyboard shortcuts

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