Scope: {
    iterationLimit: number;
    memoryLimit: number;
    recursionLimit: number;
    timeLimit: number;
}

A scope is a set of names in a dictionary that are bound (defined) in a MathJSON expression.

Scopes are arranged in a stack structure. When an expression that defined a new scope is evaluated, the new scope is added to the scope stack. Outside of the expression, the scope is removed from the scope stack.

The scope stack is used to resolve symbols, and it is possible for a scope to 'mask' definitions from previous scopes.

Scopes are lexical (also called a static scope): they are defined based on where they are in an expression, they are not determined at runtime.

Type declaration

  • ExperimentaliterationLimit: number

    Signal iteration-limit-exceeded when the iteration limit in a loop is exceeded. Default: no limits.

  • ExperimentalmemoryLimit: number

    Signal out-of-memory when the memory usage for this scope is exceeded.

    Memory is in Megabytes, default: 1Mb.

  • ExperimentalrecursionLimit: number

    Signal recursion-depth-exceeded when the recursion depth for this scope is exceeded.

  • ExperimentaltimeLimit: number

    Signal timeout when the execution time for this scope is exceeded.

    Time in seconds, default 2s.