SPB Git

Repository Public MIT

workspace.md 2.2 KB

# Workspace engine (ORIXWorkspace)

A workspace is an ordered list of cells. Formula cells may define a variable (NPV = …) or a function (f(x) = …); live parameters define a variable driven by a slider; tables and graphs read variables.

flowchart LR
    Investment --> NPV
    DiscountRate(("DiscountRate<br/>live parameter")) --> NPV
    CashFlow1 --> NPV
    CashFlow2 --> NPV
    CashFlow3 --> NPV
    NPV --> Decision
    DiscountRate --> Graph["graph cell"]
    DiscountRate --> Table["table cell"]

# Recalculation

  1. Parse every cell (two passes: function names are collected first so that f(2) in another cell is a call).
  2. Resolve names: the first definition of a name wins; a later duplicate is an error on that cell.
  3. Topological order (Kahn's algorithm in document order). Cells that cannot be ordered are in a cycle: each gets a circularReference error with the actual path (a → b → c → a). Nothing loops.
  4. Evaluate in order. A cell whose dependency failed gets "Depends on “x”, which has an error".
  5. Incremental updates: editing a cell or moving a slider re-evaluates only that cell and its transitive dependents (lastRecalculated lists them). Changes that alter names, the set of functions or the error structure trigger a full pass.

Cell order in the document does not matter for evaluation: c = a + b may appear above a = 5.

# Exports

Plain text, Markdown, CSV (machine-readable full-precision values), LaTeX (a complete article document using amsmath), and the native .orixcalc file. Every export ends with the assumptions that the numbers depend on: angle mode, percent convention, complex mode, arithmetic model. Unit labels travel with their cells.

# File format

.orixcalc is JSON: { checksum, format, version, workspace }. The checksum is the SHA-256 of the canonical encoding of the document. On load: wrong format → rejected; newer version → rejected with a clear message; checksum mismatch → reported as damaged, with the readable content returned for recovery; truncated file → reported as damaged.

Files main
Menu

Theme