Expand description
§Closure expression parsing and invocation.
This module provides parsing and evaluation support for closure expressions in the AIMX language.
Closures are anonymous functions that can capture variables from their surrounding scope and are
denoted by the => operator.
§Syntax
AIMX supports two forms of closures:
- Single parameter:
param => expression - Double parameter:
(param1, param2) => expression
Closures are first-class values that can be stored in variables, passed as arguments to functions, and returned from functions.
§Examples
// Simple closure with single parameter
x => x * 2
// Closure with two parameters
(x, y) => x + y
// Using closures with array operations
nums.filter(x => x > 5)
nums.map((item, index) => item * index)Enums§
- Closure
- Represents a closure (anonymous function) expression in the AIMX language.
Functions§
- parse_
closure - Parses a closure expression from the input string.
- parse_
closure_ conditional - Parses a closure that falls back to conditional expression parsing.