Stack allocation for OCaml
summary
Adds a modal type extension to OCaml that lets values be allocated on a separate stack when safe, implemented in the compiler and available on GitHub. The system marks bindings as local vs global modes (inferred), allows local returns, and requires no lifetime variables so normal type inference keeps working. Real examples change list iterators to take a local closure and remove per-iteration heap allocations (closure and ref cell), but tail-call restrictions and currying compatibility force code edits in tens of places. The implementation runs and yields measurable allocation reductions.
AI-written summary · about
