Adding State and Visibility Control to Traits Using Lexical Nesting

  • Tom Van Cutsem
  • Alexandre Bergel
  • Stéphane Ducasse
  • Wolfgang De Meuter
Part of the Lecture Notes in Computer Science book series (LNCS, 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.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Copyright information

© Springer-Verlag Berlin Heidelberg 2009

Authors and Affiliations

  • Tom Van Cutsem
    • 1
  • Alexandre Bergel
    • 2
  • Stéphane Ducasse
    • 2
  • Wolfgang De Meuter
    • 1
  1. 1.Programming Technology LabVrije Universiteit BrusselBelgium
  2. 2.RMoD research group, INRIA LilleFrance

Personalised recommendations