vars

package
v0.0.0-...-7337ae7 Latest Latest
Warning

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

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

Documentation

Overview

Package vars contains basic types for manipulating Elvish variables.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DelElement

func DelElement(variable Var, indicies []interface{}) error

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 ElementErrorLevel

func ElementErrorLevel(err error) int

ElementErrorLevel 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 Var) bool

IsBlackhole returns whether the variable is a blackhole variable.

Types

type Var

type Var interface {
	Set(v interface{}) error
	Get() interface{}
}

Var represents an Elvish variable.

func FromGet

func FromGet(get func() interface{}) Var

FromGet makes a variable from a get callback. The variable is read-only.

func FromPtr

func FromPtr(p interface{}) Var

FromPtr creates a variable from a pointer. The variable is kept in sync with the value the pointer points to, using elvToGo and goToElv conversions when Get and Set.

func FromSetGet

func FromSetGet(set func(interface{}) error, get func() interface{}) Var

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

func HeadOfElement

func HeadOfElement(v Var) Var

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

func MakeElement

func MakeElement(v Var, indicies []interface{}) (Var, error)

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

func NewAnyWithInit

func NewAnyWithInit(v interface{}) Var

NewAnyWithInit creates a variable with an initial value. The variable created can be assigned values of any type.

func NewBlackhole

func NewBlackhole() Var

NewBlackhole returns a blackhole variable. Assignments to a blackhole variable will be discarded, and getting a blackhole variable always returns an empty string.

func NewElement

func NewElement(v Var, a []interface{}, i []interface{}) Var

NewElement returns an ephemeral variable used for assigning variable element.

func NewEnv

func NewEnv(name string) Var

NewEnv returns an environment variable.

func NewRo

func NewRo(v interface{}) Var

Jump to

Keyboard shortcuts

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