【24h】

Self Type Constructors

机译:自类型构造函数

获取原文
获取原文并翻译 | 示例

摘要

Bruce and Foster proposed the language LOOJ, an extension of Java with the notion of MyType, which represents the type of a self reference and changes its meaning along with inheritance. MyType is useful to write extensible yet type-safe classes for objects with recursive interfaces, that is, ones with methods that take or return objects of the same type as the receiver.rnAlthough LOOJ has also generics, MyType has been introduced as a feature rather orthogonal to generics. As a result, LOOJ cannot express an interface that refers to the same generic class recursively but with different type arguments. This is a significant limitation because such an interface naturally arises in practice, for example, in a generic collection class with method map(), which converts a collection to the same kind of collection of a different element type. Altherr and Cremet and Moors, Piessens, and Oder-sky gave solutions to this problem but they used a highly sophisticated combination of advanced mechanisms such as abstract type members, higher-order type constructors, and F-bounded polymorphism.rnIn this paper, we give another solution by introducing self type constructors, which integrate MyType and generics so that MyType can take type arguments in a generic class. Self type constructors are tailored to writing recursive interfaces more concicely than previous solutions. We demonstrate the expressive power of self type constructors by means of examples, formalize a core language with self type constructors, and prove its type safety.
机译:Bruce和Foster提出了语言LOOJ,这是Java的扩展,带有MyType的概念,该类型表示自我引用的类型,并随着继承而改变其含义。 MyType对于为具有递归接口的对象编写可扩展的但类型安全的类很有用,即使用带有接收器或返回与接收器相同类型的对象的方法的对象。rn尽管LOOJ也具有泛型,但引入了MyType作为功能与泛型正交。结果,LOOJ无法表达一个递归引用同一泛型类但具有不同类型参数的接口。这是一个重大限制,因为这样的接口实际上是在实践中自然产生的,例如,在具有方法map()的通用集合类中,该类将集合转换为不同元素类型的同一种集合。 Altherr和Cremet和Moors,Piessens和Oder-sky解决了这个问题,但是他们使用了高级机制的高度复杂的组合,例如抽象类型成员,高阶类型构造函数和F界多态性。通过引入自我类型构造函数来提供另一种解决方案,该构造函数集成了MyType和泛型,以便MyType可以在泛型类中采用类型参数。自类型构造函数经过专门设计,比以前的解决方案更简洁地编写递归接口。我们通过示例演示自我类型构造函数的表达能力,用自我类型构造函数形式化核心语言,并证明其类型安全性。

著录项

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号