Affiliation:
1. Kyoto University, Kyoto, Japan
Abstract
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.
Although 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 Odersky 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.
In 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.
Publisher
Association for Computing Machinery (ACM)
Subject
Computer Graphics and Computer-Aided Design,Software
Cited by
3 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. Gradual typing for Smalltalk;Science of Computer Programming;2014-12
2. Matching MyType to subtyping;Science of Computer Programming;2013-07
3. Related Types;Lecture Notes in Computer Science;2011