Refined Environment Classifiers: Type- and Scope-safe Code Generation with Mutable Cells
Refined Environment Classifiers: Type- and Scope-safe Code Generation with Mutable Cells
复制标题
细化环境分类器:使用可变单元生成类型和范围安全的代码
DOI:
10.1007/978-3-319-47958-3_15
复制
发表时间:
2016
期刊:
影响因子:
--
通讯作者:
Yuto Sudo
中科院分区:
文献类型:
--
作者:
Oleg Kiselyov;Yukiyoshi Kameyama;Yuto Sudo
Generating high-performance code and applying typical optimizations within the bodies of loops and functions involves moving or storing open code for later use, often in a different binding environment. There are ample opportunities for variables being left unbound or accidentally captured. It has been a tough challenge to statically ensure that by construction the generated code is nevertheless well-typed andwell-scoped: all free variables in manipulated and stored code fragments shall eventually be bound, by their intended binders.We present the calculus for code generation with mutable state that for the first time achieves type-safety and hygiene without ad hoc restrictions. The calculus strongly resembles region-based memory management, but with the orders of magnitude simpler proofs. It employs the rightly abstract representation for free variables, which, like hypothesis in natural deduction, are free from the bureaucracy of syntax imposed by the type environment or numbering conventions.Although the calculus was designed for the sake of formalization and is deliberately bare-bone, it turns out easily implementable and not too bothersome for writing realistic program.