首页    期刊浏览 2025年06月05日 星期四
登录注册

文章基本信息

  • 标题:Scala with Explicit Nulls
  • 本地全文:下载
  • 作者:Abel Nieto ; Yaoyu Zhao ; Ondřej Lhoták
  • 期刊名称:LIPIcs : Leibniz International Proceedings in Informatics
  • 电子版ISSN:1868-8969
  • 出版年度:2020
  • 卷号:166
  • 页码:1-26
  • DOI:10.4230/LIPIcs.ECOOP.2020.25
  • 出版社:Schloss Dagstuhl -- Leibniz-Zentrum fuer Informatik
  • 摘要:The Scala programming language makes all reference types implicitly nullable. This is a problem, because null references do not support most operations that do make sense on regular objects, leading to runtime errors. In this paper, we present a modification to the Scala type system that makes nullability explicit in the types. Specifically, we make reference types non-nullable by default, while still allowing for nullable types via union types. We have implemented this design for explicit nulls as a fork of the Dotty (Scala 3) compiler. We evaluate our scheme by migrating a number of Scala libraries to use explicit nulls. Finally, we give a denotational semantics of type nullification, the interoperability layer between Java and Scala with explicit nulls. We show a soundness theorem stating that, for variants of System F_ω that model Java and Scala, nullification preserves values of types.
  • 关键词:Scala; Java; nullability; language interoperability; type systems
国家哲学社会科学文献中心版权所有