# Handler, async and surface design comparisons

These comparisons identify technical approaches relevant to the
[handler and async design](../../extensions/handlers-async/) and the
[HoldFast surface grammar](../surface-grammar/). Each claim concerns its cited
proposal, implementation or paper.

## Effect-handler disposal routes

OCaml's `discontinue` resumes at the effect site by raising an exception.
An abandoned continuation can retain its captured resources.
[OCaml effect handlers](https://ocaml.org/manual/5.4/effects.html)

Dynamic Wind pairs a suspend clause that releases resources on capture with a
resume clause that reacquires them. Its resource-safety argument concerns a
paper machine instrumented to close resources. That strategy requires
resources that can be released and reacquired, which excludes a loan still
held by a device or in-flight DMA. HoldFast's handler design requires explicit
[disposal on every relevant exit](../../extensions/handlers-async/#handler-lookup-capture-and-return).
[Dynamic Wind for Effect Handlers](https://pl.cs.uni-tuebingen.de/publications/voigt2025dynamic.pdf)

## Handler scoping and continuation copying

Nearest-handler lookup can route an operation to an unrelated dynamically
enclosing handler. Effekt and Lexa select handlers through lexically scoped
capabilities. Continuation cloning also needs to rebind references into the
copied frames. Virtualizing Continuations uses virtual handler addresses.
HoldFast's candidate design uses delimiter-relative frame references.
[Virtualizing Continuations](https://cs.uwaterloo.ca/~yizhou/papers/multilexa-pldi2026.pdf) ·
[HoldFast handler representation](../../extensions/handlers-async/#handler-lookup-capture-and-return)

Yang and Wu study laws for higher-order scoped operations. Whiting and
Germane's HMCFA provides a control-flow analysis to compare when specializing
handlers.
[Judgmental monadic laws](https://doi.org/10.1145/3776678) ·
[HMCFA](https://doi.org/10.1145/3828703)

## Automatic resource analysis for handlers

RaML+ annotates operations with potential, uses explicit forwarding and
analyzes linearly typed continuations. HoldFast can treat an inferred bound for its
one-shot fragment as a candidate for kernel checking. Multi-shot bounds require
separate composition laws. [Handling Exceptions and Effects with Automatic Resource Analysis](https://arxiv.org/abs/2603.02260)

## Async and await design space

Gray, Krishnamurthi and Crichton compare async systems by eagerness, suspension,
extent, reference strength, destruction, propagation and cancellation behavior.
They test a Redex model against language runtimes with generated programs. HoldFast's
[structured async design](../../extensions/handlers-async/#frames-child-ownership-and-reaction-execution)
uses these dimensions to state its own lifecycle and resource rules.
[A Design Space Exploration of Async/Await](https://arxiv.org/html/2608.20677v1)

## Structured-concurrency runtimes

| System | Relevant behavior in the cited design |
| --- | --- |
| Java | Closing a structured scope waits for subtasks. A subtask that fails to respond to interruption can delay closing indefinitely. [JEP 533](https://openjdk.org/jeps/533) |
| Python | `TaskGroup` cancels siblings on failure, waits for them and aggregates non-cancellation exceptions, with special handling for `KeyboardInterrupt` and `SystemExit`. [`asyncio.TaskGroup`](https://docs.python.org/3/library/asyncio-task.html) |
| Swift | A cancellation shield delays observation of cancellation within a lexical block. An awaited `defer` runs before leaving its scope. [Cancellation shields](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0504-task-cancellation-shields.md) · [Awaited `defer`](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0493-defer-async.md) |
| Kotlin | Prompt cancellation can supersede a ready result. A resource in that result needs an explicit cancellation handler. [Prompt cancellation](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/suspend-cancellable-coroutine.html) |
| C++ | Execution distinguishes stopped, value and error completions. An unjoined used `simple_counting_scope` terminates on destruction. [Scope specification](https://eel.is/c++draft/exec.scope) · [Spawn proposal](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3149r11.html) |
| Rust | The async roadmap describes immovable types and guaranteed destructors as prerequisites for scoped spawn and async drop. [Move-trait project goal](https://goals.rust-lang.org/2026/move-trait.html) |

HoldFast's [cancellation contract](../../extensions/handlers-async/#cancellation-commit-and-all-exits)
requires accounting for ready results and bounded cancellation. The
[frame rules](../../extensions/handlers-async/#frames-child-ownership-and-reaction-execution)
assign static storage and track each child's exit resources.

## C# unions and Swift spans

C#'s proposed type union `union Pet(Cat, Dog, Bird)` wraps existing case types
and boxes value-type cases. HoldFast uses [nominal tagged unions](../reference/#declarations)
with explicit cases and exhaustive matching.
[C# union proposal](https://devblogs.microsoft.com/dotnet/csharp-15-union-types/)

Swift's `Span` is a copyable shared view and `MutableSpan` is a noncopyable
exclusive view. The source lifetime bounds both views.
[Swift `MutableSpan`](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0467-MutableSpan.md)

Hylo uses projection subscripts with `let`, `inout`, `set`, and `sink` to
support in-place mutation. OxCaml infers mode information such as locality,
uniqueness, and contention. Its mode-crossing rules include deeply immutable
types.
[Hylo mutable value semantics](https://doi.org/10.5381/jot.2022.21.2.a2) ·
[OxCaml modal axes](https://doi.org/10.1145/3704859) ·
[Mode Crossing](https://doi.org/10.1145/3828681)

HoldFast exposes `in`, `ref`, `out`, and `move` at call sites. Its design
combines place-named lifetimes and two-phase receiver loans with functional
and resource proofs. Values that cross ownership modes require checked laws.
[Loan modes](../reference/#loans-and-parameter-modes) ·
[Mode-crossing qualification](../../extensions/graded-foundation/#inference-specialization-and-admission)
