class Ven::Suite::Context

Overview

The context implements the scope semantics via a scopes stack, defines the traces stack for tracebacking and the underscores stack for working with contextual values (i.e., _ and &_).

Defined in:

ven/suite/context.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

[View source]

Instance Method Detail

def []=(name : String, value : Model) #

Binds a new local symbol name to value. Returns value back.


[View source]
def define(name : String, value : Model, local = true, internal = false) #

Defines a symbol called name that will hold a value. If same-named symbol with local set to false already exists (local prior to global), redefines this symbol to henceforth hold value.


[View source]
def fetch(name : String) : Model | Nil #

Retrieves a symbol called name. It looks for it in the localmost scope first, then proceeds up to the parenting scopes.


[View source]
def in(names : Array(String), values : Models, &) #

Executes block in a new scope. names and values are names and values the new scope will be initialized with.


[View source]
def in(&) #

Executes block in a new empty scope.


[View source]
def in_fun? : Bool #

Returns whether the evaluation is currently in a function.


[View source]
def inject(scope : Scope, local = true) #

Pushes a scope onto the scopes stack. Makes all symbols' local be local.


[View source]
def scope? : Scope #

Returns the localmost scope as a Scope.


[View source]
def traces : Array(Ven::Suite::Trace) #

[View source]
def traces=(traces : Array(Ven::Suite::Trace)) #

[View source]
def tracing(trace t : Tuple(QTag, String), &) #

Records the evaluation of block as trace and properly disposes of this trace after the block has been executed.


[View source]
def u!(value : Model) #

Pushes a value onto the underscores stack.


[View source]
def u? #

Pops and returns a value from the underscores stack.


[View source]
def uninject : Scope #

Pops a scope from the scopes stack and returns it.


[View source]

Returns the underscores stack.


[View source]
def with_u(values : Models, &) #

Pushes given values onto the underscores stack, evaluates the block and cleans the underscores stack by removing unused values, if any.


[View source]