scope

package
v0.0.0-...-4998ed7 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2021 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package scope provides the Scope type, which is used by an evaluator.Evaluator to look up and store scope-specific values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Scope

type Scope struct {
	// Parent is the parent scope of this scope.
	Parent *Scope
	// contains filtered or unexported fields
}

Scope is a map of values indexed by identifiers.

A scope may have a parent scope. If the current scope does not store a value for a specific identifier, the parent scopes will be considered (recursively.)

func (*Scope) ClearSelf

func (s *Scope) ClearSelf()

ClearSelf removes all values associated with this scope, not including any parent scopes.

func (*Scope) HasValue

func (s *Scope) HasValue(name string) bool

HasValue returns whether the scope or any of its parent scopes store a value identified by name.

func (*Scope) Lock

func (s *Scope) Lock()

Lock prevents this scope from further modification. Parent scopes (if any) will not be locked.

func (*Scope) Set

func (s *Scope) Set(name string, v interface{})

Set stores the value v identified by name in the scope.

If the scope has a parent scope, and that parent scope already stores a value for that identifier, the value is stored (overwritten) in the parent scope instead. Parent scopes are considered recursively until there is no parent scope.

If the scope where the value should be stored is locked, nothing will happen.

func (*Scope) Value

func (s *Scope) Value(name string) (interface{}, bool)

Value returns the value identified by name in this scope or any of its parent scopes. If there is a value, ok will be true, otherwise it will be false.

Jump to

Keyboard shortcuts

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