Documentation
¶
Overview ¶
Package scope provides types for modeling execution scopes, as well as simple namespaces.
Index ¶
- type RWScope
- func (s *RWScope[V]) Assign(key string, value V) error
- func (s *RWScope[V]) CanAssign(key string) bool
- func (s *RWScope[V]) Define(k string, v V)
- func (s *RWScope[V]) Find(key string) (value V, ok bool)
- func (s *RWScope[V]) IsLocal(key string) bool
- func (s *RWScope[V]) LocalKeys() iter.Seq[string]
- func (s *RWScope[V]) ReadOnly() Scope[V]
- func (s *RWScope[V]) String() string
- type Scope
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RWScope ¶
type RWScope[V any] struct { // contains filtered or unexported fields }
RWScope stores key,value pairs and the Scope interface. A key, value pair is always defined within the scope. A value can retrieved from its key by querying the scope and, if not found, its parents recursively.
func (*RWScope[V]) Assign ¶
Assign maps an existing `key` to `value`, failing if no matching mapping is found. The assignment starts at the scope's innermost namespace and cascades upwards through successive parent scopes.
func (*RWScope[V]) IsLocal ¶ added in v0.3.0
IsLocal returns true if the key is defined in the local scope.
type Scope ¶
Scope provides a set of values that can be find given their name.
func NewReadOnly ¶
NewReadOnly returns a scope that can only be queried and not modified.
func NewScopeWithValues ¶
NewScopeWithValues returns a scope with predefined values.