- Add string concatenation support to + operator in typechecker - Register ADT constructors in both type environment and interpreter - Bind handlers as values so they can be referenced in run...with - Fix effect checking to use subset instead of exact match - Add built-in effects (Console, Fail, State) to run block contexts - Suppress dead code warnings in diagnostics, modules, parser Update all example programs with: - Expected output documented in comments - Proper run...with statements to execute code Add new example programs: - behavioral.lux: pure, idempotent, deterministic, commutative functions - pipelines.lux: pipe operator demonstrations - statemachine.lux: ADT-based state machines - tailcall.lux: tail call optimization examples - traits.lux: type classes and pattern matching Add documentation: - docs/IMPLEMENTATION_PLAN.md: feature roadmap and status - docs/PERFORMANCE_AND_TRADEOFFS.md: performance analysis Add benchmarks for performance testing. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
21 lines
552 B
Plaintext
21 lines
552 B
Plaintext
// Benchmark: Closure creation and calls (measures closure overhead)
|
|
// Tests: Closure capture, higher-order functions
|
|
|
|
fn makeAdder(n: Int): fn(Int): Int =
|
|
fn(x: Int): Int => x + n
|
|
|
|
fn applyN(f: fn(Int): Int, x: Int, n: Int): Int =
|
|
if n <= 0 then x
|
|
else applyN(f, f(x), n - 1)
|
|
|
|
// Create 1000 closures and apply them
|
|
fn benchmark(count: Int): Int =
|
|
if count <= 0 then 0
|
|
else {
|
|
let adder = makeAdder(count)
|
|
let result = applyN(adder, 0, 100)
|
|
result + benchmark(count - 1)
|
|
}
|
|
|
|
let result = benchmark(1000)
|