Capture Checking in Scala

43 nrinaudo 2 8/25/2025, 5:22:15 AM nrinaudo.github.io ↗

Comments (2)

noelwelsh · 1h ago
Nice article. It reminds me of another post a little while ago about OCaml. Like OCaml, Scala is getting more systems programming capabilities. Capture checking can, for example, be used to implement safe memory arenas (aka slab allocation or memory pools.) If you can prove that no code has captured anything from the arena, you can prove it is safe to deallocate the arena. This is less fine-grained than Rust's approach, but I think it is much more usable. I think of it as similiar to Zig's approach but with safety guarantees.

The other part, doing away with monads, is also exciting for FP nerds like me, but probably less generally exciting as it doesn't add new capabilities to the language so much as make existing capabilities easier to use (puns intended, of course!)

brabel · 1h ago
Flix has regions which also restrict the scope of certain values. Seems like a similar concept. And D has “scope” and “return scope” to describe when variables are intended to not escape (unless returned in the latter case).