跳到正文
EasyXiv 检索
投稿 关于 登录

按回车检索 · 直接输入编号(如 1706.03762)可跳转到论文

计算机科学 > 程序设计语言

arXiv:2010.03608 (cs)
[提交于 2021年7月30日 (v1),最后修订于 2021年11月19日 (此版本, v3)]

标题:Type Checking Extracted Methods

作者:Yuquan Fu, Sam Tobin-Hochstadt
查看论文《Type Checking Extracted Methods》的 PDF
查看原文 PDF 中文 PDF (下批处理) EasyResearch 阅读
摘要:Many object-oriented dynamic languages allow programmers to _extract methods_ from objects and treat them as functions. This allows for flexible programming patterns, but presents challenges for type systems. In particular, a simple treatment of method extraction would require methods to be contravariant in the receiver type, making overriding all-but-impossible. We present a detailed investigation of this problem, as well as an implemented and evaluated solution. Method extraction is a feature of many dynamically-typed and gradually-typed languages, ranging from Python and PHP to Flow and TypeScript. In these languages, the underlying representation of objects as records of procedures can be accessed, and the procedures that implement methods can be reified as functions that can be called independently. In many of these languages, the programmer can then explicitly specify the `this` value to be used when the method implementation is called. Unfortunately, as we show, existing gradual type systems such as TypeScript and Flow are unsound in the presence of method extraction. The problem for typing any such system is that the flexibility it allows must be tamed by requiring a connection between the object the method was extracted from, and the function value that is later called. In Racket, where a method extraction-like facility, dubbed "structure type properties", is fundamental to classes, generic methods, and other APIs, these same challenges arise, and must be solved to support this feature in Typed Racket. We show how to combine two existing type system features -- existential types and occurrence typing -- to produce a sound approach to typing method extraction. We formalize our design, extending an existing formal model of the Typed Racket type system, and prove that our extension is sound. Our design is also implemented in the released version of Racket, and is compatible with all existing Typed Racket packages, many of which already used a previous version of this feature.
主题: 程序设计语言 (cs.PL)
引用方式: arXiv:2010.03608 [cs.PL]
  (或者 arXiv:2010.03608v3 [cs.PL] 对于此版本)
  https://doi.org/10.48550/arXiv.2010.03608
期刊参考: The Art, Science, and Engineering of Programming, 2022, Vol. 6, Issue 2, Article 6
相关 DOI: https://doi.org/10.22152/programming-journal.org/2022/6/6

提交历史

来自:Yuquan Fu
[v2] 2021年7月30日 星期五 19:51:02 UTC
[v3] 2021年11月19日 星期五 20:18:26 UTC
全文链接:

访问论文:

  • 查看原文 PDF
  • 中文 PDF (下批处理)
  • EasyResearch 阅读
  • TeX 源文件
  • arXiv 原文页面
查看许可

当前浏览上下文:

cs.PL
< 上一篇   |   下一篇 >
最新 | 近期 | 2021-11
切换浏览方式为:
cs

参考文献与引用

  • Google Scholar
  • Semantic Scholar

BibTeX 格式的引用

EasyXiv 是独立运营的中文预印本站点,与 arXiv 及康奈尔大学无隶属关系。 论文元数据与原文来自 arXiv.org,感谢 arXiv 提供开放获取服务。
关于 · 帮助 · 投稿指南 · 版权 · arXiv 原站