First-Order Laziness
summary
Proposes replacing thunk closures with lazy constructors that are defunctionalized first‑order values, implemented in Koka; evaluation happens on pattern match via a new lazy match and results use in‑place memorization plus optional in‑place reuse when reference count is one. Benchmarks (heap/queue examples) show traditional laziness can cost up to 5× in Koka, while lazy constructors cut allocations and make append‑heavy streams much faster; debugging and printing improve, but lazy match can expose memoization and break referential transparency.
AI-written summary · about
chapters (17)
- 0:00First-order laziness intro
- 2:49Higher-order laziness problems
- 4:15Defunctionalizing laziness
- 7:25Lazy constructors in practice
- 9:29Benefits of lazy constructors
- 11:56Compiling in Koka
- 13:18In-place memorization
- 15:25Reuse vs memorization
- 17:13Benchmarking performance
- 19:01Key ideas and conclusion
- 19:32Q&A: Whole-program vs user control
- 20:37Q&A: Modularity costs
- 21:40Q&A: Lazy fields in OOP
- 22:44Q&A: Code data connections
- 23:45Q&A: Defining lazy functions
- 24:53Q&A: Impact on semantics
- 26:21Q&A: Non-termination in constructors
