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.
- Abadi, M. and Cardelli, L. 1996. A Theory of Objects. Springer Verlag, New York. Google Scholar
Digital Library
- 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.Google Scholar
- Allen, E. E., Bannet, J., and Cartwright, R. 2003. Mixins in generic java are sound. Tech. rep., Rice University.Google Scholar
- Ancona, D., Lagorio, G., and Zucca, E. 2003. Jam - designing a Java extension with mixins. ACM Trans. Prog. Lang. Syst. 25, 5, 641--712. Google Scholar
Digital Library
- Ancona, D. and Zucca, E. 2002a. A calculus of module system. J. Funct. Program 12, 12, 91--132. Google Scholar
Digital Library
- Ancona, D. and Zucca, E. 2002b. A theory of mixin modules: Algebraic laws and reduction semantics. Math. Struct. Comput. Sci. 12, 5, 701--737. Google Scholar
Digital Library
- Bono, V., Bugliesi, M., Dezani-Ciancaglini, M., and Liquori, L. 1997. Subtyping constraint for incomplete objects. In Proceedings of TAPSOFT/CAAP. Lecture Notes in Computer Science, vol. 1214. Springer Verlag, New York, 465--477. Google Scholar
Digital Library
- Bono, V., Patel, A., and Shmatikov, V. 1999. A core calculus of classes and mixins. In Proceedings of ECOOP. Lecture Notes in Computer Science, vol. 1628. Springer-Verlag, New York. Google Scholar
Digital Library
- Bracha, G. 1992. The Programming Language Jigsaw: Mixins, modularity and multiple inheritance. Ph.D. dissertation, University of Utah. Google Scholar
Digital Library
- Bracha, G. and Cook, W. R. 1990. Mixin-based inheritance. In Proceedings of OOPSLA/ECOOP. SIGPLAN Notices, vol. 25(10). ACM, New York, 303--311. Google Scholar
Digital Library
- Cardelli, L. 1995. Obliq: A language with distributed scope. Comput. Syst. 8, 1, 27--59.Google Scholar
- Di Gianantonio, P., Honsell, F., and Liquori, L. 1998. A lambda calculus of objects with self-inflicted extension. In Proceedings of OOPSLA. ACM, New York, 166--178. Google Scholar
Digital Library
- Ducasse, S., Nierstrasz, O., Schärli, N., Wuyts, R., and Black, A. P. 2006. Traits: A mechanism for fine-grained reuse. ACM Trans. Program. Lang. Syst. 28, 2, 331--388. Google Scholar
Digital Library
- Duggan, D. and Sourelis, C. 1996. Mixin modules. In Proceedings of ICFP. SIGPLAN Notices, vol. 31(6). ACM, New York, 262--273. Google Scholar
Digital Library
- Findler, R. B. and Flatt, M. 1998. Modular object-oriented programming with units and mixins. In Proceedings of ICFP. SIGPLAN Notices. ACM, New York, 94--104. Google Scholar
Digital Library
- Fisher, K. and Reppy, J. 2004. Statically typed traits. http://www.cs.uchicago.edu/files/tr-authentic/TR-2003-13.pdf. (The early version “A Typed Calculus of Traits” has been presented at FOOL 10.)Google Scholar
- Flatt, M. and Felleisen, M. 1998. Units: Cool modules for HOT languages. In Proceedings of PLDI. SIGPLAN Notices. ACM, New York, 236--248. Google Scholar
Digital Library
- Flatt, M., Krishnamurthi, S., and Felleisen, M. 1998. Classes and mixins. In Proceedings of POPL. ACM, New York, 171--183. Google Scholar
Digital Library
- Goldberg, A. and Robson, D. 1983. Smalltalk-80: the Language and its Implementation. Addison-Wesley, Reading, MA. Google Scholar
Digital Library
- Hirschowitz, T., Leroy, X., and Wells, J. B. 2004. Call-by-value mixin modules: Reduction semantics, side effects, types. In Proceedings of ESOP. Lecture Notes in Computer Science, 2986, Springer-Verlag, New York, 64--78.Google Scholar
- Igarashi, A., Pierce, B., and Wadler, P. 2001. Featherweight Java: A minimal core calculus for Java and GJ. ACM Trans. Prog. Lang. Syst. 23, 3, 396--450. Google Scholar
Digital Library
- Kiczales, G., Lamping, J., Mendhekar, A., Maeda, C., Lopes, C. V., Loingtier, J.-M., and Irwin, J. 1997. Aspect-oriented programming. In Proceedings of ECOOP. Lecture Notes in Computer Science, 1241, Springer-Verlag, New York, 220--242.Google Scholar
- Liquori, L. 1997. An extended theory of primitive objects: first order system. In Proceedings of ECOOP. Lecture Notes in Computer Science, 1241, Springer-Verlag, New York, 146--169.Google Scholar
- Liquori, L. 1998. On object extension. In Proceedings of ECOOP. Lecture Notes in Computer Science, 1445, Springer-Verlag, New York, 498--552. Google Scholar
Digital Library
- Liquori, L. and Spiwack, A. 2004. Featherweight-trait Java : A trait-based extension for FJ. Tech. Rep. RR-5247, INRIA. Juin. http://www.inria.fr/rrrt/rr-5247.html.Google Scholar
- Liquori, L. and Spiwack, A. 2008. Extending FeatherTrait Java with interfaces. Theoret. Comput. Sci. To appear. Google Scholar
Digital Library
- Mezini, M. 2002. Towards variational object-oriented programming: The rondo model. Tech. Rep. TUD-ST-2002-02, Software Technology Group, Darmstadt University of Technology.Google Scholar
- Microsoft. The C# Home Page. http://msdn.microsoft.com/vcsharp/.Google Scholar
- Milner, R., Tofte, M., Harper, R., and MacQueen, D. 1997. The Definition of Standard ML (Revised). MIT Press, Cambridge, MA. Google Scholar
Digital Library
- Moby Team. 2007. The Moby home page. http://moby.cs.uchicago.edu/.Google Scholar
- Nierstrasz, O., Ducasse, S., and Schärli, N. 2006. Flattening traits. J. Obj. Tech. 5, 4, 129--148.Google Scholar
Cross Ref
- Quitslund, P. J. 2004. Java traits -- Improving opportunities for reuse. Tech. Rep. CSE-04-005, OGI School of Science and Engineering. http://www.ogi.edu/csee/tech-reports/2004/04-005.pdf.Google Scholar
- Scala Team. 2007. The scala home page. http://scala.epfl.ch/.Google Scholar
- Schärli, N., Ducasse, S., Nierstrasz, O., and Black, A. 2003. Traits: Composable units of behaviour. In Proceedings of ECOOP. Lecture Notes in Computer Science, 2743, Springer-Verlag, New York, 248--274.Google Scholar
- Smith, C. and Drossopoulou, S. 2005. Chai: Typed traits in Java. In Proceedings of ECOOP. Lecture Notes in Computer Science, 3586, Springer-Verlag, New York, 453--478. Google Scholar
Digital Library
- Snyder, A. 1987. Inheritance and the development of encapsulated software systems. In Research Directions in Object-Oriented Programming. MIT Press, Cambridge, MA, 165--188. Google Scholar
Digital Library
- Stroustrup, B. 1997. The C++ Programming Language, Ch. 15, Third Ed. Addison Wesley, Reading, MA. Google Scholar
Digital Library
- Sun. Java Technology. http://java.sun.com/.Google Scholar
- Ungar, D. and Smith, R. B. 1987. Self: The power of simplicity. In Proceedings of OOPSLA. ACM, New York, 227--241. Google Scholar
Digital Library
- Wells, J. B. and Vestergaard, R. 2000. Equational reasoning for linking with first-class primitive modules. In Proceedings of ESOP. Lecture Notes in Computer Science, vol. 1782. Springer Verlag, New York, 412--428. Google Scholar
Digital Library
Index Terms
FeatherTrait: A modest extension of Featherweight Java
Recommendations
Featherweight Java: a minimal core calculus for Java and GJ
Several recent studies have introduced lightweight versions of Java: reduced languages in which complex features like threads and reflection are dropped to enable rigorous arguments about key properties such as type safety. We carry this process a step ...
Variant parametric types: A flexible subtyping scheme for generics
We develop the mechanism of variant parametric types as a means to enhance synergy between parametric and inclusion polymorphism in object-oriented programming languages. Variant parametric types are used to control both the subtyping between different ...
Union types for object-oriented programming
SAC '06: Proceedings of the 2006 ACM symposium on Applied computingWe propose union types for statically typed class-based object-oriented languages as a means to enhance the flexibility of subtyping. As its name suggests, a union type can be considered a set union of instances of several types and behaves as their ...








Comments