Package lepl :: Package support :: Module context
[hide private]
[frames] | no frames]

Module context

source code

Allow global per-thread values to be defined within a certain scope in a way that supports multiple values, temporary changes inside with contexts, etc.

This is implemented in two layers. The base layer is a map from keys to values which isolates different, broad, functionalities. Despite the name, a NamespaceMap can map from any key to any value - it's just a thread-local map. However, typically is it used with Namespaces because they have support for some useful idioms.

A Namespace is, as described above, associated with a name in the thread's NamespaceMap. It manages state for some functionality, so is another map, forming the second layer. The motivating example of a Namespace is the OperatorNamespace, which maps from operators to matchers. This uses the support in Namespace that allows values to be over-ridden within a certain scope to support overriding matchers for matching spaces.

Classes [hide private]
  ContextError
Exception raised on problems with context.
  NamespaceMap
A store for namespaces.
  Namespace
A store for global definitions.
  OnceOnlyNamespace
Allow some values to be set only once.
  NamespaceMixin
Allow access to global (per-thread) values.
  Scope
Base class supporting dedicated syntax for particular options.
Functions [hide private]
 
Global(name, default=None)
Global (per-thread) binding from operator name to implementation, by namespace.
source code