arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1610.08476cs.PL
收藏

在开放的世界中逐步打字

Gradual Typing in an Open World

Michael M. Vitousek, Jeremy G. Siek

摘要:

渐进类型在同一语言中结合了静态和动态类型,为程序员提供了两者的好处。静态类型提供错误检测和强有力的保证,而动态类型支持快速原型和灵活的编程习惯。然而,对于程序员来说,为了充分利用渐进类型系统,他们必须能够信任他们的类型注释,因此必须在静态和动态代码的边界处执行运行时检查,以确保静态类型得到尊重。高阶和可变值不能在这些边界上完全检查,因此必须在它们的使用站点上执行额外的检查。传统上,这是通过在这些值上安装包装器或代理来实现的,这些值可以调节静态和动态之间的数据流,但是如果语言支持对象标识的比较或具有外部函数接口,则这些可能会导致问题。网格化Python是Python的渐进类型化变体,通过Python 3的源代码到源代码转换器实现。它实现了一种无代理的替代设计,称为瞬态强制转换。本文提出了一个正式的语义瞬态转换,并表明,他们不仅是健全的,但他们在一个开放的世界设置中,网状翻译器只应用于一些程序,其余的是未翻译的Python。我们形式化了这个开放世界的可靠性属性,并使用Coq来证明它适用于Anthill Python,这是一种模拟网状Python的演算。

英文摘要:

Gradual typing combines static and dynamic typing in the same language, offering the benefits of both to programmers. Static typing provides error detection and strong guarantees while dynamic typing enables rapid prototyping and flexible programming idioms. For programmers to fully take advantage of a gradual type system, however, they must be able to trust their type annotations, and so runtime checks must be performed at the boundaries of static and dynamic code to ensure that static types are respected. Higher order and mutable values cannot be completely checked at these boundaries, and so additional checks must be performed at their use sites. Traditionally, this has been achieved by installing wrappers or proxies on such values that moderate the flow of data between static and dynamic, but these can cause problems if the language supports comparison of object identity or has a foreign function interface. Reticulated Python is a gradually typed variant of Python implemented via a source-to-source translator for Python 3. It implements a proxy-free alternative design named transient casts. This paper presents a formal semantics for transient casts and shows that not only are they sound, but they work in an open-world setting in which the Reticulated translator has only been applied to some of the program; the rest is untranslated Python. We formalize this open world soundness property and use Coq to prove that it holds for Anthill Python, a calculus that models Reticulated Python.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑