FeatherTrait: A Modest Extension of Featherweight Java - Inria - Institut national de recherche en sciences et technologies du numérique Access content directly
Journal Articles ACM Transactions on Programming Languages and Systems (TOPLAS) Year : 2008

FeatherTrait: A Modest Extension of Featherweight Java

Abstract

In the context of statically-typed, class-based languages, we investigate classes that can be extended with trait composition. A trait is a collection of methods without state; it can be viewed as an incomplete stateless class. Traits can be composed in any order, but only make sense when imported by a class that provides state variables and additional methods to disambiguate conflicting names arising between the imported traits. We introduce FeatherTrait Java (FTJ), a conservative extension of the simple lightweight class-based calculus Featherweight Java (FJ) with statically-typed traits. In FTJ, classes can be built using traits as basic behavioral bricks; method conflicts between imported traits must be resolved explicitly by the user either by (i) aliasing or excluding method names in traits, or by (ii) overriding explicitly the conflicting methods in the class or in the trait itself. We present an operational semantics with a lookup algorithm, and a sound type system that guarantees that evaluating a well-typed expression never yields a message-not-understood run-time error nor gets the interpreter stuck. We give examples of the increased expressive power of the trait-based inheritance model. The resulting calculus appears to be a good starting point for a rigorous mathematical analysis of typed class-based languages featuring trait-based inheritance.
Fichier principal
Vignette du fichier
fjtraits.pdf (313.24 Ko) Télécharger le fichier
Origin : Files produced by the author(s)
Loading...

Dates and versions

inria-00432538 , version 1 (16-11-2009)

Identifiers

Cite

Luigi Liquori, Arnaud Spiwack. FeatherTrait: A Modest Extension of Featherweight Java. ACM Transactions on Programming Languages and Systems (TOPLAS), 2008, ACM Transactions on Programming Languages and Systems (TOPLAS), 30 (2), pp.11:1--11:32. ⟨10.1145/1330017.1330022⟩. ⟨inria-00432538⟩
401 View
671 Download

Altmetric

Share

Gmail Facebook X LinkedIn More