当前位置: X-MOL 学术Sci. Comput. Program. › 论文详情
Our official English website, www.x-mol.net, welcomes your feedback! (Note: you will need to create a separate account there.)
Castor: Programming with extensible generative visitors
Science of Computer Programming ( IF 1.5 ) Pub Date : 2020-03-18 , DOI: 10.1016/j.scico.2020.102449
Weixin Zhang , Bruno C.d.S. Oliveira

Much recent work on type-safe extensibility for Object-Oriented languages has focused on design patterns that require modest type system features. Examples of such design patterns include Object Algebras, Extensible Visitors, Finally Tagless interpreters, or Polymorphic Embeddings. Those techniques, which often use a functional style, can solve basic forms of the Expression Problem. However, they have important limitations.

This paper presents Castor: a Scala framework for programming with extensible, generative visitors. Castor has several advantages over previous approaches. Firstly, Castor comes with support for (type-safe) pattern matching to complement its visitors with a concise notation to express operations. Secondly, Castor supports type-safe interpreters (à la Finally Tagless), but with additional support for pattern matching and a generally recursive style. Thirdly, Castor enables many operations to be defined using an imperative style, which is significantly more performant than a functional style (especially in the JVM platform). Finally, functional techniques usually only support tree structures well, but graph structures are poorly supported. Castor supports type-safe extensible programming on graph structures. The key to Castor's usability is the use of annotations to automatically generate large amounts of boilerplate code to simplify programming with extensible visitors. To illustrate the applicability of Castor we present several applications and two case studies. The first case study compares the ability of Castor for modularizing the interpreters from the “Types and Programming Languages” book with previous modularization work. The second case study on UML activity diagrams illustrates the imperative aspects of Castor, as well as its support for hierarchical datatypes and graphs.



中文翻译:

Castor:与可扩展的生成访客进行编程

面向对象语言的类型安全可扩展性的许多最新工作都集中在需要适度类型系统功能的设计模式上。这种设计模式的示例包括对象代数可扩展的访问者最终无标签解释器或多态嵌入。这些通常使用功能样式的技术可以解决表达问题的基本形式。但是,它们具有重要的局限性。

本文介绍了Castor:一个可扩展的,生成访问者的Scala框架。与先前的方法相比,Castor具有多个优点。首先,Castor支持(类型安全)模式匹配,以简洁的表示操作的符号来补充其访问者。其次,Castor支持类型安全的解释器(称为“最终无标签”),但额外支持模式匹配和一般的递归样式。第三,蓖麻支持使用命令式样式定义许多操作,该命令式样式比功能样式(特别是在JVM平台中)的性能明显更高。最后,功能技术通常只很好地支持树结构,但对图结构的支持却很差。Castor支持在图结构上进行类型安全的可扩展编程。Castor可用性的关键是使用注释自动生成大量样板代码,以简化可扩展访问者的编程。为了说明Castor的适用性,我们介绍了几个应用程序和两个案例研究。第一个案例研究比较了Castor的能力用于将“类型和编程语言”书中的解释程序进行模块化,以及之前的模块化工作。关于UML活动图的第二个案例研究说明了Castor的必要方面,以及它对分层数据类型和图的支持。

更新日期:2020-03-18
down
wechat
bug