Metaprogramming enables the generation of performant code, while gradual typing facilitates the smooth migration from untyped scripts to robust statically typed programs. However, combining these features with imperative state - specifically mutable references - reintroduces the classic peril of scope extrusion, where code fragments containing free variables escape their defining lexical context. While static type systems utilizing environment classifiers have successfully tamed this interaction, enforcing these invariants in a gradual language remains an open challenge. This paper presents $λ^{α,\star}_{\text{Ref}}$, the first gradual metaprogramming language that supports mutable references while guaranteeing scope safety. To put $λ^{α,\star}_{\text{Ref}}$ on a firm foundation, we also develop its statically typed sister language, $λ^α_{\text{Ref}}$, that introduces unrestricted subtyping for environment classifiers. Our key innovation, however, is the dynamic enforcement of the environment classifier discipline in $λ^{α,\star}_{\text{Ref}}$, enabling the language to mediate between statically verified scopes and dynamically verified scopes. The dynamic enforcement is carried out in a novel cast calculus $\mathrm{CC}^{α,\star}_{\text{Ref}}$ that uses an extension of Henglein's Coercion Calculus to handle code types, classifier polymorphism, and subtype constraints. We prove that $λ^{α,\star}_{\text{Ref}}$ satisfies type safety and scope safety. Finally, we provide a space-efficient implementation strategy for the dynamic scope checks, ensuring that the runtime overhead remains practical.


翻译:暂无翻译

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
Meta-Transformer:多模态学习的统一框架
专知会员服务
59+阅读 · 2023年7月21日
【元图(Meta-Graph):元学习小样本连接预测】
专知会员服务
65+阅读 · 2020年5月31日
元学习(meta learning) 最新进展综述论文
专知会员服务
281+阅读 · 2020年5月8日
元学习(Meta Learning)最全论文、视频、书籍资源整理
深度学习与NLP
22+阅读 · 2019年6月20日
Hierarchically Structured Meta-learning
CreateAMind
27+阅读 · 2019年5月22日
元学习(Meta-Learning) 综述及五篇顶会论文推荐
强化学习的Unsupervised Meta-Learning
CreateAMind
18+阅读 · 2019年1月7日
Unsupervised Learning via Meta-Learning
CreateAMind
44+阅读 · 2019年1月3日
meta learning 17年:MAML SNAIL
CreateAMind
11+阅读 · 2019年1月2日
国家自然科学基金
2+阅读 · 2017年12月31日
国家自然科学基金
9+阅读 · 2017年12月31日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
Arxiv
37+阅读 · 2021年9月28日
Arxiv
13+阅读 · 2020年4月12日
Arxiv
14+阅读 · 2019年9月11日
Meta-Learning with Implicit Gradients
Arxiv
13+阅读 · 2019年9月10日
Arxiv
136+阅读 · 2018年10月8日
VIP会员
相关VIP内容
Meta-Transformer:多模态学习的统一框架
专知会员服务
59+阅读 · 2023年7月21日
【元图(Meta-Graph):元学习小样本连接预测】
专知会员服务
65+阅读 · 2020年5月31日
元学习(meta learning) 最新进展综述论文
专知会员服务
281+阅读 · 2020年5月8日
相关资讯
元学习(Meta Learning)最全论文、视频、书籍资源整理
深度学习与NLP
22+阅读 · 2019年6月20日
Hierarchically Structured Meta-learning
CreateAMind
27+阅读 · 2019年5月22日
元学习(Meta-Learning) 综述及五篇顶会论文推荐
强化学习的Unsupervised Meta-Learning
CreateAMind
18+阅读 · 2019年1月7日
Unsupervised Learning via Meta-Learning
CreateAMind
44+阅读 · 2019年1月3日
meta learning 17年:MAML SNAIL
CreateAMind
11+阅读 · 2019年1月2日
相关基金
国家自然科学基金
2+阅读 · 2017年12月31日
国家自然科学基金
9+阅读 · 2017年12月31日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员