Clojure的实用可选类型
Practical Optional Types for Clojure
摘要:
类型化Clojure是Clojure的可选类型系统,Clojure是Lisp家族中的一种面向JVM的动态语言。类型化Clojure使Clojure程序员能够在Clojure世界中通过静态类型检查对其代码的正确性获得更大的信心,并在Clojure社区中获得了大量采用。Typed Clojure重新利用了Typed Racket的出现类型,这是一种静态推理谓词测试的方法,并且还包括几个新的类型系统特性来处理现有的Clojure习惯用法。在本文中,我们描述了类型化的Clojure,并介绍了这些类型系统扩展,重点介绍了Clojure中广泛使用的三个特性。首先,多方法提供了可扩展的操作,它们的Clojure语义与底层的发生类型框架有着惊人的协同作用。其次,Java互操作性是Clojure的核心任务,但也带来了一些挑战,比如无处不在的null;类型化Clojure在处理Java互操作性的同时,确保类型化程序中没有空指针异常。第三,Clojure程序员习惯性地将不可变的字典用于数据结构; Typed Clojure使用多种形式的异构字典类型来处理这一点。我们提供了一个包含这些和其他功能的类型化Clojure类型系统的正式模型,并证明了其可靠性。此外,Typed Clojure现在被许多使用Clojure的公司和开发人员使用,我们在两个重要的代码库中对类型系统功能的使用进行了定量分析。
英文摘要:
Typed Clojure is an optional type system for Clojure, a dynamic language in the Lisp family that targets the JVM. Typed Clojure enables Clojure programmers to gain greater confidence in the correctness of their code via static type checking while remaining in the Clojure world, and has acquired significant adoption in the Clojure community. Typed Clojure repurposes Typed Racket's occurrence typing, an approach to statically reasoning about predicate tests, and also includes several new type system features to handle existing Clojure idioms. In this paper, we describe Typed Clojure and present these type system extensions, focusing on three features widely used in Clojure. First, multimethods provide extensible operations, and their Clojure semantics turns out to have a surprising synergy with the underlying occurrence typing framework. Second, Java interoperability is central to Clojure's mission but introduces challenges such as ubiquitous null; Typed Clojure handles Java interoperability while ensuring the absence of null-pointer exceptions in typed programs. Third, Clojure programmers idiomatically use immutable dictionaries for data structures; Typed Clojure handles this with multiple forms of heterogeneous dictionary types. We provide a formal model of the Typed Clojure type system incorporating these and other features, with a proof of soundness. Additionally, Typed Clojure is now in use by numerous corporations and developers working with Clojure, and we present a quantitative analysis on the use of type system features in two substantial code bases.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。