Episode 418 minutes

Loop-Fused Lambdas & First-Class Closures

Explore zero-allocation loop-fused List<T> pipelines and v0.13 first-class closures with safe read-only value capture.

Lesson Video Coming Soon

This episode's HD lesson video will appear directly in this player once published. Meanwhile, run and modify the live HADID v0.13 code lab right below!

Learning Objectives

  • Chain .filter().map().order_by_desc().take().sum() pipelines
  • Store, pass, and return first-class fn(A): R closures
  • Understand HADID's safe read-only capture guarantee

Architecture Summary

HADID fuses List<T> chains like .filter().map().take().sum() into a single C17 `for` loop with zero intermediate allocations. In v0.13, first-class closures (fn(A): R) can also be stored in variables, passed to higher-order functions, and returned from factories with arena-safe value capture.

Live HADID v0.13 Code Lab

LIVE COMPILER

Episode 4 · Interactive Lab

Live Native C17 · v0.13.0
main.had

Run with Ctrl / ⌘ + Enter

Executes on the real HADID v0.13.0 Linux compiler inside a network-isolated container (async/await, closures, Generic fn<T> + where, Query<T>, loop-fused lambdas, html_render, crypto, SQLite :memory:, and full EN/TR syntax). Use the local `hadid` CLI for disk SQLite, live WebSocket/HTTP servers, and native AOT binaries.

Sign in with Digital HAT ID to earn Code Lab (+25 XP), Quiz (+50 XP), badges, and certificates.Sign In

Knowledge Check

1. What happens if a HADID closure tries to mutate a captured outer variable?