OperatorFunc
@defgroup operator_registry Operator Registry @brief Extensible operator registration and dispatch system
The Operator Registry is the key to WAL++'s extensibility. It allows both C++ and Python code to register new operators dynamically.
Operator Registration Model:
@mermaid
graph TD
A["OperatorRegistry"] -->|register| B["Operator Map"]
B --> C["Built-in
50+ ops"]
B --> D["Python
Operators"]
B --> E["User
Custom"]
C --> F["Math"]
C --> G["List Ops"]
C --> H["Waveform"]
D --> I["PyO3 Bridge"]
E --> J["Closures"]
@endmermaid
Key Features: - Dynamic registration (add operators at runtime) - Unified dispatch (same call for all operator types) - Unevaluated arguments (allows special forms) - Easy Python integration via PyO3
Operator Categories: - Math: +, -, *, /, **, % - Bitwise: band, bor, bxor, lshift, rshift - List: car, cdr, cons, length, list - Array: arange, array, extend - Waveform: signal, signal-names, load, step - Type: type, is?, ... - Control: if, while, for, let - Definition: define, lambda, macro - Special: quote, unquote, eval
- See
- "Evaluator" for usage
- See
- "Core API" for public interface
@{ Function signature for all WAL operators
All operators in WAL share this signature:
Parameters:
- evaluator: Reference to evaluator (for recursive eval, environment access)
- args: Unevaluated argument expressions
Return: The computed result value
Unevaluated Arguments: Operators receive arguments unevaluated. This is crucial for: - Special forms (if, define, lambda) that need control flow - Lazy evaluation patterns - Quoting and metaprogramming
Regular operators typically evaluate arguments first:
Special forms skip evaluation:
- See
- SEval::dispatch_builtin for operator lookup
- See
- SEval::eval_args for argument evaluation helper