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.
Funder
Sixth Framework Programme
Publisher
Association for Computing Machinery (ACM)
Reference37 articles.
1. Abadi M. and Cardelli L. 1996. A Theory of Objects. Springer Verlag New York. Abadi M. and Cardelli L. 1996. A Theory of Objects. Springer Verlag New York.
2. Allen E. Chase D. Luchangco V. Maessen J.-W. Ryu S. Steele G. L. and Tobin-Hochstadt S. 2007. The Fortress Language Specification version 1.0. http://research.sun.com/projects/plrg/fortress.pdf. Allen E. Chase D. Luchangco V. Maessen J.-W. Ryu S. Steele G. L. and Tobin-Hochstadt S. 2007. The Fortress Language Specification version 1.0. http://research.sun.com/projects/plrg/fortress.pdf.
3. Allen E. E. Bannet J. and Cartwright R. 2003. Mixins in generic java are sound. Tech. rep. Rice University. Allen E. E. Bannet J. and Cartwright R. 2003. Mixins in generic java are sound. Tech. rep. Rice University.
4. Jam---designing a Java extension with mixins
5. A calculus of module systems
Cited by
35 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. Flexible Correct-by-Construction Programming;Logical Methods in Computer Science;2023-06-07
2. Variability modules;Journal of Systems and Software;2023-01
3. Traits: Correctness-by-Construction for Free;Formal Techniques for Distributed Objects, Components, and Systems;2022
4. Featherweight Swift: a Core calculus for Swift’s type system;Proceedings of the 13th ACM SIGPLAN International Conference on Software Language Engineering;2020-11-15
5. Software language engineers’ worst nightmare;Proceedings of the 13th ACM SIGPLAN International Conference on Software Language Engineering;2020-11-15