详细说明求值顺序多态性
Elaborating Evaluation-Order Polymorphism
摘要:
我们根据求值顺序对程序设计语言进行分类:每种语言都将一种求值顺序固定为默认值,使其对该求值顺序的程序透明,而对另一种求值顺序的程序则很麻烦。本文开发了一个在评价顺序方面公正的类型系统。计算顺序在术语中是隐式的,在类型中是显式的,具有类型连接词的按值和按名称版本。交集类型的一种形式量化求值顺序,描述对求值顺序不可知(即多态)的代码。通过允许这样的通用代码,程序可以在没有代码重复的情况下表达计算的按值和按名称版本。我们还制定了一个类型系统,只有按值连接词,加上一个类型,概括了按值和按名称连接词之间的差异:它要么是一个暂停(按名称)或“无操作”(按值)。我们展示了一个简单的编码的公正类型系统到更经济的一个。然后,我们定义了一个详细的经济语言的调用的值的语义,并证明了详细的良好类型的源程序,其中的评估顺序是隐式的,产生一个良好类型的目标程序的评估顺序是显式的。我们还证明了目标程序的评估和减少(无论是按值或按名称)在源程序之间的模拟。最后,我们证明了类型,阐述和评估是忠实于类型注释中给出的源程序:如果程序员只写按值类型,没有按名称减少可以发生在运行时间。
英文摘要:
We classify programming languages according to evaluation order: each language fixes one evaluation order as the default, making it transparent to program in that evaluation order, and troublesome to program in the other. This paper develops a type system that is impartial with respect to evaluation order. Evaluation order is implicit in terms, and explicit in types, with by-value and by-name versions of type connectives. A form of intersection type quantifies over evaluation orders, describing code that is agnostic over (that is, polymorphic in) evaluation order. By allowing such generic code, programs can express the by-value and by-name versions of a computation without code duplication. We also formulate a type system that only has by-value connectives, plus a type that generalizes the difference between by-value and by-name connectives: it is either a suspension (by name) or a "no-op" (by value). We show a straightforward encoding of the impartial type system into the more economical one. Then we define an elaboration from the economical language to a call-by-value semantics, and prove that elaborating a well-typed source program, where evaluation order is implicit, produces a well-typed target program where evaluation order is explicit. We also prove a simulation between evaluation of the target program and reductions (either by-value or by-name) in the source program. Finally, we prove that typing, elaboration, and evaluation are faithful to the type annotations given in the source program: if the programmer only writes by-value types, no by-name reductions can occur at run time.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。