一句话:提出一种新的中间语言,将调用约定编码在类型的 Kind 中,从而兼顾灵活多态与高效静态编译。
支持多态的语言让程序员可以一次表达复杂想法并在多种场景复用函数,但多态也给编译器带来挑战:要在多态代码中高效操作具体值并不容易。本文提出一种新的中间语言,在支持灵活多态的同时实现高效静态编译。其多态不仅覆盖值的类型,还覆盖值的表示、原语机器函数的元数以及参数的求值顺序,这三者在实际编译中都很重要。核心思想是把关于值调用约定的信息编码到其类型的 Kind 中,而不是编码在类型本身中。这样,编译器可以在 Kind 层面获知表示、元数与求值顺序等编译所需信息,从而生成高效代码。摘要未给出具体实验评估。
A language supporting polymorphism is a boon to programmers: they can express complex ideas once and reuse functions in a variety of situations. However, polymorphism is pain for compilers tasked with producing efficient code that manipulates concrete values. This paper presents a new intermediate language that allows for efficient static compilation, while still supporting flexible polymorphism. Specifically, it permits polymorphism over not only the types of values, but also the representation of values, the arity of primitive machine functions, and the evaluation order of arguments---all three of which are useful in practice. The key insight is to encode information about a value's calling convention in the kind of its type, rather than in the type itself.
@article{DownenAJE20,
title = {Kinds are calling conventions},
author = {Paul Downen and Zena M. Ariola and Simon Peyton Jones and Richard A. Eisenberg},
journal = {Proceedings of the ACM on Programming Languages},
volume = {4},
number = {ICFP},
year = {2020},
doi = {10.1145/3408986}
}