paperbot · PL 论文追踪

全部论文 待读 收藏

P2 First-Order Laziness

一阶惰性
ICFP 9(ICFP)2025匹配度 2/10 · 该论文属于函数式语言设计与实现,讨论惰性数据结构与去功能化,虽属 PL 领域,但与用户核心方向(ML/Agent 程序的静态分析、LLM 辅助形式化验证、浮点程序分析、贝叶斯程序分析)无直接交集;不涉及 LLM、Agent 或静态分析/验证。引用 1 inbox
Anton Lorenzen, Daan Leijen, Wouter Swierstra, Sam Lindley
crossref: 2026-09-10

AI 速览

一句话:提出一阶惰性构造子,将惰性数据结构中的 thunk 去功能化,从而提升性能并便于调试。

在严格语言中,惰性求值通常用显式 thunk 模拟:闭包延迟计算并记忆结果。但闭包实现的 thunk 难以打印和调试,需要额外内存分配,有时性能较差,且性能推理非常微妙,阻碍了惰性数据结构的广泛使用。本文提出 lazy constructors(惰性构造子),作为 lazy thunks 的简单一阶替代。其核心思想是让惰性数据结构中的 thunk 去功能化(defunctionalized),用数据构造子而非闭包表示未求值计算。这样得到的实现不仅显著快于传统 thunk,还能被轻松检查和打印,便于调试。论文展示了该机制如何用于实现惰性数据结构,并比较其性能与可观察性。

问题
严格语言中用闭包 thunk 实现惰性数据结构会导致调试困难、内存开销大、性能可能低下且性能推理复杂。
方法
提出 lazy constructors,将惰性数据结构中的 thunk 去功能化为简单的一阶数据构造子,替代闭包编码。
评估
通过实现惰性数据结构并与传统 thunk 实现进行对比,表明新方法显著更快且更易于检查与调试。
原文摘要(Abstract)

In strict languages, laziness is typically modeled with explicit thunks that defer a computation until needed and memoize the result. Such thunks are implemented using a closure. Implementing lazy data structures using thunks thus has several disadvantages: closures cannot be printed or inspected during debugging; allocating closures requires additional memory, sometimes leading to poor performance; reasoning about the performance of such lazy data structures is notoriously subtle. These complications prevent wider adoption of lazy data structures, even in settings where they should shine. In this paper, we introduce lazy constructors as a simple first-order alternative to lazy thunks. Lazy constructors enable the thunks of a lazy data structure to be defunctionalized, yielding implementations of lazy data structures that are not only significantly faster but can easily be inspected for debugging.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot3040,
  title = {First-Order Laziness},
  author = {Anton Lorenzen and Daan Leijen and Wouter Swierstra and Sam Lindley},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {9},
  number = {ICFP},
  year = {2025},
  doi = {10.1145/3747530}
}