struct Context{T}

Context is a container for storing any contextual information. It uses Memento pattern to keep track of prior history. While the context can be changed, explict save/restore can be used to save the current context and restore the most recently saved one.


  • id::UInt64

    ID of the context

  • history::DataStructures.Stack{T} where T

    History of context data

  • path::Array{Symbol,1}

    Call path

Context(id::UInt64, container::T) -> Context{_A} where _A

Create a context with the provided container.

context([id::UInt], [container])

Get a new context object. If id is not passed, then return a global context for the current thread/task. The container must be an object that supports push!, getindex, empty!, and length functions. The default is Dict{Any,Any}.

save(c::Context) -> DataStructures.Stack{_A} where _A

Save the current context to history.

@ctx <function definition> [label]

Define a function that is context-aware i.e. save the current context before executing the function and restore the context right before returning to the caller. So, if the function modifies the context using (see @memo), then the change is not visible the caller. ```

@memo var = expr
@memo var

Store the variable/value from the assigment statement in the current context.