Module Generation without Regret

Module Generation without Regret
复制标题

无悔模块生成

DOI:
10.1145/3372884.3373160
复制
发表时间:
2020
期刊:
Proc. of ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation
影响因子:
--
通讯作者:
Takahisa Watanabe
Takahisa Watanabe
中科院分区:
--
文献类型:
--
作者:
uhi Sato;Yukiyoshi Kameyama;Takahisa Watanabe

文献摘要

相似文献

模块是为编程语言提供抽象的不可或缺的机制。为了减少使用模块时的抽象开销,Watanabe 等人。提出了一种用于生成和操作模块代码的语言,并通过翻译为普通 MetaOCaml 来实现它。不幸的是,如果函子被重复应用于模块,他们的解决方案会存在严重的代码爆炸问题。他们的解决方案中的另一个问题是它不允许嵌套模块。本文提出了一种两阶段类型语言的改进翻译,其中允许嵌套模块,并具有模块生成功能。我们的翻译不会遇到代码重复问题。关键思想是使用最新 MetaOCaml 中的 genlet 运算符,它在代码生成时执行 let 插入以允许共享代码片段。据我们所知,我们的工作是第一个将 genlet 应用于模块代码生成的工作。我们使用微基准进行了实验,结果表明我们的方法可以有效地减少本来呈指数级增长的生成代码的大小。
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.