Documentation
¶
Overview ¶
Package env provides namespace management for the system
Index ¶
- Constants
- func MustResolveValue(ns Namespace, s data.Symbol) data.Value
- func ResolveValue(ns Namespace, s data.Symbol) (data.Value, bool)
- func RootSymbol(name data.Local) data.Symbol
- type Entry
- type Environment
- func (e *Environment) Domains() data.Locals
- func (e *Environment) Get(domain data.Local, res Resolver) Namespace
- func (e *Environment) GetAnonymous() Namespace
- func (e *Environment) GetQualified(n data.Local) Namespace
- func (e *Environment) GetRoot() Namespace
- func (e *Environment) New(n data.Local) Namespace
- func (e *Environment) Snapshot() (*Environment, error)
- type Namespace
- type Resolver
Constants ¶
const ( // ErrNameAlreadyBound is raised when an attempt is made to bind a // Namespace entry that has already been bound ErrNameAlreadyBound = "name is already bound in namespace: %s" // ErrNameNotBound is raised when an attempt is mode to retrieve a value // from a Namespace that hasn't been bound ErrNameNotBound = "name is not bound in namespace: %s" // ErrSnapshotIncomplete is raised when an attempt is made to create a // Namespace snapshot in a situation where an unbound entry has been // retrieved ErrSnapshotIncomplete = "can't snapshot environment. entry not bound: %s" )
const ( // ErrSymbolNotDeclared is raised when an attempt to forcefully resolve an // undeclared symbol in the Namespace fails ErrSymbolNotDeclared = "symbol not declared in namespace: %s" // ErrSymbolNotBound is raised when an attempt to forcefully resolve an // unbound symbol in the Namespace fails ErrSymbolNotBound = "symbol not bound in namespace: %s" )
const ( // RootDomain stores built-ins RootDomain = data.Local("ale") // AnonymousDomain identifies an anonymous namespace AnonymousDomain = data.Local("*anon*") )
Variables ¶
This section is empty.
Functions ¶
func MustResolveValue ¶
MustResolveValue attempts to resolve a value or explodes violently
func ResolveValue ¶
ResolveValue attempts to resolve a symbol to a bound value
Types ¶
type Entry ¶
type Entry interface { Owner() Namespace Name() data.Local Value() data.Value Bind(data.Value) IsBound() bool IsPrivate() bool }
Entry represents a namespace entry
func MustResolveSymbol ¶
MustResolveSymbol attempts to resolve a symbol or explodes violently
type Environment ¶
Environment maintains a mapping of domain names to namespaces
func NewEnvironment ¶
func NewEnvironment() *Environment
NewEnvironment creates a new synchronous namespace map
func (*Environment) Domains ¶
func (e *Environment) Domains() data.Locals
func (*Environment) Get ¶
func (e *Environment) Get(domain data.Local, res Resolver) Namespace
Get returns a mapped namespace or instantiates a new one to be cached
func (*Environment) GetAnonymous ¶
func (e *Environment) GetAnonymous() Namespace
GetAnonymous returns an anonymous (non-resolvable) namespace
func (*Environment) GetQualified ¶
func (e *Environment) GetQualified(n data.Local) Namespace
GetQualified returns the namespace for the specified domain.
func (*Environment) GetRoot ¶
func (e *Environment) GetRoot() Namespace
GetRoot returns the root namespace, where built-ins go
func (*Environment) New ¶
func (e *Environment) New(n data.Local) Namespace
New constructs a new namespace
func (*Environment) Snapshot ¶
func (e *Environment) Snapshot() (*Environment, error)