Skip to content

← All updates

session

Resumable effect handlers, structured concurrency, graph-coloring regalloc

The concurrency and effects story is complete at the language level. Everything below is in main and covered by tests (test_effect_resume, test_effect_noresume, test_effect_compose, test_spawn_scope, test_cancellation).

Effect handlers with continuations

  • resume(cont, value): a handler arm can now continue the handle block from the point of the do, with value as the result of the effect. New keyword, AST node, parser, type checker, and lowering.
  • Continuation capture at lowering time: the statements after a do are captured as a continuation closure (lambda-lifted, called through CallPtr), so there is no runtime scheduler and no hidden allocation behind an effect.
  • No resume means no continuation: a handler that returns without resume drops the rest of the block, which gives cooperative cancellation for free.
  • Chaining: multiple do statements in one block each capture their own continuation; nested handlers resolve at the nearest enclosing handle.

Structured concurrency and cancellation

  • spawn scope { … }: a scope-owned executor runs every spawn inside the block and joins them all at the closing brace. Tasks cannot outlive their scope.
  • cancel scope;: cancels all pending tasks in the enclosing scope, backed by the new p_executor_cancel runtime builtin.
  • do Cancel.stop(): cooperative cancellation through effect dispatch.
  • No function coloring, verified: any function is callable from synchronous code, a spawned task, or a handler body; there is no async fn / fn split to maintain.

Async I/O as effects

  • do IO.read / do IO.write and do Net.accept dispatch to handlers and resume with the result. A request handler reads as straight-line code even though every I/O point is a suspension.

Compiler and backends

  • Graph-coloring register allocator (Chaitin-Briggs) added alongside linear scan, with function alignment for the native backends.
  • Deterministic PE code generation: the Windows emitter now produces identical bytes for identical input, build after build.
  • Cached parsing: repeated compiles of unchanged modules skip the parser.
  • Struct globals in the C backend: initialized correctly as inline values.

Standard library

  • 104 modules. New since 1.0: arena (bump allocator with O(1) bulk free), template (typed template rendering), plot (SVG line/bar/scatter plots), data (CSV loading and schema inference), and game (an ECS-plus-frame-arena engine framework in which Fid is its own scripting language).