Skip to content

Value

class 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

Functions

Name Description
is_nil @name Type Checking @{
to_bool @} @name Type Extraction @{
try_as @} @name Safe Type Extraction @{ Safely extract type if value is of type T, returns nullopt otherwise
to_string_repr @} @name Conversions & Comparisons @{
get_variant @} @name Internals @{

Function Details

get_variant

const ValueVariant& get_variant() const

@} @name Internals @{

is_nil

bool is_nil() const

@name Type Checking @{

to_bool

bool to_bool() const

@} @name Type Extraction @{

to_string_repr

std::string to_string_repr() const

@} @name Conversions & Comparisons @{

try_as

template<typename T> std::optional<T> try_as() const

@} @name Safe Type Extraction @{ Safely extract type if value is of type T, returns nullopt otherwise