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.


翻译:安全且富有表现力地管理有状态资源是编程语言领域的一个长期挑战,尤其是在存在别名的情况下。例如,像Java的同步块这样基于作用域的构造简化了推理,但限制了表达能力和并行性。相反,命令式、流敏感的方法实现了细粒度控制,但需要复杂的类型状态分析,并且常常给程序员带来显式状态追踪的负担。在这项工作中,我们提出了一种新颖的方法,统一了作用域推理的简便性与命令式类型状态管理的表达能力。我们的设计将传统的流不敏感能力机制扩展到流敏感环境。具体而言,我们将能力的生命周期与词法作用域解耦,允许函数以流敏感的方式接收、撤销或返回能力,并建立在现有用于作用域能力编程的安全性与人体工程学机制之上。我们将该方法实现为Scala 3编译器的扩展,利用路径依赖类型和隐式解析来实现简洁、静态安全且富有表现力的类型状态编程。我们的原型泛型支持多种模式,包括文件操作、高级锁定协议、DOM构建和会话类型,表明通过最小扩展现有支持能力的语言,即可实现富有表现力且安全的类型状态管理。

0
下载
关闭预览

相关内容

软件工程评估(Evaluation and Assessment in Software Engineering,EASE)会议是一个国际领先的会议场所,学术界和实践者可以在此展示和讨论他们对基于证据的软件工程的研究及其对软件实践的影响。第23届EASE将于2019年4月在丹麦哥本哈根举行,由哥本哈根IT大学主办。EASE 2019欢迎向不同领域提交高质量的研究报告:完整的研究论文、短篇论文和手工艺品、新兴成果和愿景、行业轨迹、博士研讨会、海报。官网链接:https://ease2019.org/
大型语言模型系统中提示缺陷的分类学
专知会员服务
8+阅读 · 2025年9月19日
探究模型能力与应用的进展和边界
专知会员服务
26+阅读 · 2025年8月27日
可解释聚类综述
专知会员服务
38+阅读 · 2024年9月8日
大模型报告:模型能力决定下限,场景适配度决定上限
专知会员服务
57+阅读 · 2024年6月3日
【AAAI2021】对比聚类,Contrastive Clustering
专知
26+阅读 · 2021年1月30日
使用 Canal 实现数据异构
性能与架构
20+阅读 · 2019年3月4日
从Seq2seq到Attention模型到Self Attention(一)
量化投资与机器学习
76+阅读 · 2018年10月8日
用模型不确定性理解模型
论智
11+阅读 · 2018年9月5日
【AAAI专题】论文分享:以生物可塑性为核心的类脑脉冲神经网络
中国科学院自动化研究所
15+阅读 · 2018年1月23日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Arxiv
0+阅读 · 6月5日
Arxiv
0+阅读 · 6月1日
VIP会员
最新内容
学习数据的几何:形状空间分析数学综述
专知会员服务
6+阅读 · 6月17日
定向能反无人机系统最新发展动态
专知会员服务
7+阅读 · 6月17日
从燃煤战舰到算法战争:水面指挥的永恒要求
专知会员服务
4+阅读 · 6月17日
相关资讯
相关基金
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员