Module Generation without Regret
Module Generation without Regret
复制标题
无悔模块生成
DOI:
10.1145/3372884.3373160
复制
发表时间:
2020
期刊:
影响因子:
--
通讯作者:
Takahisa Watanabe
中科院分区:
文献类型:
--
作者:
uhi Sato;Yukiyoshi Kameyama;Takahisa Watanabe
Modules are an indispensable mechanism for providing abstraction to programming languages. To reduce the abstraction overhead in the usage of modules, Watanabe et al. proposed a language for generating and manipulating code of modules, and implemented it via a translation to plain MetaOCaml. Unfortunately, their solution has a serious problem of code explosion if functors are repeatedly applied to modules. Another problem in their solution is that it does not allow nested modules.This paper proposes a refined translation for a two-stage typed language with module generation where nested modules are allowed. Our translation does not suffer from the code-duplication problem. The key idea is to use the genlet operator in latest MetaOCaml, which performs let insertion at the code-generation time to allow sharing of code fragments. To our knowledge, our work is the first to apply genlet to code generation for modules. We conduct an experiment using a microbenchmark, and the result shows that our method is effective to reduce the size of generated code that would have been exponentially large.