skip to main content
article

User-changeable visibility: resolving unanticipated name clashes in traits

Authors Info & Claims
Published:21 October 2007Publication History
Skip Abstract Section

Abstract

A trait is a unit of behaviour that can be composed with other traits and used by classes. Traits offer an alternative to multiple inheritance. Conflict resolution of traits, while flexible, does not completely handle accidental method name conflicts: if a trait with method m is composed with another trait defining a different method m then resolving the conflict may prove delicate or infeasible in cases where both versions of m are still needed. In this paper we present freezeable traits, which provide an expressive composition mechanism to support unanticipated method composition conflicts. Our solution introduces private trait methods and lets the class composer change method visibility at composition time (from public to private and vice versa). Moreover two class composers may use different composition policies for the same trait, something which is not possible in mainstream languages. This approach respects the two main design principles of traits: the class composer is empowered and traits can be flattened away. We present an implementation of freezable traits in Smalltalk. As a side-effect of this implementation we introduced private (early-bound and invisible) methods to Smalltalk by distinguishing object-sends from self-sends. Our implementation uses compile-time bytecode manipulation and, as such, introduces no run-time penalties.

References

  1. Alexandre Bergel, Stéphane Ducasse, Oscar Nierstrasz, and Roel Wuyts. Stateful traits and their formalization. Journal of Computer Languages, Systems and Structures, 2007. To appear. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Gilad Bracha and Gary Lindstrom. Modularity meets inheritance. Uucs-91-017, University of Utah, Dept. Comp. Sci., October 1991.Google ScholarGoogle Scholar
  3. Gilad Bracha. The Programming Language Jigsaw: Mixins, Modularity and Multiple Inheritance. PhD thesis, Dept. of Computer Science, University of Utah, March 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Andrew P. Black, Nathanael Schärli, and Stéphane Ducasse. Applying traits to the Smalltalk collection hierarchy. In Proceedings of 17th International Conference on Object-Oriented Programming Systems, Languages and Applications (OOPSLA'03), volume 38, pages 47--64, October 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Frank W. Calliss. A comparison of module constructs in programming languages. SIGPLAN Not., 26(1):38--46, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Marcus Denker, Stéphane Ducasse, and Eric Tanter. Runtime bytecode transformation for Smalltalk. Journal of Computer Languages, Systems and Structures, 32(2--3):125--139, July 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Stéphane Ducasse, Oscar Nierstrasz, Nathanael Schärli, Roel Wuyts, and Andrew Black. Traits: A mechanism for fine--grained reuse. ACM Transactions on Programming Languages and Systems (TOPLAS), 28(2):331--388, March 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Matthias Felleisen and Robert Hieb. The revised report on the syntactic theories of sequential control and state. Theor. Comput. Sci., 103(2):235--271, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Matthew Flatt, Shriram Krishnamurthi, and Matthias Felleisen. Classes and mixins. In Proceedings of the 25th ACM SIGPLAN--SIGACT Symposium on Principles of Programming Languages, pages 171--183. ACM Press, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. The Fortress language specification. http://research.sun.com/projects/plrg/fortress0866.pdf.Google ScholarGoogle Scholar
  11. Kathleen Fisher and John Reppy. Statically typed traits. Technical Report TR--2003--13, University of Chicago, Department of Computer Science, December 2003.Google ScholarGoogle Scholar
  12. James Gosling, Bill Joy, Guy Steele, and Gilad Bracha. The Java Language Specification, Second Edition. Addison Wesley, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. James Gosling, Bill Joy, Guy Steele, and Gilad Bracha. The Java Language Specification (Third Edition). Addison Wesley, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Dan Ingalls, Ted Kaehler, John Maloney, Scott Wallace, and Alan Kay. Back to the future: The story of Squeak, A practical Smalltalk written in itself. In Proceedings OOPSLA '97, ACM SIGPLAN Notices, pages 318--326. ACM Press, November 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Bertrand Meyer. Eiffel: The Language. Prentice-Hall, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Bertrand Meyer. Object-Oriented Software Construction. Prentice-Hall, second edition, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Tom Mens and Marc van Limberghen. Encapsulation and composition as orthogonal operators on mixins: A solution to multiple inheritance problems. Object Oriented Systems, 3(1):1--30, 1996.Google ScholarGoogle Scholar
  18. Oscar Nierstrasz, Stéphane Ducasse, and Nathanael Schärli. Flattening Traits. Journal of Object Technology, 5(4):129--148, May 2006.Google ScholarGoogle ScholarCross RefCross Ref
  19. Martin Odersky. Scala language secification v. 2.4. Technical report, Ecole Polytechnique Fédérale de Lausanne, 1015 Lausanne, Switzerland, March 2007.Google ScholarGoogle Scholar
  20. Jon G. Riecke and Christopher A. Stone. Privacy via subsumption. Inf. Comput., 172(1):2--28, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. John Reppy and Aaron Turon. A foundation for trait-based metaprogramming. In International Workshop on Foundations and Developments of Object-Oriented Languages, 2006.Google ScholarGoogle Scholar
  22. John Reppy and Aaron Turon. Metaprogramming with traits. In Proceedings of European Conference on Object-Oriented Programming (ECOOP'2007), 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Nathanael Schärli, Andrew P. Black, and Stéphane Ducasse. Object-oriented encapsulation for dynamically typed languages. In Proceedings of 18th International Conference on Object-Oriented Programming Systems, Languages and Applications (OOPSLA'04), pages 130--149, October 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. The scala programming language. http://lamp.epl.ch/scala/.Google ScholarGoogle Scholar
  25. Charles Smith and Sophia Drossopoulou. Chai: Typed traits in Java. In Proceedings ECOOP 2005, 2005.Google ScholarGoogle Scholar
  26. Nathanael Schärli, Stéphane Ducasse, Oscar Nierstrasz, and Andrew Black. Traits: Composable units of behavior. In Proceedings of European Conference on Object-Oriented Programming (ECOOP'03), volume 2743 of LNCS, pages 248--274. Springer Verlag, July 2003.Google ScholarGoogle ScholarCross RefCross Ref
  27. Slate. http://slate.tunes.org.Google ScholarGoogle Scholar
  28. David Thomas and Andy Hunt. Programming Ruby. Addison Wesley, 2nd edition, 2005.Google ScholarGoogle Scholar
  29. Mario Wolczko. Encapsulation, delegation and inheritance in object-oriented languages. IEEE Software Engineering Journal, 7(2):95--102, March 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. User-changeable visibility: resolving unanticipated name clashes in traits

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 42, Issue 10
        Proceedings of the 2007 OOPSLA conference
        October 2007
        686 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/1297105
        Issue’s Table of Contents
        • cover image ACM Conferences
          OOPSLA '07: Proceedings of the 22nd annual ACM SIGPLAN conference on Object-oriented programming systems, languages and applications
          October 2007
          728 pages
          ISBN:9781595937865
          DOI:10.1145/1297027

        Copyright © 2007 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 21 October 2007

        Check for updates

        Qualifiers

        • article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!