Skip to content

WAL++ API Documentation

fast_vcd
wal

Types

Name Description
Value @defgroup AST Abstract Syntax Tree (AST) Types @brief Core value types and AST node classes for WAL The AST module provides the fundamental data structures used throughout WAL++: - Value: The universal type representing all possible WAL values - Symbol: Represents variable/signal identifiers - WList: Lisp-like homogeneous lists - Closure: First-class function objects (lambda) - Macro: Macro definitions for metaprogramming - Environment: Variable binding scope chains See : "Evaluator" for how these values are processed See : "Operator Registry" for extensibility @{ Architecture of WAL Value System @mermaid graph TD A["Value
(std::variant)"] --> B["Scalars"] A --> C["Collections"] A --> D["Functions"] A --> E["Environment"] B --> B1["nil"] B --> B2["bool"] B --> B3["int64_t"] B --> B4["double"] B --> B5["string"] C --> C1["Symbol"] C --> C2["WList"] D --> D1["Closure
lambda"] D --> D2["Macro"] D --> D3["UserOperator"] E --> E1["Environment
scope chain"] @endmermaid Universal value type for WAL expressions Represents all possible values in WAL expressions using std::variant for type safety. This replaces Python's dynamic typing with C++'s type-safe alternative. Type Categories: - Atomic: nil, bool, int64_t, double, string - Symbolic: Symbol (with scope/group tracking) - Collections: WList (heterogeneous lisp lists) - Functions: Closure (lambda), Macro, UserOperator - Context: Environment (scope chains) See : Symbol See : WList See : Closure See : Environment
Symbol @} Represents a variable or signal identifier with optional scope and group information Symbols are the basic building blocks for identifiers in WAL.
WList Heterogeneous list container inheriting from std::vector WList provides Lisp-like list semantics with: - Arbitrary element types (elements are Values) - First-class list objects - Sequence operations (car, cdr, cons, length) Lists form the structure of WAL S-expressions: - Function calls: (+ 1 2) → WList{Symbol("+"), 1, 2} - Data structures: (list 1 2 3) → WList{1, 2, 3} - Nested forms: (func (nested 1 2) 3) → WList with nested WList See : Value::is_list See : SEval::eval for list evaluation
WArray @brief Upstream WAL's array: a string-keyed, insertion-ordered map. Upstream represents an array as a Python dict, so it is NOT a vector: keys are arbitrary (ints, floats, strings and symbols are all stringified on the way in, which is why (seta a 0 "foo") and (geta a "0") name the same slot), and the value is a mutable reference, so (seta a ...) is visible through every binding that holds the same array.
Closure Lambda (anonymous) function object with captured environment Closures implement first-class functions in WAL: - Capture a lexical environment at definition time - Store parameter list (args) - Store function body (expression) - Support recursive self-reference via name Evaluation: - Parameters bound to arguments in captured environment - Body evaluated with new bindings - Returns the body's evaluation result (lambda (x y) (+ x y)) ↓ Closure { environment: <current>, args: (x y), expression: (+ x y), name: "lambda" } See : Environment for scope chains See : SEval::eval_closure
Macro Lisp-style macro for code generation and metaprogramming Macros allow compile-time code transformation: - Similar structure to Closure (captured environment, args, body) - Arguments are NOT evaluated before passing to macro - Macro body must return code (a Value) - Returned code is then evaluated by the evaluator This enables DSL creation, special control flow, and code generation. Unlike Closure: - Arguments passed unevaluated (like special forms) - Return value must be quoted/unquoted correctly - Used for syntax transformation See : Closure for comparison See : Value for result type
UserOperator Reference to a user-defined operator Allows WAL programs to reference operators defined in Python or other modules.
Environment Variable binding context with lexical scope chain Environments form chains for lexical scoping: @mermaid graph LR A["Global Env
parent: nullptr"] --> B["Outer Scope
parent: Global"] B --> C["Inner Scope
parent: Outer"] C --> D["Innermost
parent: Inner"] @endmermaid Variable Lookup (lexical scoping): - Check local bindings first - Follow parent chain to global scope - Throws EvalError if not found Variable Definition: - Always local to current environment - Does not shadow parent bindings - Use write to modify parent-defined variables Enables: - Closures with captured environments - Function parameter bindings - Local variable scopes - Proper recursion support See : Closure for environment capture See : SEval for scope management