Skip to main content

Adding State and Visibility Control to Traits Using Lexical Nesting

  • Conference paper

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 5653))

Abstract

Traits are reusable building blocks that can be composed to share methods across unrelated class hierarchies. Original traits are stateless and cannot express visibility control for methods. Two extensions, stateful traits and freezable traits, have been proposed to overcome these limitations. However, these extensions introduce complexity and have not yet been combined to simultaneously add both state and visibility control to traits.

This paper revisits the addition of state and visibility control to traits. Rather than extending the original traits model with additional operations, we allow traits to be lexically nested within other modules. Traits can then have (shared) state and visibility control by hiding variables or methods in their lexical scope. Although the Traits’ “flattening property” has to be revisited, the combination of traits with lexical nesting results in a simple and expressive trait model. We discuss an implementation of the model in AmbientTalk and specify its operational semantics.

Funded by the Interuniversity Attraction Poles Program, Belgian State, Belgian Science Policy.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   84.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   109.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Slate, http://slate.tunes.org

  2. 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 the 12th ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications, pp. 318–326. ACM Press, New York (1997)

    Chapter  Google Scholar 

  3. Flatt, M., Finder, R.B., Felleisen, M.: Scheme with classes, mixins and traits. In: AAPLAS 2006 (2006)

    Google Scholar 

  4. The Fortress language specification, http://research.sun.com/projects/plrg/fortress0866.pdf

  5. Fisher, K., Reppy, J.: Statically typed traits. Technical Report TR-2003-13, University of Chicago, Department of Computer Science (December 2003)

    Google Scholar 

  6. Smith, C., Drossopoulou, S.: chai: Traits for java-like languages. In: Black, A.P. (ed.) ECOOP 2005. LNCS, vol. 3586, pp. 453–478. Springer, Heidelberg (2005)

    Chapter  Google Scholar 

  7. Liquori, L., Spiwack, A.: FeatherTrait: A modest extension of Featherweight Java. ACM Transactions on Programming Languages and Systems (TOPLAS) 30(2), 1–32 (2008)

    Article  MATH  Google Scholar 

  8. Reppy, J., Turon, A.: Metaprogramming with traits. In: Ernst, E. (ed.) ECOOP 2007. LNCS, vol. 4609, pp. 373–398. Springer, Heidelberg (2007)

    Chapter  Google Scholar 

  9. Bergel, A., Ducasse, S., Nierstrasz, O., Wuyts, R.: Stateful traits and their formalization. Journal of Computer Languages, Systems and Structures 34(2-3), 83–108 (2007)

    Article  Google Scholar 

  10. Ducasse, S., Wuyts, R., Bergel, A., Nierstrasz, O.: User-changeable visibility: Resolving unanticipated name clashes in traits. In: Proceedings of 22nd International Conference on Object-Oriented Programming, Systems, Languages, and Applications, pp. 171–190. ACM Press, New York (2007)

    Google Scholar 

  11. Bak, L., Bracha, G., Grarup, S., Griesemer, R., Griswold, D., Hölzle, U.: Mixins in Strongtalk. In: ECOOP 2002 Workshop on Inheritance (2002)

    Google Scholar 

  12. Ducasse, S., Nierstrasz, O., Schärli, N., Wuyts, R., Black, A.: Traits: A mechanism for fine-grained reuse. ACM Transactions on Programming Languages and Systems (TOPLAS) 28(2), 331–388 (2006)

    Article  Google Scholar 

  13. Schärli, N., Ducasse, S., Nierstrasz, O., Black, A.: Traits: Composable units of behavior. In: Cardelli, L. (ed.) ECOOP 2003. LNCS, vol. 2743, pp. 248–274. Springer, Heidelberg (2003)

    Chapter  Google Scholar 

  14. Reppy, J., Turon, A.: A foundation for trait-based metaprogramming. In: International Workshop on Foundations and Developments of Object-Oriented Languages (2006)

    Google Scholar 

  15. Mens, T., van Limberghen, M.: Encapsulation and composition as orthogonal operators on mixins: A solution to multiple inheritance problems. Object Oriented Systems 3(1), 1–30 (1996)

    Google Scholar 

  16. Ungar, D., Chambers, C., Chang, B.W., Hölzle, U.: Organizing programs without classes. LISP and Symbolic Computation 4(3) (1991)

    Google Scholar 

  17. Reddy, U.: Objects as closures: abstract semantics of object-oriented languages. In: LFP 1988: Proceedings of the ACM conference on LISP and functional programming, pp. 289–297. ACM, New York (1988)

    Chapter  Google Scholar 

  18. Abelson, H., Sussman, G.J., Sussman, J.: Structure and interpretation of computer programs. MIT electrical engineering and computer science series. McGraw-Hill, New York (1991)

    Book  MATH  Google Scholar 

  19. Dickey, K.: Scheming with objects. AI Expert 7(10), 24–33 (1992)

    Google Scholar 

  20. Black, A., Hutchinson, N., Jul, E., Levy, H.: Object structure in the Emerald system. In: Proceedings OOPSLA 1986, ACM SIGPLAN Notices, vol. 21, pp. 78–86 (November 1986)

    Google Scholar 

  21. International, E.C.M.A.: ECMA-262: ECMAScript Language Specification, 3rd edn. ECMA (European Association for Standardizing Information and Communication Systems), Geneva, Switzerland (December 1999)

    Google Scholar 

  22. Madsen, O.L., Moller-Pedersen, B., Nygaard, K.: Object-Oriented Programming in the Beta Programming Language. Addison Wesley, Reading (1993)

    Google Scholar 

  23. Miller, M.S.: Robust Composition: Towards a Unified Approach to Access Control and Concurrency Control. PhD thesis, Johns Hopkins University, Baltimore, Maryland, USA (May 2006)

    Google Scholar 

  24. Bracha, G.: On the interaction of method lookup and scope with inheritance and nesting. In: 3rd ECOOP Workshop on Dynamic Languages and Applications (2007)

    Google Scholar 

  25. Dedecker, J., Cutsem, T.V., Mostinckx, S., Theo D’Hondt, W.D.M.: Ambient-oriented programming in ambienttalk. In: Thomas, D. (ed.) ECOOP 2006. LNCS, vol. 4067, pp. 230–254. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  26. Van Cutsem, T., Mostinckx, S., Boix, E., Dedecker, J., De Meuter, W.: Ambienttalk: Object-oriented event-driven programming in mobile ad hoc networks. In: XXVI International Conference of the Chilean Society of Computer Science, 2007. SCCC 2007, pp. 3–12 (November 2007)

    Google Scholar 

  27. Ungar, D., Smith, R.B.: Self: The power of simplicity. In: Proceedings OOPSLA 1987, ACM SIGPLAN Notices, vol. 22, pp. 227–242 (December 1987)

    Google Scholar 

  28. Lieberman, H.: Using prototypical objects to implement shared behavior in object oriented systems. In: Proceedings OOPSLA 1986, ACM SIGPLAN Notices, vol. 21, pp. 214–223 (December 1986)

    Google Scholar 

  29. Maloney, J.H., Smith, R.B.: Directness and liveness in the morphic user interface construction environment. In: UIST 1995: Proceedings of the 8th annual ACM symposium on User interface and software technology, pp. 21–28. ACM, New York (1995)

    Google Scholar 

  30. Smith, R.B., Ungar, D.: Programming as an experience: The inspiration for self. In: Olthoff, W. (ed.) ECOOP 1995. LNCS, vol. 952, pp. 303–330. Springer, Heidelberg (1995)

    Google Scholar 

  31. Anderson, C., Drossopoulou, S.: delta an imperative object based calculus. In: Proceedings of USE 2002 (2002)

    Google Scholar 

  32. Bettini, L., Bono, V.: Type Safe Dynamic Object Delegation in Class-based Languages. In: Proc. of PPPJ, Principles and Practice of Programming in Java. ACM Press, New York (2008)

    Google Scholar 

  33. Bono, V., Fisher, K.: An imperative, first-order calculus with object extension. In: Proceedings of the 12th European Conference on Object-Oriented Programming, London, UK, pp. 462–497. Springer, Heidelberg (1998)

    Google Scholar 

  34. Flatt, M., Krishnamurthi, S., Felleisen, M.: Classes and mixins. In: Proceedings of the 25th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 171–183. ACM Press, New York (1998)

    Chapter  Google Scholar 

  35. Felleisen, M., Hieb, R.: The revised report on the syntactic theories of sequential control and state. Theor. Comput. Sci. 103(2), 235–271 (1992)

    Article  MathSciNet  MATH  Google Scholar 

  36. Bracha, G.: The Programming Language Jigsaw: Mixins, Modularity and Multiple Inheritance. PhD thesis, Dept. of Computer Science, University of Utah (1992)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2009 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Van Cutsem, T., Bergel, A., Ducasse, S., De Meuter, W. (2009). Adding State and Visibility Control to Traits Using Lexical Nesting. In: Drossopoulou, S. (eds) ECOOP 2009 – Object-Oriented Programming. ECOOP 2009. Lecture Notes in Computer Science, vol 5653. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-03013-0_11

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-03013-0_11

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-03012-3

  • Online ISBN: 978-3-642-03013-0

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics