Nothing Special   »   [go: up one dir, main page]

skip to main content
article

Stateful traits and their formalization

Published: 01 July 2008 Publication History

Abstract

Traits offer a fine-grained mechanism to compose classes from reusable components while avoiding problems of fragility brought by multiple inheritance and mixins. Traits as originally proposed are stateless, that is, they contain only methods, but no instance variables. State can only be accessed within stateless traits by accessors, which become required methods of the trait. Although this approach works reasonably well in practice, it means that many traits, viewed as software components, are artificially incomplete, and classes that use such traits may contain significant amounts of boilerplate glue code. We present an approach to stateful traits that is faithful to the guiding principle of stateless traits: the client retains control of the composition. Stateful traits consist of a minimal extension to stateless traits in which instance variables are purely local to the scope of a trait, unless they are explicitly made accessible by the composing client of a trait. We demonstrate by means of a formal object calculus that adding state to traits preserves the flattening property: traits contained in a program can be compiled away. We discuss and compare two implementation strategies, and briefly present a case study in which stateful traits have been used to refactor the trait-based version of the Smalltalk collection hierarchy.

References

[1]
Schärli N, Ducasse S, Nierstrasz O, Black A. Traits: composable units of behavior. In: Proceedings of ECOOP 2003 (European conference on object-oriented programming), Lecture notes in computer science, vol. 2743, Berline: Springer, July 2003. p. 248-74.
[2]
Ducasse, S., Nierstrasz, O., Schärli, N., Wuyts, R. and Black, A., Traits: a mechanism for fine-grained reuse. ACM transactions on programming languages and systems. v28 i2. 331-388.
[3]
Ingalls D, Kaehler T, Maloney J, Wallace S, Kay A. Back to the future: the story of Squeak, A practical Smalltalk written in itself. In: Proceedings of OOPSLA '97, ACM SIGPLAN notices. New York: ACM Press, November 1997. p. 318-26.
[4]
Scala home page. {http://lamp.epfl.ch/scala/}.
[5]
Slate. {http://slate.tunes.org}.
[6]
The Fortress language specification. {http://research.sun.com/projects/plrg/fortress0866.pdf}.
[7]
Fisher K, Reppy J. Statically typed traits. Technical Report TR-2003-13, Department of Computer Science, University of Chicago, December 2003.
[8]
Smith C, Drossopoulou S. Chai: typed traits in Java. In: Proceedings of ECOOP 2005; 2005.
[9]
Nierstrasz, O., Ducasse, S. and Schärli, N., Flattening traits. Journal of Object Technology. v5 i4. 129-148.
[10]
Bergel A, Ducasse S, Nierstrasz O, Wuyts R. Stateful traits. In: Advances in Smalltalk - Proceedings of 14th international Smalltalk Conference (ISC 2006), Lecture Notes in Computer Science, vol. 4406, Berlin: Springer; 2007. p. 66-90.
[11]
Black AP, Schärli N, Ducasse S. Applying traits to the Smalltalk collection hierarchy. In: Proceedings of OOPSLA'03 (International conference on object-oriented programming systems, languages and applications), vol. 38, October 2003. p. 47-64.
[12]
Bracha G. The programming language jigsaw: mixins, modularity and multiple inheritance. PhD thesis, Department of Computer Science, University of Utah, March 1992.
[13]
Flatt M, Krishnamurthi S, Felleisen M. Classes and mixins. In: Proceedings of the 25th ACM SIGPLAN-SIGACT symposium on principles of programming languages. New York: ACM Press; 1998. p. 171-183.
[14]
Felleisen, M. and Hieb, R., The revised report on the syntactic theories of sequential control. Theoretical computer science. v103 i2. 235-271.
[15]
Bak L, Bracha G, Grarup S, Griesemer R, Griswold D, Hölzle U. Mixins in strongtalk. In ECOOP '02 workshop on inheritance, June 2002.
[16]
Cardelli, L., Donahue, J., Glassman, L., Jordan, M., Kalsow, B. and Nelson, G., Modula-3 language definition. ACM SIGPLAN notices. v27 i8. 15-42.
[17]
The Jikes research virtual machine. {http://jikesrvm.sourceforge.net/}.
[18]
Sweeney PF, Gil JY. Space and time-efficient memory layout for multiple inheritance. In: Proceedings of OOPSLA '99, New York: ACM Press; 1999. p. 256-75.
[19]
Python. {http://www.python.org}.
[20]
Stroustrup, B. and Ellis, M.A., The annotated C++ reference manual. 1990. Addison-Wesley, Reading, MA.
[21]
Krogdahl, S., Multiple inheritance in Simula-like languages. In: BIT. v25.
[22]
Snyder A. Encapsulation and inheritance in object-oriented programming languages. In: Proceedings of OOPSLA '86, ACM SIGPLAN notices, vol. 21, November 1986. p. 38-45.
[23]
Ungar D, Smith RB. Self: the power of simplicity. In: Proceedings of OOPSLA '87, ACM SIGPLAN notices, vol. 22, December 1987. p. 227-42.
[24]
Ungar, D., Chambers, C., Chang, B.-W. and Hölzle, U., Organizing programs without classes. LISP and SYMBOLIC COMPUTATION: an international journal. vvol. 4 i3.
[25]
Mohnen M. Interfaces with default implementations in Java. In: Conference on the principles and practice of programming in Java, Dublin, Ireland: ACM Press, June 2002. p. 35-40.
[26]
Bracha G, Cook W. Mixin-based inheritance. In: Proceedings of OOPSLA/ECOOP '90. ACM SIGPLAN notices, vol. 25, October 1990, p. 303-11.
[27]
Meyer, B., Eiffel: the language. 1992. Englewood cliffs, Prentice-Hall.
[28]
Chambers C. Object-oriented multi-methods in Cecil. In: Madsen LO, editor, Proceedings of ECOOP '92, Lecture notes in computer science, vol. 615 Utrecht, the Netherlands, June 1992. Springer, Berlin. p. 33-56.

Cited By

View all
  • (2021)FeatureVistaProceedings of the 25th ACM International Systems and Software Product Line Conference - Volume A10.1145/3461001.3471154(196-201)Online publication date: 6-Sep-2021
  • (2020)Featherweight Swift: a Core calculus for Swift’s type systemProceedings of the 13th ACM SIGPLAN International Conference on Software Language Engineering10.1145/3426425.3426939(140-154)Online publication date: 16-Nov-2020
  • (2019)Composable Actor BehaviourDistributed Applications and Interoperable Systems10.1007/978-3-030-22496-7_4(57-73)Online publication date: 17-Jun-2019
  • Show More Cited By

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image Computer Languages, Systems and Structures
Computer Languages, Systems and Structures  Volume 34, Issue 2-3
July, 2008
106 pages

Publisher

Elsevier Science Publishers B. V.

Netherlands

Publication History

Published: 01 July 2008

Author Tags

  1. Eiffel
  2. Flattening
  3. Jigsaw
  4. Mixin
  5. Multiple-inheritance
  6. Traits

Qualifiers

  • Article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)0
  • Downloads (Last 6 weeks)0
Reflects downloads up to 20 Nov 2024

Other Metrics

Citations

Cited By

View all
  • (2021)FeatureVistaProceedings of the 25th ACM International Systems and Software Product Line Conference - Volume A10.1145/3461001.3471154(196-201)Online publication date: 6-Sep-2021
  • (2020)Featherweight Swift: a Core calculus for Swift’s type systemProceedings of the 13th ACM SIGPLAN International Conference on Software Language Engineering10.1145/3426425.3426939(140-154)Online publication date: 16-Nov-2020
  • (2019)Composable Actor BehaviourDistributed Applications and Interoperable Systems10.1007/978-3-030-22496-7_4(57-73)Online publication date: 17-Jun-2019
  • (2017)XtraitjJournal of Systems and Software10.1016/j.jss.2016.07.035131:C(419-441)Online publication date: 1-Sep-2017
  • (2015)HandlesScience of Computer Programming10.1016/j.scico.2014.07.01198:P3(318-338)Online publication date: 1-Feb-2015
  • (2015)Implementing type-safe software product lines using parametric traitsScience of Computer Programming10.1016/j.scico.2013.07.01697:P3(282-308)Online publication date: 1-Jan-2015
  • (2014)Trait-oriented programming in Java 8Proceedings of the 2014 International Conference on Principles and Practices of Programming on the Java platform: Virtual machines, Languages, and Tools10.1145/2647508.2647520(181-186)Online publication date: 23-Sep-2014
  • (2014)Generic traits for the Java platformProceedings of the 2014 International Conference on Principles and Practices of Programming on the Java platform: Virtual machines, Languages, and Tools10.1145/2647508.2647518(5-16)Online publication date: 23-Sep-2014
  • (2014)Delegation proxiesProceedings of the 13th international conference on Modularity10.1145/2577080.2577081(1-12)Online publication date: 22-Apr-2014
  • (2014)Verifying traits: an incremental proof system for fine-grained reuseFormal Aspects of Computing10.1007/s00165-013-0278-326:4(761-793)Online publication date: 1-Jul-2014
  • Show More Cited By

View Options

View options

Login options

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media