paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Typestate via Revocable Capabilities

通过可撤销能力(Capabilities)实现 Typestate
PLDI 10(PLDI)2026匹配度 2/10 · 论文属于类型系统与语言设计中的 typestate/capability 机制,和用户当前关注的 PL 与 LLM/Agent 交叉、浮点程序分析、贝叶斯程序分析均无直接关系;虽属 PL 领域且有 Scala 3 编译器实现,但不落在核心研究问题上。引用 0 inbox
Songlin Jia, Craig Liu, Siyuan He, Haotian Deng, Yuyan Bao, Tiark Rompf
crossref: 2026-09-10

AI 速览

一句话:将流不敏感的 capability 机制扩展为流敏感,解耦能力生命周期与词法作用域,实现安全且表达力强的 typestate 编程。

在存在别名的情况下,安全且有表达力地管理有状态资源是编程语言的长期难题。作用域式构造(如 Java 的 synchronized 块)易于推理,却限制了表达力与并行性;命令式、流敏感的方法提供细粒度控制,但需要复杂的 typestate 分析,并迫使程序员显式跟踪状态。本文提出一种统一二者优点的方案:将传统的流不敏感 capability 机制扩展到流敏感场景,把能力生命周期与词法作用域解耦,使函数能够以流敏感方式接收、撤销或返回能力,并复用已有作用域能力机制来保证安全性与易用性。作者在 Scala 3 编译器中实现该扩展,借助路径依赖类型与隐式解析支持简洁、静态安全且富有表达力的 typestate 编程。原型可通用地支持文件操作、高级锁协议、DOM 构造与会话类型等多种模式,表明在已有 capability 支持的语言上仅需最小扩展即可实现表达力强且安全的 typestate 管理。

问题
有状态资源的安全管理在别名存在时难以兼顾易推理与表达力:作用域式构造限制表达力与并行性,命令式流敏感方法则需复杂分析并加重程序员显式跟踪状态的负担。
方法
将流不敏感的 capability 机制扩展为流敏感,使能力生命周期与词法作用域解耦,允许函数以流敏感方式接收、撤销与返回能力,并在 Scala 3 编译器中利用路径依赖类型与隐式解析实现该扩展。
评估
以 Scala 3 编译器扩展为原型,展示其通用支持文件操作、高级锁协议、DOM 构造与会话类型等多种模式,验证了最小语言扩展即可获得安全且富有表达力的 typestate 管理。
原文摘要(Abstract)

Managing stateful resources safely and expressively is a longstanding challenge in programming languages, especially in the presence of aliasing. For example, scope-based constructs like Java’s synchronized blocks offer ease of reasoning, but they restrict expressiveness and parallelism. Conversely, imperative, flow-sensitive approaches enable fine-grained control, but they require sophisticated typestate analyses and often burden programmers with explicit state tracking. In this work, we present a novel approach that unifies the ease of scoped reasoning with the expressiveness of imperative typestate management. Our design extends traditional flow-insensitive capability mechanisms to a flow-sensitive setting. In particular, we decouple capability lifetimes from lexical scopes, allowing functions to receive, revoke, or return capabilities in a flow-sensitive manner, building on existing mechanisms for the safety and ergonomics of scoped capability programming. We implement our approach as an extension to the Scala 3 compiler, leveraging path-dependent types and implicit resolution to enable concise, statically safe, and expressive typestate programming. Our prototype generically supports a wide range of patterns, including file operations, advanced locking protocols, DOM construction, and session types, showing that expressive and safe typestate management can be achieved with minimal extensions to an existing language with capability support.

链接与引用

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

BibTeX
@article{paperbot3765,
  title = {Typestate via Revocable Capabilities},
  author = {Songlin Jia and Craig Liu and Siyuan He and Haotian Deng and Yuyan Bao and Tiark Rompf},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {10},
  number = {PLDI},
  year = {2026},
  doi = {10.1145/3808323}
}