User-Changeable Visibility: Resolving Unanticipated Name Clashes in Traits - Inria - Institut national de recherche en sciences et technologies du numérique Access content directly
Conference Papers Year : 2008

User-Changeable Visibility: Resolving Unanticipated Name Clashes in Traits


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.
No file

Dates and versions

inria-00216103 , version 1 (24-01-2008)


  • HAL Id : inria-00216103 , version 1


Stéphane Ducasse, Oscar Nierstrasz, Roel Wuyts, Alexandre Bergel. User-Changeable Visibility: Resolving Unanticipated Name Clashes in Traits. Proceedings of 22nd International Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA'07), 2008, Montreal, Canada. ⟨inria-00216103⟩
122 View
0 Download


Gmail Facebook X LinkedIn More