类型化Racket的瞬态语义
A Transient Semantics for Typed Racket
摘要:
混合类型语言使程序员能够以各种方式链接类型化和非类型化组件。有些提供了丰富的类型系统,以促进非类型化代码向类型化世界的平滑迁移;其他的只是提供了一种方便的Dynamic类型形式和一个传统的结构化类型系统。与这个维度正交的是,自然系统通过复杂的契约系统确保类型的完整性,而瞬态系统在类型化代码中的战略位置插入简单的一阶检查。此外,每种确保类型完整性的方法都有自己的错误分配策略。Typed Racket拥有丰富的迁移类型系统,并使用自然语义强制类型。网状Python有一个简单的结构类型系统,扩展了Dynamic,并使用Transient语义强制类型。虽然Typed Racket以显著的性能代价满足最严格的渐变类型健全性属性,但Reticulated Python似乎将性能损失限制在可容忍的程度,并且仍然是类型健全的。这种比较提出了一个问题,即瞬态检查是否适用于富迁移类型系统。本文报告了将网状Python的瞬态语义适应于Typed Racket的丰富迁移类型系统的惊人困难。由此产生的实现,浅类型Racket,比标准的深类型Racket更快,但只有当瞬态责任分配策略被禁用时。对于语言设计者来说,这份报告提供了关于如何装备现有编译器以支持瞬态语义的有价值的提示。对于理论家来说,暂时责备的负面经验要求对这种策略进行彻底的调查。
英文摘要:
Mixed-typed languages enable programmers to link typed and untyped components in various ways. Some offer rich type systems to facilitate the smooth migration of untyped code to the typed world; others merely provide a convenient form of type Dynamic together with a conventional structural type system. Orthogonal to this dimension, Natural systems ensure the integrity of types with a sophisticated contract system, while Transient systems insert simple first-order checks at strategic places within typed code. Furthermore, each method of ensuring type integrity comes with its own blame-assignment strategy. Typed Racket has a rich migratory type system and enforces the types with a Natural semantics. Reticulated Python has a simple structural type system extended with Dynamic and enforces types with a Transient semantics. While Typed Racket satisfies the most stringent gradual-type soundness properties at a significant performance cost, Reticulated Python seems to limit the performance penalty to a tolerable degree and is nevertheless type sound. This comparison raises the question of whether Transient checking is applicable to and beneficial for a rich migratory type system. This paper reports on the surprising difficulties of adapting the Transient semantics of Reticulated Python to the rich migratory type system of Typed Racket. The resulting implementation, Shallow Typed Racket, is faster than the standard Deep Typed Racket but only when the Transient blame assignment strategy is disabled. For language designers, this report provides valuable hints on how to equip an existing compiler to support a Transient semantics. For theoreticians, the negative experience with Transient blame calls for a thorough investigation of this strategy.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。