Adding State and Visibility Control to Traits Using Lexical Nesting

  • Authors:
  • Tom Cutsem;Alexandre Bergel;Stéphane Ducasse;Wolfgang Meuter

  • Affiliations:
  • Programming Technology Lab, Vrije Universiteit Brussel, Belgium;RMoD research group, INRIA Lille, France;RMoD research group, INRIA Lille, France;Programming Technology Lab, Vrije Universiteit Brussel, Belgium

  • Venue:
  • Genoa Proceedings of the 23rd European Conference on ECOOP 2009 --- Object-Oriented Programming
  • Year:
  • 2009

Quantified Score

Hi-index 0.00

Visualization

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.