Managing stateful resources safely and expressively is a longstanding challenge in programming languages, especially in the presence of aliasing. While scope-based constructs such as Java's synchronized blocks offer ease of reasoning, they restrict expressiveness and parallelism. Conversely, imperative, flow-sensitive management enables fine-grained control but demands sophisticated typestate analyses and often burdens programmers with explicit state tracking. In this work, we present a novel approach that unifies the strengths of both paradigms by extending flow-insensitive capability mechanisms into flow-sensitive typestate tracking. Our system decouples capability lifetimes from lexical scopes, allowing functions to provide, revoke, and return capabilities in a flow-sensitive manner, based on the existing mechanisms explored 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 stateful patterns, including file operations, advanced locking protocols, DOM construction, and session types. This work demonstrates that expressive and safe typestate management can be achieved with minimal extensions to existing capability-based languages, paving the way for more robust and ergonomic stateful programming.


翻译:安全且富有表现力地管理有状态资源是编程语言中长期存在的挑战,尤其是在存在别名的情况下。虽然基于作用域的构造(如Java的同步块)提供了易于推理的特性,但它们限制了表达能力和并行性。相反,命令式的、流敏感的管理实现了细粒度控制,但需要复杂的类型状态分析,并且常常使程序员承担显式状态跟踪的负担。在这项工作中,我们提出了一种新颖的方法,通过将流不敏感的能力机制扩展为流敏感的类型状态跟踪,统一了两种范式的优势。我们的系统将能力生命周期与词法作用域解耦,允许函数以流敏感的方式提供、撤销和返回能力,这基于已探索的、用于提升作用域能力编程安全性和人体工程学的现有机制。我们将我们的方法实现为Scala 3编译器的扩展,利用路径依赖类型和隐式解析,以实现简洁、静态安全且富有表现力的类型状态编程。我们的原型通用地支持广泛的有状态模式,包括文件操作、高级锁定协议、DOM构造和会话类型。这项工作表明,通过对现有基于能力的语言进行最小扩展,即可实现富有表现力且安全的类型状态管理,为更健壮和符合人体工程学的有状态编程铺平了道路。

0
下载
关闭预览

相关内容

iOS 8 提供的应用间和应用跟系统的功能交互特性。
  • Today (iOS and OS X): widgets for the Today view of Notification Center
  • Share (iOS and OS X): post content to web services or share content with others
  • Actions (iOS and OS X): app extensions to view or manipulate inside another app
  • Photo Editing (iOS): edit a photo or video in Apple's Photos app with extensions from a third-party apps
  • Finder Sync (OS X): remote file storage in the Finder with support for Finder content annotation
  • Storage Provider (iOS): an interface between files inside an app and other apps on a user's device
  • Custom Keyboard (iOS): system-wide alternative keyboards

Source: iOS 8 Extensions: Apple’s Plan for a Powerful App Ecosystem
FlowQA: Grasping Flow in History for Conversational Machine Comprehension
专知会员服务
34+阅读 · 2019年10月18日
Stabilizing Transformers for Reinforcement Learning
专知会员服务
60+阅读 · 2019年10月17日
Keras François Chollet 《Deep Learning with Python 》, 386页pdf
专知会员服务
163+阅读 · 2019年10月12日
Hierarchically Structured Meta-learning
CreateAMind
27+阅读 · 2019年5月22日
Unsupervised Learning via Meta-Learning
CreateAMind
44+阅读 · 2019年1月3日
meta learning 17年:MAML SNAIL
CreateAMind
11+阅读 · 2019年1月2日
STRCF for Visual Object Tracking
统计学习与视觉计算组
15+阅读 · 2018年5月29日
Focal Loss for Dense Object Detection
统计学习与视觉计算组
12+阅读 · 2018年3月15日
国家自然科学基金
13+阅读 · 2017年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
Arxiv
29+阅读 · 2023年1月12日
An Overview on Machine Translation Evaluation
Arxiv
14+阅读 · 2022年2月22日
Arxiv
11+阅读 · 2019年4月15日
Arxiv
31+阅读 · 2018年11月13日
Exploring Visual Relationship for Image Captioning
Arxiv
15+阅读 · 2018年9月19日
VIP会员
相关VIP内容
相关资讯
Hierarchically Structured Meta-learning
CreateAMind
27+阅读 · 2019年5月22日
Unsupervised Learning via Meta-Learning
CreateAMind
44+阅读 · 2019年1月3日
meta learning 17年:MAML SNAIL
CreateAMind
11+阅读 · 2019年1月2日
STRCF for Visual Object Tracking
统计学习与视觉计算组
15+阅读 · 2018年5月29日
Focal Loss for Dense Object Detection
统计学习与视觉计算组
12+阅读 · 2018年3月15日
相关论文
Arxiv
29+阅读 · 2023年1月12日
An Overview on Machine Translation Evaluation
Arxiv
14+阅读 · 2022年2月22日
Arxiv
11+阅读 · 2019年4月15日
Arxiv
31+阅读 · 2018年11月13日
Exploring Visual Relationship for Image Captioning
Arxiv
15+阅读 · 2018年9月19日
相关基金
国家自然科学基金
13+阅读 · 2017年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员